Skip to content

Previous UTXO validation for sender #678

Open

Description

@nothingmuch

bitcoin/bips#1396 allowed the UTXO data to be left in the transaction.

the main rationale is that removing this data goes against the BIP 174, so implementations rightfully make that difficult.

BIP 78 does not really specify what to do in case the receiver modifies the outpoints and/or the previous UTXOs:

* For each input in the proposal:
** Verify that no keypaths are in the PSBT input
** Verify that no partial signature has been filled
** If it is one of the sender's inputs:
*** Verify that input's sequence is unchanged.
*** Verify the PSBT input is not finalized
** If it is one of the receiver's inputs:
*** Verify the PSBT input is finalized
*** Verify that <code>non_witness_utxo</code> or <code>witness_utxo</code> are filled in.
** Verify that the payjoin proposal inputs all specify the same sequence value.
** Verify that the payjoin proposal did not introduce mixed input's type.
** Verify that all of sender's inputs from the original PSBT are in the proposal.

Previously re-adding the UTXO was the sender's responsibility, which implied recognizing this input was intended to be used, but we should clarify that the sender should validate that the outpoints are unchanged (in both BIP 78 and 77?).

If the receiver modifies the previous UTXOs and but leaves the outpoints intact, then in some cases (e.g. taproot signatures, or if the amount/script is modified segwit signatures) this will invalidate the transaction, even if the sender manages to somehow produce a signature.

Activity

  1. Jolah1 commented on Aug 11, 2026

    @Jolah1
    Contributor

    I'd like to take this one.
    I wrote a few tests against master to check what's already covered. Outpoint tampering is caught, but only incidentally: a modified sender outpoint stops matching the original, gets classified as a receiver input, and fails the finalization check. The sender is told ReceiverTxinNotFinalized — the wrong party, for the wrong reason.

    The previous-UTXO gap is real. Tampering with witness_utxo or non_witness_utxo on a sender input is accepted, then silently overwritten by restore_original_utxos. The resulting transaction is fine, but nothing reports the misbehavior.

    Proposed scope: validate sender inputs' previous-UTXO data in check_inputs with its own error, give outpoint mismatches an accurate error, and add tests for both.

    One question first: BIP 78 has the receiver strip UTXO data, so an absent witness_utxo is expected and must stay valid only present-and-different should error. Does that match your intent?

  2. xstoicunicornx commented on Sep 29, 2026

    @xstoicunicornx
    Collaborator

    This is still an open issue as #1836 couldn't quite address the root of it.

    Before this can be resolved in PDK I think we need to determine what the expected behavior should be and whether the spec should be updated to reflect that. Then the next piece would be to update PDK to reflect this behavior too.

    To recap, bitcoin/bips#1396 updated the spec to no longer require that sender input UTXO data be wiped from the payjoin proposal that the sender receives for final signing. This leaves ambiguity about what validation needs to be done for the UTXO data, or if any validation is needed at all. The two options I see are:

    1. The sender should validate that UTXO data is the same as what was sent in Original PSBT
    2. The sender should not validate UTXO data and just repopulate sender input UTXO data from scratch

    My preference is to go with option 2, as its the most consistent option and is (conveniently) already implemented this way. With option 1 you still need to populate the sender input UTXO data from scratch in the scenario where the receiver wiped the UTXO data and also creates an error path that needs handling when/if the UTXO data does not match (this error arguably can't be exploited if the sender repopulates UTXO data every time instead).

    Alternatively, we could do something vague that just states that sender should ensure UTXO data is accurate before signing, but leave the exact implementation details unspecified.

    Wrote this as a follow up from #1836 (comment). @DanGould would like your thoughts since it was your tweak to spec that set this issue into motion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions