psbt: support output metadata updates before inputs are added #35797

pull l0rinc wants to merge 6 commits into bitcoin:master from l0rinc:l0rinc/psbt-zero-input-output-update changing 5 files +163 −19
  1. l0rinc commented at 4:33 AM on July 25, 2026: contributor

    Problem: PSBTv2 permits outputs to be added before inputs. An authenticated descriptorprocesspsbt request can abort the node while updating metadata for one of those outputs because UpdatePSBTOutput() traverses its script with a signature creator for input 0. ECDSA signing or a miniscript timelock check can then access the missing input.

    Fix: Make MutableTransactionSignatureCreator reject ECDSA and Schnorr signing and MuSig2 operations when its input index does not exist, and return a rejecting checker for transaction-bound conditions. Output metadata traversal still records scripts and key origins, allowing outputs to be updated before inputs are added.

  2. test: characterize PSBT output metadata
    Document the scripts and key origins collected for common output descriptors before changing zero-input handling.
    Use a valid input for ECDSA-backed outputs because their zero-input paths currently abort.
    c261c2c3c9
  3. sign: reject ECDSA signing without input
    PSBTv2 permits outputs to be added before inputs, but `UpdatePSBTOutput()` traverses output scripts with a signature creator for input 0.
    A descriptor with private key material can therefore reach `SignatureHash()` without a corresponding input and abort.
    Reject the signature attempt while preserving the scripts and key origins collected during traversal.
    97e0758ccb
  4. test: characterize P2WSH miniscript output
    Add a relative-timelock case that consults the transaction checker during output metadata traversal.
    Use a valid input because the pre-fix missing-input path is only reliably diagnosed under a sanitizer.
    59f3f9525f
  5. sign: reject checks without input
    A miniscript relative timelock can consult `CheckSequence()` while `UpdatePSBTOutput()` is only collecting metadata.
    Return a rejecting checker when the creator has no corresponding input, so traversal can continue without reading a missing sequence.
    9f0afec37e
  6. test: characterize Schnorr signature creator
    Document direct Taproot signing with a valid input before covering a missing input index.
    The PSBT output-update path has no precomputed transaction data, so it cannot exercise this sighash path.
    54453625dd
  7. sign: reject Schnorr signing without input
    `ComputeSchnorrSignatureHash()` is shared by Schnorr signing and MuSig2 operations and can pass a missing input index to `SignatureHashSchnorr()`.
    Reject the request before computing the sighash, matching the missing-input behavior for ECDSA signing and transaction checks.
    0fa3581395
  8. DrahtBot added the label PSBT on Jul 25, 2026
  9. DrahtBot commented at 4:33 AM on July 25, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35797.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

Contributors
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-07-25 07:50 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me