Skip to content
Merged
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
38 changes: 24 additions & 14 deletions payjoin/src/receive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,23 @@ impl ProvisionalProposal {
input.bip32_derivation = BTreeMap::new();
input.partial_sigs = BTreeMap::new();
}
for i in self.sender_input_indexes() {
log::trace!("Clearing sender input {}", i);
self.payjoin_psbt.inputs[i].non_witness_utxo = None;
self.payjoin_psbt.inputs[i].witness_utxo = None;
self.payjoin_psbt.inputs[i].final_script_sig = None;
self.payjoin_psbt.inputs[i].final_script_witness = None;
self.payjoin_psbt.inputs[i].tap_key_sig = None;
}

Ok(PayjoinProposal {
payjoin_psbt: self.payjoin_psbt,
owned_vouts: self.owned_vouts,
params: self.params,
})
}

fn sender_input_indexes(&self) -> Vec<usize> {
// iterate proposal as mutable WITH the outpoint (previous_output) available too
let mut original_inputs = self.original_psbt.input_pairs().peekable();
let mut sender_input_indexes = vec![];
Expand All @@ -559,27 +576,20 @@ impl ProvisionalProposal {
}
}
}

for i in sender_input_indexes {
log::trace!("Clearing sender input {}", i);
self.payjoin_psbt.inputs[i].non_witness_utxo = None;
self.payjoin_psbt.inputs[i].witness_utxo = None;
self.payjoin_psbt.inputs[i].final_script_sig = None;
self.payjoin_psbt.inputs[i].final_script_witness = None;
self.payjoin_psbt.inputs[i].tap_key_sig = None;
}
Ok(PayjoinProposal {
payjoin_psbt: self.payjoin_psbt,
owned_vouts: self.owned_vouts,
params: self.params,
})
sender_input_indexes
}

pub fn finalize_proposal(
mut self,
wallet_process_psbt: impl Fn(&Psbt) -> Result<Psbt, Error>,
min_feerate_sat_per_vb: Option<FeeRate>,
) -> Result<PayjoinProposal, Error> {
for i in self.sender_input_indexes() {
log::trace!("Clearing sender script signatures for input {}", i);
self.payjoin_psbt.inputs[i].final_script_sig = None;
self.payjoin_psbt.inputs[i].final_script_witness = None;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should final_script_sig and tap_key_sig also be removed at this step? Might they cause problems if they were not removed before wallet_process_psbt of various implementations?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems reasonable to remove all signatures at this step as they would be invalid anyways. Updated and smoke-tested with another test receive.

self.payjoin_psbt.inputs[i].tap_key_sig = None;
}
let psbt = self.apply_fee(min_feerate_sat_per_vb)?;
let psbt = wallet_process_psbt(psbt)?;
let payjoin_proposal = self.prepare_psbt(psbt)?;
Expand Down