From decaa2928523e236f855892840f316b67a5fbbb4 Mon Sep 17 00:00:00 2001 From: spacebear Date: Mon, 12 Aug 2024 15:18:49 -0400 Subject: [PATCH] Remove `contribute_non_witness_input` 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. --- payjoin/src/receive/mod.rs | 35 ----------------------------------- payjoin/src/receive/v2/mod.rs | 4 ---- 2 files changed, 39 deletions(-) diff --git a/payjoin/src/receive/mod.rs b/payjoin/src/receive/mod.rs index 1ff936e8..78bafaf3 100644 --- a/payjoin/src/receive/mod.rs +++ b/payjoin/src/receive/mod.rs @@ -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 } diff --git a/payjoin/src/receive/v2/mod.rs b/payjoin/src/receive/v2/mod.rs index 78a4fe06..0d40b467 100644 --- a/payjoin/src/receive/v2/mod.rs +++ b/payjoin/src/receive/v2/mod.rs @@ -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() }