Skip to content

Commit

Permalink
style change to the utxo module
Browse files Browse the repository at this point in the history
  • Loading branch information
djordon committed May 11, 2024
1 parent 5c76566 commit 686f3e9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions signer/src/utxo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand All @@ -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;

Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
}
}
Expand Down Expand Up @@ -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<Transaction, Error> {
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);

Expand Down

0 comments on commit 686f3e9

Please sign in to comment.