Run `rustfmt` on `sign/taproot.rs`
authorElias Rohrer <dev@tnull.de>
Wed, 27 Mar 2024 11:14:24 +0000 (12:14 +0100)
committerElias Rohrer <dev@tnull.de>
Tue, 9 Apr 2024 11:09:50 +0000 (13:09 +0200)
lightning/src/sign/taproot.rs

index 230383f4f7d6496bcb1b7d40829b086ea6d39d05..7536b68a8793b59dc79a0a7661fdef8881712c4e 100644 (file)
@@ -3,11 +3,13 @@
 use alloc::vec::Vec;
 use bitcoin::blockdata::transaction::Transaction;
 use bitcoin::secp256k1;
-use bitcoin::secp256k1::{PublicKey, schnorr::Signature, Secp256k1, SecretKey};
+use bitcoin::secp256k1::{schnorr::Signature, PublicKey, Secp256k1, SecretKey};
 
 use musig2::types::{PartialSignature, PublicNonce};
 
-use crate::ln::chan_utils::{ClosingTransaction, CommitmentTransaction, HolderCommitmentTransaction, HTLCOutputInCommitment};
+use crate::ln::chan_utils::{
+       ClosingTransaction, CommitmentTransaction, HTLCOutputInCommitment, HolderCommitmentTransaction,
+};
 use crate::ln::msgs::PartialSignatureWithNonce;
 use crate::ln::PaymentPreimage;
 use crate::sign::{ChannelSigner, HTLCDescriptor};
@@ -18,7 +20,9 @@ use crate::sign::{ChannelSigner, HTLCDescriptor};
 pub trait TaprootChannelSigner: ChannelSigner {
        /// Generate a local nonce pair, which requires committing to ahead of time.
        /// The counterparty needs the public nonce generated herein to compute a partial signature.
-       fn generate_local_nonce_pair(&self, commitment_number: u64, secp_ctx: &Secp256k1<secp256k1::All>) -> PublicNonce;
+       fn generate_local_nonce_pair(
+               &self, commitment_number: u64, secp_ctx: &Secp256k1<secp256k1::All>,
+       ) -> PublicNonce;
 
        /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
        ///
@@ -36,8 +40,8 @@ pub trait TaprootChannelSigner: ChannelSigner {
        /// irrelevant or duplicate preimages.
        //
        // TODO: Document the things someone using this interface should enforce before signing.
-       fn partially_sign_counterparty_commitment(&self, counterparty_nonce: PublicNonce,
-               commitment_tx: &CommitmentTransaction,
+       fn partially_sign_counterparty_commitment(
+               &self, counterparty_nonce: PublicNonce, commitment_tx: &CommitmentTransaction,
                inbound_htlc_preimages: Vec<PaymentPreimage>,
                outbound_htlc_preimages: Vec<PaymentPreimage>, secp_ctx: &Secp256k1<secp256k1::All>,
        ) -> Result<(PartialSignatureWithNonce, Vec<Signature>), ()>;
@@ -53,9 +57,10 @@ pub trait TaprootChannelSigner: ChannelSigner {
        /// An external signer implementation should check that the commitment has not been revoked.
        ///
        // TODO: Document the things someone using this interface should enforce before signing.
-       fn finalize_holder_commitment(&self, commitment_tx: &HolderCommitmentTransaction,
+       fn finalize_holder_commitment(
+               &self, commitment_tx: &HolderCommitmentTransaction,
                counterparty_partial_signature: PartialSignatureWithNonce,
-               secp_ctx: &Secp256k1<secp256k1::All>
+               secp_ctx: &Secp256k1<secp256k1::All>,
        ) -> Result<PartialSignature, ()>;
 
        /// Create a signature for the given input in a transaction spending an HTLC transaction output
@@ -72,8 +77,9 @@ pub trait TaprootChannelSigner: ChannelSigner {
        /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
        /// not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
        /// so).
-       fn sign_justice_revoked_output(&self, justice_tx: &Transaction, input: usize, amount: u64,
-               per_commitment_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>,
+       fn sign_justice_revoked_output(
+               &self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
+               secp_ctx: &Secp256k1<secp256k1::All>,
        ) -> Result<Signature, ()>;
 
        /// Create a signature for the given input in a transaction spending a commitment transaction
@@ -94,9 +100,10 @@ pub trait TaprootChannelSigner: ChannelSigner {
        ///
        /// `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
        /// (which is committed to in the BIP 341 signatures).
-       fn sign_justice_revoked_htlc(&self, justice_tx: &Transaction, input: usize, amount: u64,
-               per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
-               secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()>;
+       fn sign_justice_revoked_htlc(
+               &self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
+               htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
+       ) -> Result<Signature, ()>;
 
        /// Computes the signature for a commitment transaction's HTLC output used as an input within
        /// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
@@ -109,8 +116,9 @@ pub trait TaprootChannelSigner: ChannelSigner {
        ///
        /// [`TapSighashType::Default`]: bitcoin::sighash::TapSighashType::Default
        /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
-       fn sign_holder_htlc_transaction(&self, htlc_tx: &Transaction, input: usize,
-               htlc_descriptor: &HTLCDescriptor, secp_ctx: &Secp256k1<secp256k1::All>,
+       fn sign_holder_htlc_transaction(
+               &self, htlc_tx: &Transaction, input: usize, htlc_descriptor: &HTLCDescriptor,
+               secp_ctx: &Secp256k1<secp256k1::All>,
        ) -> Result<Signature, ()>;
 
        /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
@@ -130,16 +138,18 @@ pub trait TaprootChannelSigner: ChannelSigner {
        /// detected onchain. It has been generated by our counterparty and is used to derive
        /// channel state keys, which are then included in the witness script and committed to in the
        /// BIP 341 signature.
-       fn sign_counterparty_htlc_transaction(&self, htlc_tx: &Transaction, input: usize, amount: u64,
-               per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment,
-               secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()>;
+       fn sign_counterparty_htlc_transaction(
+               &self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey,
+               htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
+       ) -> Result<Signature, ()>;
 
        /// Create a signature for a (proposed) closing transaction.
        ///
        /// Note that, due to rounding, there may be one "missing" satoshi, and either party may have
        /// chosen to forgo their output as dust.
-       fn partially_sign_closing_transaction(&self, closing_tx: &ClosingTransaction,
-               secp_ctx: &Secp256k1<secp256k1::All>) -> Result<PartialSignature, ()>;
+       fn partially_sign_closing_transaction(
+               &self, closing_tx: &ClosingTransaction, secp_ctx: &Secp256k1<secp256k1::All>,
+       ) -> Result<PartialSignature, ()>;
 
        /// Computes the signature for a commitment transaction's anchor output used as an
        /// input within `anchor_tx`, which spends the commitment transaction, at index `input`.