Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/handlers/offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ impl AppCommand<AppContext<OfflineOperations<'_>>> for CombinePsbtCommand {
psbts
.into_iter()
.try_fold::<_, _, Result<Psbt, Error>>(init_psbt, |mut acc, x| {
let _ = acc.combine(x);
acc.combine(x)?;
Ok(acc)
})?;

Expand Down
29 changes: 29 additions & 0 deletions tests/integration/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,35 @@ mod test_online {
);
}

#[test]
fn test_combine_psbt_rejects_mismatched_psbts() {
let (cli, mut cmd_init, env) = setup_online_wallet();
cmd_init.assert().success();
fund_and_sync_wallet(&cli, &env);

// Two PSBTs spending the same UTXO but paying different amounts: their
// unsigned transactions differ, so BIP174 forbids combining them.
let psbt_a = cli_create_tx(&cli, &format!("{RECIPIENT}:15000"));
let psbt_b = cli_create_tx(&cli, &format!("{RECIPIENT}:25000"));

let output = cli
.wallet_cmd(&["--wallet", WALLET_NAME, "combine_psbt", &psbt_a, &psbt_b])
.output()
.expect("failed to spawn `combine_psbt`");

assert!(
!output.status.success(),
"combine_psbt should fail on PSBTs with different unsigned transactions, got: {}",
String::from_utf8_lossy(&output.stdout)
);

let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("different unsigned transaction"),
"unexpected error message: {stderr}"
);
}

#[test]
fn test_bump_fee_replaces_unconfirmed_tx() {
let (cli, mut cmd_init, env) = setup_online_wallet();
Expand Down
Loading