Repository navigation
Attach inputs and outputs added through PSBT2.AddInput and AddOutput - #1363
Merged
NicolasDorier merged 1 commit intoOct 27, 2026
Merged
Conversation
PSBT2.AddInput and PSBT2.AddOutput built a new input or output but never added it to the PSBT, and callers outside NBitcoin cannot attach it themselves because PSBTInputList.Add and PSBTOutputList.Add are internal. Both methods now add what they build before returning it. AddOutput now reports "Outputs are not modifiable" instead of "Inputs are not modifiable", and no longer builds an unused TxOut. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
PSBT2.AddInputandPSBT2.AddOutputbuild a new input or output but never add it to the PSBT. Callers outside NBitcoin cannot attach it themselves, becausePSBTInputList.AddandPSBTOutputList.Addare internal. So the PSBT is left unchanged.Both methods now add what they build before returning it, like
TxInList.AddandTxOutList.Adddo. Also:AddOutputreports "Outputs are not modifiable" instead of "Inputs are not modifiable".TxOutinAddOutputis removed.AddOutputUsesOutputIndexno longer attaches the first output by hand, which would now add it twice. It was the only caller doing that.If you'd rather keep
AddInput/AddOutputas builders, the alternative is to make the listAddmethods public. That would let callers skip the modifiable-flag check, which is why I went this way. Happy to switch if you prefer it.New tests cover attaching, a serialization round trip, and the modifiable-flag errors. The PSBT, Miniscript and Taproot tests pass on net10.0, except the ones that download bitcoind, which fail the same way without this change.
🤖 Generated with Claude Code