2
2
3
3
use bitcoin:: blockdata:: transaction:: Transaction ;
4
4
5
- use bitcoin:: secp256k1:: { PublicKey , Secp256k1 , SecretKey } ;
6
- use bitcoin:: secp256k1:: ecdsa:: Signature ;
7
5
use bitcoin:: secp256k1;
6
+ use bitcoin:: secp256k1:: ecdsa:: Signature ;
7
+ use bitcoin:: secp256k1:: { PublicKey , Secp256k1 , SecretKey } ;
8
8
9
- use crate :: util :: ser :: Writeable ;
10
- use crate :: ln :: PaymentPreimage ;
11
- use crate :: ln :: chan_utils :: { HTLCOutputInCommitment , HolderCommitmentTransaction , CommitmentTransaction , ClosingTransaction } ;
9
+ use crate :: ln :: chan_utils :: {
10
+ ClosingTransaction , CommitmentTransaction , HTLCOutputInCommitment , HolderCommitmentTransaction ,
11
+ } ;
12
12
use crate :: ln:: msgs:: UnsignedChannelAnnouncement ;
13
+ use crate :: ln:: PaymentPreimage ;
14
+ use crate :: util:: ser:: Writeable ;
13
15
14
16
#[ allow( unused_imports) ]
15
17
use crate :: prelude:: * ;
@@ -40,8 +42,8 @@ pub trait EcdsaChannelSigner: ChannelSigner {
40
42
/// irrelevant or duplicate preimages.
41
43
//
42
44
// TODO: Document the things someone using this interface should enforce before signing.
43
- fn sign_counterparty_commitment ( & self , commitment_tx : & CommitmentTransaction ,
44
- inbound_htlc_preimages : Vec < PaymentPreimage > ,
45
+ fn sign_counterparty_commitment (
46
+ & self , commitment_tx : & CommitmentTransaction , inbound_htlc_preimages : Vec < PaymentPreimage > ,
45
47
outbound_htlc_preimages : Vec < PaymentPreimage > , secp_ctx : & Secp256k1 < secp256k1:: All > ,
46
48
) -> Result < ( Signature , Vec < Signature > ) , ( ) > ;
47
49
/// Creates a signature for a holder's commitment transaction.
@@ -62,15 +64,17 @@ pub trait EcdsaChannelSigner: ChannelSigner {
62
64
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
63
65
//
64
66
// TODO: Document the things someone using this interface should enforce before signing.
65
- fn sign_holder_commitment ( & self , commitment_tx : & HolderCommitmentTransaction ,
66
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
67
+ fn sign_holder_commitment (
68
+ & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
69
+ ) -> Result < Signature , ( ) > ;
67
70
/// Same as [`sign_holder_commitment`], but exists only for tests to get access to holder
68
71
/// commitment transactions which will be broadcasted later, after the channel has moved on to a
69
72
/// newer state. Thus, needs its own method as [`sign_holder_commitment`] may enforce that we
70
73
/// only ever get called once.
71
- #[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
72
- fn unsafe_sign_holder_commitment ( & self , commitment_tx : & HolderCommitmentTransaction ,
73
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
74
+ #[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
75
+ fn unsafe_sign_holder_commitment (
76
+ & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
77
+ ) -> Result < Signature , ( ) > ;
74
78
/// Create a signature for the given input in a transaction spending an HTLC transaction output
75
79
/// or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
76
80
///
@@ -92,8 +96,9 @@ pub trait EcdsaChannelSigner: ChannelSigner {
92
96
/// monitor.
93
97
///
94
98
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
95
- fn sign_justice_revoked_output ( & self , justice_tx : & Transaction , input : usize , amount : u64 ,
96
- per_commitment_key : & SecretKey , secp_ctx : & Secp256k1 < secp256k1:: All >
99
+ fn sign_justice_revoked_output (
100
+ & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey ,
101
+ secp_ctx : & Secp256k1 < secp256k1:: All > ,
97
102
) -> Result < Signature , ( ) > ;
98
103
/// Create a signature for the given input in a transaction spending a commitment transaction
99
104
/// HTLC output when our counterparty broadcasts an old state.
@@ -120,9 +125,10 @@ pub trait EcdsaChannelSigner: ChannelSigner {
120
125
/// monitor.
121
126
///
122
127
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
123
- fn sign_justice_revoked_htlc ( & self , justice_tx : & Transaction , input : usize , amount : u64 ,
124
- per_commitment_key : & SecretKey , htlc : & HTLCOutputInCommitment ,
125
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
128
+ fn sign_justice_revoked_htlc (
129
+ & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey ,
130
+ htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ,
131
+ ) -> Result < Signature , ( ) > ;
126
132
/// Computes the signature for a commitment transaction's HTLC output used as an input within
127
133
/// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
128
134
/// must be be computed using [`EcdsaSighashType::All`].
@@ -139,8 +145,9 @@ pub trait EcdsaChannelSigner: ChannelSigner {
139
145
/// [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All
140
146
/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
141
147
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
142
- fn sign_holder_htlc_transaction ( & self , htlc_tx : & Transaction , input : usize ,
143
- htlc_descriptor : & HTLCDescriptor , secp_ctx : & Secp256k1 < secp256k1:: All >
148
+ fn sign_holder_htlc_transaction (
149
+ & self , htlc_tx : & Transaction , input : usize , htlc_descriptor : & HTLCDescriptor ,
150
+ secp_ctx : & Secp256k1 < secp256k1:: All > ,
144
151
) -> Result < Signature , ( ) > ;
145
152
/// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
146
153
/// transaction, either offered or received.
@@ -166,15 +173,17 @@ pub trait EcdsaChannelSigner: ChannelSigner {
166
173
/// monitor.
167
174
///
168
175
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
169
- fn sign_counterparty_htlc_transaction ( & self , htlc_tx : & Transaction , input : usize , amount : u64 ,
170
- per_commitment_point : & PublicKey , htlc : & HTLCOutputInCommitment ,
171
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
176
+ fn sign_counterparty_htlc_transaction (
177
+ & self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey ,
178
+ htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ,
179
+ ) -> Result < Signature , ( ) > ;
172
180
/// Create a signature for a (proposed) closing transaction.
173
181
///
174
182
/// Note that, due to rounding, there may be one "missing" satoshi, and either party may have
175
183
/// chosen to forgo their output as dust.
176
- fn sign_closing_transaction ( & self , closing_tx : & ClosingTransaction ,
177
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
184
+ fn sign_closing_transaction (
185
+ & self , closing_tx : & ClosingTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
186
+ ) -> Result < Signature , ( ) > ;
178
187
/// Computes the signature for a commitment transaction's anchor output used as an
179
188
/// input within `anchor_tx`, which spends the commitment transaction, at index `input`.
180
189
///
@@ -199,7 +208,7 @@ pub trait EcdsaChannelSigner: ChannelSigner {
199
208
///
200
209
/// [`NodeSigner::sign_gossip_message`]: crate::sign::NodeSigner::sign_gossip_message
201
210
fn sign_channel_announcement_with_funding_key (
202
- & self , msg : & UnsignedChannelAnnouncement , secp_ctx : & Secp256k1 < secp256k1:: All >
211
+ & self , msg : & UnsignedChannelAnnouncement , secp_ctx : & Secp256k1 < secp256k1:: All > ,
203
212
) -> Result < Signature , ( ) > ;
204
213
}
205
214
0 commit comments