Skip to content

Commit

Permalink
Remove contribute_non_witness_input
Browse files Browse the repository at this point in the history
Remove a maintenance burden that's unnecessary at this time. Support for
non_witness inputs can be added back later if/when we move to using
PSBTv2 internally, without having to maintain separate logic.
  • Loading branch information
spacebear21 committed Aug 12, 2024
1 parent a01c6a8 commit decaa29
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
35 changes: 0 additions & 35 deletions payjoin/src/receive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,41 +459,6 @@ impl ProvisionalProposal {
);
}

pub fn contribute_non_witness_input(&mut self, tx: bitcoin::Transaction, outpoint: OutPoint) {
// The payjoin proposal must not introduce mixed input sequence numbers
let original_sequence = self
.payjoin_psbt
.unsigned_tx
.input
.first()
.map(|input| input.sequence)
.unwrap_or_default();

// Add the value of new receiver input to receiver output
let txo_value = tx.output[outpoint.vout as usize].value;
let vout_to_augment =
self.owned_vouts.choose(&mut rand::thread_rng()).expect("owned_vouts is empty");
self.payjoin_psbt.unsigned_tx.output[*vout_to_augment].value += txo_value;

// Insert contribution at random index for privacy
let mut rng = rand::thread_rng();
let index = rng.gen_range(0..=self.payjoin_psbt.unsigned_tx.input.len());

// Add the new input to the PSBT
self.payjoin_psbt.inputs.insert(
index,
bitcoin::psbt::Input { non_witness_utxo: Some(tx), ..Default::default() },
);
self.payjoin_psbt.unsigned_tx.input.insert(
index,
bitcoin::TxIn {
previous_output: outpoint,
sequence: original_sequence,
..Default::default()
},
);
}

pub fn is_output_substitution_disabled(&self) -> bool {
self.params.disable_output_substitution
}
Expand Down
4 changes: 0 additions & 4 deletions payjoin/src/receive/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,6 @@ impl ProvisionalProposal {
self.inner.contribute_witness_input(txo, outpoint)
}

pub fn contribute_non_witness_input(&mut self, tx: bitcoin::Transaction, outpoint: OutPoint) {
self.inner.contribute_non_witness_input(tx, outpoint)
}

pub fn is_output_substitution_disabled(&self) -> bool {
self.inner.is_output_substitution_disabled()
}
Expand Down

0 comments on commit decaa29

Please sign in to comment.