@@ -24,11 +24,18 @@ use crate::sign::{ChannelSigner, HTLCDescriptor};
24
24
/// policies in order to be secure. Please refer to the [VLS Policy
25
25
/// Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
26
26
/// for an example of such policies.
27
+ ///
28
+ /// Like [`ChannelSigner`], many of the methods allow errors to be returned to support async
29
+ /// signing. In such cases, the signing operation can be replayed by calling
30
+ /// [`ChannelManager::signer_unblocked`] or [`ChainMonitor::signer_unblocked`] (see individual
31
+ /// method documentation for which method should be called) once the result is ready, at which
32
+ /// point the channel operation will resume.
33
+ ///
34
+ /// [`ChannelManager::signer_unblocked`]: crate::ln::channelmanager::ChannelManager::signer_unblocked
35
+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
27
36
pub trait EcdsaChannelSigner : ChannelSigner {
28
37
/// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
29
38
///
30
- /// Note that if signing fails or is rejected, the channel will be force-closed.
31
- ///
32
39
/// Policy checks should be implemented in this function, including checking the amount
33
40
/// sent to us and checking the HTLCs.
34
41
///
@@ -39,8 +46,12 @@ pub trait EcdsaChannelSigner: ChannelSigner {
39
46
///
40
47
/// Note that all the relevant preimages will be provided, but there may also be additional
41
48
/// irrelevant or duplicate preimages.
42
- //
43
- // TODO: Document the things someone using this interface should enforce before signing.
49
+ ///
50
+ /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
51
+ /// signature and should be retried later. Once the signer is ready to provide a signature after
52
+ /// previously returning an `Err`, [`ChannelManager::signer_unblocked`] must be called.
53
+ ///
54
+ /// [`ChannelManager::signer_unblocked`]: crate::ln::channelmanager::ChannelManager::signer_unblocked
44
55
fn sign_counterparty_commitment (
45
56
& self , commitment_tx : & CommitmentTransaction , inbound_htlc_preimages : Vec < PaymentPreimage > ,
46
57
outbound_htlc_preimages : Vec < PaymentPreimage > , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -58,18 +69,19 @@ pub trait EcdsaChannelSigner: ChannelSigner {
58
69
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
59
70
/// signature and should be retried later. Once the signer is ready to provide a signature after
60
71
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
61
- /// monitor.
72
+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
62
73
///
63
74
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
64
- //
65
- // TODO: Document the things someone using this interface should enforce before signing.
75
+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
66
76
fn sign_holder_commitment (
67
77
& self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
68
78
) -> Result < Signature , ( ) > ;
69
79
/// Same as [`sign_holder_commitment`], but exists only for tests to get access to holder
70
80
/// commitment transactions which will be broadcasted later, after the channel has moved on to a
71
81
/// newer state. Thus, needs its own method as [`sign_holder_commitment`] may enforce that we
72
82
/// only ever get called once.
83
+ ///
84
+ /// This method is *not* async as it is intended only for testing purposes.
73
85
#[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
74
86
fn unsafe_sign_holder_commitment (
75
87
& self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -92,9 +104,10 @@ pub trait EcdsaChannelSigner: ChannelSigner {
92
104
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
93
105
/// signature and should be retried later. Once the signer is ready to provide a signature after
94
106
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
95
- /// monitor.
107
+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
96
108
///
97
109
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
110
+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
98
111
fn sign_justice_revoked_output (
99
112
& self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey ,
100
113
secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -121,9 +134,10 @@ pub trait EcdsaChannelSigner: ChannelSigner {
121
134
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
122
135
/// signature and should be retried later. Once the signer is ready to provide a signature after
123
136
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
124
- /// monitor.
137
+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
125
138
///
126
139
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
140
+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
127
141
fn sign_justice_revoked_htlc (
128
142
& self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey ,
129
143
htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -139,11 +153,12 @@ pub trait EcdsaChannelSigner: ChannelSigner {
139
153
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
140
154
/// signature and should be retried later. Once the signer is ready to provide a signature after
141
155
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
142
- /// monitor.
156
+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
143
157
///
144
158
/// [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All
145
159
/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
146
160
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
161
+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
147
162
fn sign_holder_htlc_transaction (
148
163
& self , htlc_tx : & Transaction , input : usize , htlc_descriptor : & HTLCDescriptor ,
149
164
secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -169,9 +184,10 @@ pub trait EcdsaChannelSigner: ChannelSigner {
169
184
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
170
185
/// signature and should be retried later. Once the signer is ready to provide a signature after
171
186
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
172
- /// monitor.
187
+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
173
188
///
174
189
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
190
+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
175
191
fn sign_counterparty_htlc_transaction (
176
192
& self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey ,
177
193
htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -180,6 +196,12 @@ pub trait EcdsaChannelSigner: ChannelSigner {
180
196
///
181
197
/// Note that, due to rounding, there may be one "missing" satoshi, and either party may have
182
198
/// chosen to forgo their output as dust.
199
+ ///
200
+ /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
201
+ /// signature and should be retried later. Once the signer is ready to provide a signature after
202
+ /// previously returning an `Err`, [`ChannelManager::signer_unblocked`] must be called.
203
+ ///
204
+ /// [`ChannelManager::signer_unblocked`]: crate::ln::channelmanager::ChannelManager::signer_unblocked
183
205
fn sign_closing_transaction (
184
206
& self , closing_tx : & ClosingTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
185
207
) -> Result < Signature , ( ) > ;
@@ -189,9 +211,10 @@ pub trait EcdsaChannelSigner: ChannelSigner {
189
211
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
190
212
/// signature and should be retried later. Once the signer is ready to provide a signature after
191
213
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
192
- /// monitor.
214
+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
193
215
///
194
216
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
217
+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
195
218
fn sign_holder_anchor_input (
196
219
& self , anchor_tx : & Transaction , input : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
197
220
) -> Result < Signature , ( ) > ;
@@ -201,9 +224,9 @@ pub trait EcdsaChannelSigner: ChannelSigner {
201
224
/// Channel announcements also require a signature from each node's network key. Our node
202
225
/// signature is computed through [`NodeSigner::sign_gossip_message`].
203
226
///
204
- /// Note that if this fails or is rejected , the channel will not be publicly announced and
205
- /// our counterparty may (though likely will not) close the channel on us for violating the
206
- /// protocol.
227
+ /// This method is *not* asynchronous. If an `Err` is returned , the channel will not be
228
+ /// publicly announced and our counterparty may (though likely will not) close the channel on
229
+ /// us for violating the protocol.
207
230
///
208
231
/// [`NodeSigner::sign_gossip_message`]: crate::sign::NodeSigner::sign_gossip_message
209
232
fn sign_channel_announcement_with_funding_key (
@@ -219,6 +242,9 @@ pub trait EcdsaChannelSigner: ChannelSigner {
219
242
/// spending the previous funding transaction's output
220
243
///
221
244
/// `input_value`: The value of the previous funding transaction output.
245
+ ///
246
+ /// This method is *not* asynchronous. If an `Err` is returned, the channel will be immediately
247
+ /// closed.
222
248
fn sign_splicing_funding_input (
223
249
& self , tx : & Transaction , input_index : usize , input_value : u64 ,
224
250
secp_ctx : & Secp256k1 < secp256k1:: All > ,
0 commit comments