3
3
use alloc:: vec:: Vec ;
4
4
use bitcoin:: blockdata:: transaction:: Transaction ;
5
5
use bitcoin:: secp256k1;
6
- use bitcoin:: secp256k1:: { PublicKey , schnorr:: Signature , Secp256k1 , SecretKey } ;
6
+ use bitcoin:: secp256k1:: { schnorr:: Signature , PublicKey , Secp256k1 , SecretKey } ;
7
7
8
8
use musig2:: types:: { PartialSignature , PublicNonce } ;
9
9
10
- use crate :: ln:: chan_utils:: { ClosingTransaction , CommitmentTransaction , HolderCommitmentTransaction , HTLCOutputInCommitment } ;
10
+ use crate :: ln:: chan_utils:: {
11
+ ClosingTransaction , CommitmentTransaction , HTLCOutputInCommitment , HolderCommitmentTransaction ,
12
+ } ;
11
13
use crate :: ln:: msgs:: PartialSignatureWithNonce ;
12
14
use crate :: ln:: PaymentPreimage ;
13
15
use crate :: sign:: { ChannelSigner , HTLCDescriptor } ;
@@ -18,7 +20,9 @@ use crate::sign::{ChannelSigner, HTLCDescriptor};
18
20
pub trait TaprootChannelSigner : ChannelSigner {
19
21
/// Generate a local nonce pair, which requires committing to ahead of time.
20
22
/// The counterparty needs the public nonce generated herein to compute a partial signature.
21
- fn generate_local_nonce_pair ( & self , commitment_number : u64 , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> PublicNonce ;
23
+ fn generate_local_nonce_pair (
24
+ & self , commitment_number : u64 , secp_ctx : & Secp256k1 < secp256k1:: All > ,
25
+ ) -> PublicNonce ;
22
26
23
27
/// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
24
28
///
@@ -36,8 +40,8 @@ pub trait TaprootChannelSigner: ChannelSigner {
36
40
/// irrelevant or duplicate preimages.
37
41
//
38
42
// TODO: Document the things someone using this interface should enforce before signing.
39
- fn partially_sign_counterparty_commitment ( & self , counterparty_nonce : PublicNonce ,
40
- commitment_tx : & CommitmentTransaction ,
43
+ fn partially_sign_counterparty_commitment (
44
+ & self , counterparty_nonce : PublicNonce , commitment_tx : & CommitmentTransaction ,
41
45
inbound_htlc_preimages : Vec < PaymentPreimage > ,
42
46
outbound_htlc_preimages : Vec < PaymentPreimage > , secp_ctx : & Secp256k1 < secp256k1:: All > ,
43
47
) -> Result < ( PartialSignatureWithNonce , Vec < Signature > ) , ( ) > ;
@@ -53,9 +57,10 @@ pub trait TaprootChannelSigner: ChannelSigner {
53
57
/// An external signer implementation should check that the commitment has not been revoked.
54
58
///
55
59
// TODO: Document the things someone using this interface should enforce before signing.
56
- fn finalize_holder_commitment ( & self , commitment_tx : & HolderCommitmentTransaction ,
60
+ fn finalize_holder_commitment (
61
+ & self , commitment_tx : & HolderCommitmentTransaction ,
57
62
counterparty_partial_signature : PartialSignatureWithNonce ,
58
- secp_ctx : & Secp256k1 < secp256k1:: All >
63
+ secp_ctx : & Secp256k1 < secp256k1:: All > ,
59
64
) -> Result < PartialSignature , ( ) > ;
60
65
61
66
/// Create a signature for the given input in a transaction spending an HTLC transaction output
@@ -72,8 +77,9 @@ pub trait TaprootChannelSigner: ChannelSigner {
72
77
/// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
73
78
/// not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
74
79
/// so).
75
- fn sign_justice_revoked_output ( & self , justice_tx : & Transaction , input : usize , amount : u64 ,
76
- per_commitment_key : & SecretKey , secp_ctx : & Secp256k1 < secp256k1:: All > ,
80
+ fn sign_justice_revoked_output (
81
+ & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey ,
82
+ secp_ctx : & Secp256k1 < secp256k1:: All > ,
77
83
) -> Result < Signature , ( ) > ;
78
84
79
85
/// Create a signature for the given input in a transaction spending a commitment transaction
@@ -94,9 +100,10 @@ pub trait TaprootChannelSigner: ChannelSigner {
94
100
///
95
101
/// `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
96
102
/// (which is committed to in the BIP 341 signatures).
97
- fn sign_justice_revoked_htlc ( & self , justice_tx : & Transaction , input : usize , amount : u64 ,
98
- per_commitment_key : & SecretKey , htlc : & HTLCOutputInCommitment ,
99
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
103
+ fn sign_justice_revoked_htlc (
104
+ & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey ,
105
+ htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ,
106
+ ) -> Result < Signature , ( ) > ;
100
107
101
108
/// Computes the signature for a commitment transaction's HTLC output used as an input within
102
109
/// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
@@ -109,8 +116,9 @@ pub trait TaprootChannelSigner: ChannelSigner {
109
116
///
110
117
/// [`TapSighashType::Default`]: bitcoin::sighash::TapSighashType::Default
111
118
/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
112
- fn sign_holder_htlc_transaction ( & self , htlc_tx : & Transaction , input : usize ,
113
- htlc_descriptor : & HTLCDescriptor , secp_ctx : & Secp256k1 < secp256k1:: All > ,
119
+ fn sign_holder_htlc_transaction (
120
+ & self , htlc_tx : & Transaction , input : usize , htlc_descriptor : & HTLCDescriptor ,
121
+ secp_ctx : & Secp256k1 < secp256k1:: All > ,
114
122
) -> Result < Signature , ( ) > ;
115
123
116
124
/// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
@@ -130,16 +138,18 @@ pub trait TaprootChannelSigner: ChannelSigner {
130
138
/// detected onchain. It has been generated by our counterparty and is used to derive
131
139
/// channel state keys, which are then included in the witness script and committed to in the
132
140
/// BIP 341 signature.
133
- fn sign_counterparty_htlc_transaction ( & self , htlc_tx : & Transaction , input : usize , amount : u64 ,
134
- per_commitment_point : & PublicKey , htlc : & HTLCOutputInCommitment ,
135
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
141
+ fn sign_counterparty_htlc_transaction (
142
+ & self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey ,
143
+ htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ,
144
+ ) -> Result < Signature , ( ) > ;
136
145
137
146
/// Create a signature for a (proposed) closing transaction.
138
147
///
139
148
/// Note that, due to rounding, there may be one "missing" satoshi, and either party may have
140
149
/// chosen to forgo their output as dust.
141
- fn partially_sign_closing_transaction ( & self , closing_tx : & ClosingTransaction ,
142
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < PartialSignature , ( ) > ;
150
+ fn partially_sign_closing_transaction (
151
+ & self , closing_tx : & ClosingTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
152
+ ) -> Result < PartialSignature , ( ) > ;
143
153
144
154
/// Computes the signature for a commitment transaction's anchor output used as an
145
155
/// input within `anchor_tx`, which spends the commitment transaction, at index `input`.
0 commit comments