Skip to content

Commit

Permalink
gui: merge psbt signatures instead of override full psbt
Browse files Browse the repository at this point in the history
While signing in parallele, only new signatures should
be appended without race condition.
  • Loading branch information
edouardparis committed Jan 10, 2024
1 parent c5fff4f commit 0efd790
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion gui/src/app/state/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ impl Action for SignAction {
self.error = None;
self.signed.insert(fingerprint);
let daemon = daemon.clone();
tx.psbt = psbt.clone();
merge_signatures(&mut tx.psbt, &psbt);
if self.is_saved {
return Command::perform(
async move { daemon.update_spend_tx(&psbt).map_err(|e| e.into()) },
Expand Down Expand Up @@ -530,6 +530,22 @@ impl Action for SignAction {
}
}

fn merge_signatures(psbt: &mut Psbt, signed_psbt: &Psbt) {
for i in 0..signed_psbt.inputs.len() {
let psbtin = match psbt.inputs.get_mut(i) {
Some(psbtin) => psbtin,
None => continue,
};
let signed_psbtin = match signed_psbt.inputs.get(i) {
Some(signed_psbtin) => signed_psbtin,
None => continue,
};
psbtin
.partial_sigs
.extend(&mut signed_psbtin.partial_sigs.iter());
}
}

async fn sign_psbt_with_hot_signer(
wallet: Arc<Wallet>,
psbt: Psbt,
Expand Down

0 comments on commit 0efd790

Please sign in to comment.