Skip to content

Commit

Permalink
Fix #424 by iterating original_input on match (#428)
Browse files Browse the repository at this point in the history
The payjoin psbt construction code reintroduces original psbt inputs that
the receiver may have lost. It does this by iterating through each
proposed input and original input.

This fix only iterates to the next original_input once a proposed input
that matches is found, otherwise inputs could be skipped and signing
could fail. The outer loop already iterates through proposed inputs.
Inputs in the proposal are in the same order as the original as per spec,
and just insert receiver inputs so this iteration will always find matches.
  • Loading branch information
DanGould authored Nov 29, 2023
1 parent b31268f commit fe923c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/bitcoin/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ fn add_back_original_input(original_psbt: &Psbt, payjoin_psbt: Psbt) -> Psbt {
if proposed_txin.previous_output == original_txin.previous_output {
proposed_psbtin.witness_utxo = original_psbtin.witness_utxo.clone();
proposed_psbtin.non_witness_utxo = original_psbtin.non_witness_utxo.clone();
original_inputs.next();
}
original_inputs.next();
}
}
payjoin_psbt
Expand Down

0 comments on commit fe923c8

Please sign in to comment.