Skip to content

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

Open
l0rinc wants to merge 6 commits into
bitcoin:masterfrom
l0rinc:l0rinc/psbt-zero-input-output-update
Open

psbt: support output metadata updates before inputs are added#35797
l0rinc wants to merge 6 commits into
bitcoin:masterfrom
l0rinc:l0rinc/psbt-zero-input-output-update

Conversation

@l0rinc

@l0rinc l0rinc commented Jul 25, 2026

Copy link
Copy Markdown
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.

l0rinc added 6 commits July 24, 2026 21:27
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.
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.
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.
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.
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.
`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.
@DrahtBot DrahtBot added the PSBT label Jul 25, 2026
@DrahtBot

DrahtBot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

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

Code Coverage & Benchmarks

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

Reviews

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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants