Skip to content

combine_psbt silently drops PSBTs that fail to combine (exit 0, incomplete output) #323

Description

@tvpeter

Describe the bug

bdk-cli wallet … combine_psbt discards the error from Psbt::combine, so when two PSBTs are incompatible (different unsigned transactions) the command exits 0 and prints a "combined" PSBT that is silently missing the other PSBT's inputs/signatures, instead of failing.

The fold that merges the PSBTs discards each combine result:

let final_psbt = psbts.into_iter().try_fold::<_, _, Result<Psbt, Error>>(
    init_psbt,
    |mut acc, x| {
        let _ = acc.combine(x);   // error dropped here
        Ok(acc)
    },
)?;

Per BIP174, Psbt::combine returns Err whenever the two PSBTs don't describe the same unsigned transaction (different txids/outputs).

To Reproduce

Two PSBTs with different unsigned transactions (BIP174-incompatible):

 bdk-cli wallet -w demo combine_psbt $A $B
# exit 0; output == B, with A silently dropped

 bdk-cli wallet -w demo combine_psbt $A $A
# control: valid combine, output == A

Expected behavior

  • non-zero exit and an error explaining the PSBTs could not be combined.

Build environment

  • BDK-CLI tag/commit: bdk-cli v4.0.0 bdk-cli 5b3cb00

Additional context

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions