From 686f3e91a4e8bd49939d527692aea11e3a9df59c Mon Sep 17 00:00:00 2001 From: djordon Date: Fri, 10 May 2024 23:35:02 -0400 Subject: [PATCH] style change to the utxo module --- signer/src/utxo.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/signer/src/utxo.rs b/signer/src/utxo.rs index 9d5657a1b..3c233ed04 100644 --- a/signer/src/utxo.rs +++ b/signer/src/utxo.rs @@ -112,12 +112,12 @@ impl DepositRequest { /// Create a TxIn object with witness data for the deposit script of /// the given request. Only a valid signature is needed to satisfy the /// deposit script. - fn as_tx_input(&self, sig: Signature) -> TxIn { + fn as_tx_input(&self, signature: Signature) -> TxIn { TxIn { previous_output: self.outpoint, script_sig: ScriptBuf::new(), sequence: Sequence(0), - witness: self.construct_witness_data(sig), + witness: self.construct_witness_data(signature), } } @@ -135,7 +135,7 @@ impl DepositRequest { /// given by self.signers_public_key. The public key used for key-path /// spending is self.taproot_public_key, and is supposed to be a dummy /// public key. - pub fn construct_witness_data(&self, sig: Signature) -> Witness { + pub fn construct_witness_data(&self, signature: Signature) -> Witness { let (internal_key, _) = self.taproot_public_key.inner.x_only_public_key(); let ver = LeafVersion::TapScript; @@ -160,6 +160,7 @@ impl DepositRequest { let x_signers_public_key = self.signers_public_key.inner.x_only_public_key().0; let witness_data = [ + signature.to_vec(), x_signers_public_key.serialize().to_vec(), self.deposit_script.to_bytes(), control_block.serialize(), @@ -250,11 +251,11 @@ impl SignerUtxo { /// /// The signers' UTXO is always a key-spend only taproot UTXO, so a /// valid signature is all that is needed to spend it. - fn as_tx_input(&self, sig: &Signature) -> TxIn { + fn as_tx_input(&self, signature: &Signature) -> TxIn { TxIn { previous_output: self.outpoint, sequence: Sequence::ZERO, - witness: Witness::p2tr_key_spend(sig), + witness: Witness::p2tr_key_spend(signature), script_sig: ScriptBuf::new(), } } @@ -333,16 +334,16 @@ impl<'a> UnsignedTransaction<'a> { /// An Err is returned if the amounts withdrawn is greater than the sum /// of all the input amounts. fn new_transaction(reqs: &[Request], state: &SignerBtcState) -> Result { - let sig = Self::generate_dummy_signature(); + let signature = Self::generate_dummy_signature(); let deposits = reqs .iter() - .filter_map(|req| Some(req.as_deposit()?.as_tx_input(sig))); + .filter_map(|req| Some(req.as_deposit()?.as_tx_input(signature))); let withdrawals = reqs .iter() .filter_map(|req| Some(req.as_withdrawal()?.as_tx_output())); - let signer_input = state.utxo.as_tx_input(&sig); + let signer_input = state.utxo.as_tx_input(&signature); let signer_output_sats = Self::compute_signer_amount(reqs, state)?; let signer_output = SignerUtxo::new_tx_output(state.public_key, signer_output_sats);