Conversation
The fold merging the input PSBTs discarded each combine result with `let _ = acc.combine(x)`. Per BIP174, Psbt::combine returns Err whenever the two PSBTs do not describe the same unsigned transaction, so incompatible inputs left the accumulator untouched. This fix propagates the error with `?`. BDKCliError already converts from bitcoin::psbt::Error, so the command now exits non-zero. Fixes bitcoindevkit#323
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #324 +/- ##
=======================================
Coverage 57.78% 57.78%
=======================================
Files 22 22
Lines 3733 3733
=======================================
Hits 2157 2157
Misses 1576 1576
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vadim-anfv
approved these changes
Sep 21, 2026
vadim-anfv
left a comment
Collaborator
There was a problem hiding this comment.
tACK 682e414
Reproduced offline with two PSBTs spending the same dummy input but with different outputs, so their unsigned txs differ:
A=$(bitcoin-cli createpsbt '[{"txid":"1111111111111111111111111111111111111111111111111111111111111111","vout":0}]' '[{"data":"aa"}]')
B=$(bitcoin-cli createpsbt '[{"txid":"1111111111111111111111111111111111111111111111111111111111111111","vout":0}]' '[{"data":"bb"}]')
echo $A; echo $B
cHNidP8BAD8CAAAAARERERERERERERERERERERERERERERERERERERERERERAAAAAAD9////AQAAAAAAAAAAA2oBqgAAAAAAAAA=
cHNidP8BAD8CAAAAARERERERERERERERERERERERERERERERERERERERERERAAAAAAD9////AQAAAAAAAAAAA2oBuwAAAAAAAAA=
D=$(mktemp -d)
DESC=$(cargo run -q -- -n regtest -d $D descriptor --type tr | jq -r .private_descriptors.external)
cargo run -q -- -n regtest -d $D wallet -w demo config -e "$DESC" --database-type sqlitemaster: A B exits 0 and returns B, A is silently dropped.
$ cargo run -q -- -n regtest -d $D wallet -w demo combine_psbt $A $B; echo "exit=$?"
{
"psbt": "cHNidP8BAD8CAAAAARERERERERERERERERERERERERERERERERERERERERERAAAAAAD9////AQAAAAAAAAAAA2oBuwAAAAAAAAA=",
"is_finalized": false
}
exit=0
$ cargo run -q -- -n regtest -d $D wallet -w demo combine_psbt $A $A; echo "exit=$?"
{
"psbt": "cHNidP8BAD8CAAAAARERERERERERERERERERERERERERERERERERERERERERAAAAAAD9////AQAAAAAAAAAAA2oBqgAAAAAAAAA=",
"is_finalized": false
}
exit=0
this branch: A B fails, A A unchanged.
$ cargo run -q -- -n regtest -d $D wallet -w demo combine_psbt $A $B; echo "exit=$?"
Error: PsbtError: different unsigned transaction: expected 26defa6e8fa255cd46eac60b7a3f9e415515297498da7cecdffdd8bc818aa37a, actual 1a67d0770fe1ffa6d1d745fe12aee522cdb44985c6aee69ebe15ed80caa225ae
exit=1
$ cargo run -q -- -n regtest -d $D wallet -w demo combine_psbt $A $A; echo "exit=$?"
{
"psbt": "cHNidP8BAD8CAAAAARERERERERERERERERERERERERERERERERERERERERERAAAAAAD9////AQAAAAAAAAAAA2oBqgAAAAAAAAA=",
"is_finalized": false
}
exit=0
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.
Description
wallet ... combine_psbtdiscarded the result of everyPsbt::combinecall, so two BIP174-incompatible PSBTs (different unsigned transactions) produced exit code 0 and a PSBT that was silently missing the other PSBT's inputs and signatures.This PR propagates the error with
?.BDKCliErroralready has a#[from]impl forbitcoin::psbt::Error, so no new error variant was needed.Fixes #323
Changelog notice
combine_psbtto fail when PSBTs cannot be combined instead of silently dropping themChecklists
All Submissions:
cargo fmtandcargo clippybefore committingBugfixes: