psbt: support output metadata updates before inputs are added#35797
Open
l0rinc wants to merge 6 commits into
Open
psbt: support output metadata updates before inputs are added#35797l0rinc wants to merge 6 commits into
l0rinc wants to merge 6 commits into
Conversation
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.
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35797. ReviewsSee the guideline and AI policy for information on the review process. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: PSBTv2 permits outputs to be added before inputs.
An authenticated
descriptorprocesspsbtrequest can abort the node while updating metadata for one of those outputs becauseUpdatePSBTOutput()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
MutableTransactionSignatureCreatorreject 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.