@@ -24,6 +24,15 @@ use crate::sign::{ChannelSigner, HTLCDescriptor};
2424/// policies in order to be secure. Please refer to the [VLS Policy
2525/// Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
2626/// 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
2736pub trait EcdsaChannelSigner : ChannelSigner {
2837 /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
2938 ///
@@ -39,8 +48,12 @@ pub trait EcdsaChannelSigner: ChannelSigner {
3948 ///
4049 /// Note that all the relevant preimages will be provided, but there may also be additional
4150 /// irrelevant or duplicate preimages.
42- //
43- // TODO: Document the things someone using this interface should enforce before signing.
51+ ///
52+ /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
53+ /// signature and should be retried later. Once the signer is ready to provide a signature after
54+ /// previously returning an `Err`, [`ChannelManager::signer_unblocked`] must be called.
55+ ///
56+ /// [`ChannelManager::signer_unblocked`]: crate::ln::channelmanager::ChannelManager::signer_unblocked
4457 fn sign_counterparty_commitment (
4558 & self , commitment_tx : & CommitmentTransaction , inbound_htlc_preimages : Vec < PaymentPreimage > ,
4659 outbound_htlc_preimages : Vec < PaymentPreimage > , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -58,18 +71,19 @@ pub trait EcdsaChannelSigner: ChannelSigner {
5871 /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
5972 /// signature and should be retried later. Once the signer is ready to provide a signature after
6073 /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
61- /// monitor.
74+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
6275 ///
6376 /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
64- //
65- // TODO: Document the things someone using this interface should enforce before signing.
77+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
6678 fn sign_holder_commitment (
6779 & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
6880 ) -> Result < Signature , ( ) > ;
6981 /// Same as [`sign_holder_commitment`], but exists only for tests to get access to holder
7082 /// commitment transactions which will be broadcasted later, after the channel has moved on to a
7183 /// newer state. Thus, needs its own method as [`sign_holder_commitment`] may enforce that we
7284 /// only ever get called once.
85+ ///
86+ /// This method is *not* async as it is intended only for testing purposes.
7387 #[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
7488 fn unsafe_sign_holder_commitment (
7589 & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -92,9 +106,10 @@ pub trait EcdsaChannelSigner: ChannelSigner {
92106 /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
93107 /// signature and should be retried later. Once the signer is ready to provide a signature after
94108 /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
95- /// monitor.
109+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
96110 ///
97111 /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
112+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
98113 fn sign_justice_revoked_output (
99114 & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey ,
100115 secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -121,9 +136,10 @@ pub trait EcdsaChannelSigner: ChannelSigner {
121136 /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
122137 /// signature and should be retried later. Once the signer is ready to provide a signature after
123138 /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
124- /// monitor.
139+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
125140 ///
126141 /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
142+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
127143 fn sign_justice_revoked_htlc (
128144 & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey ,
129145 htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -139,11 +155,12 @@ pub trait EcdsaChannelSigner: ChannelSigner {
139155 /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
140156 /// signature and should be retried later. Once the signer is ready to provide a signature after
141157 /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
142- /// monitor.
158+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
143159 ///
144160 /// [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All
145161 /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
146162 /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
163+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
147164 fn sign_holder_htlc_transaction (
148165 & self , htlc_tx : & Transaction , input : usize , htlc_descriptor : & HTLCDescriptor ,
149166 secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -169,9 +186,10 @@ pub trait EcdsaChannelSigner: ChannelSigner {
169186 /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
170187 /// signature and should be retried later. Once the signer is ready to provide a signature after
171188 /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
172- /// monitor.
189+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
173190 ///
174191 /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
192+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
175193 fn sign_counterparty_htlc_transaction (
176194 & self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey ,
177195 htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -180,6 +198,12 @@ pub trait EcdsaChannelSigner: ChannelSigner {
180198 ///
181199 /// Note that, due to rounding, there may be one "missing" satoshi, and either party may have
182200 /// chosen to forgo their output as dust.
201+ ///
202+ /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
203+ /// signature and should be retried later. Once the signer is ready to provide a signature after
204+ /// previously returning an `Err`, [`ChannelManager::signer_unblocked`] must be called.
205+ ///
206+ /// [`ChannelManager::signer_unblocked`]: crate::ln::channelmanager::ChannelManager::signer_unblocked
183207 fn sign_closing_transaction (
184208 & self , closing_tx : & ClosingTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ,
185209 ) -> Result < Signature , ( ) > ;
@@ -189,9 +213,10 @@ pub trait EcdsaChannelSigner: ChannelSigner {
189213 /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
190214 /// signature and should be retried later. Once the signer is ready to provide a signature after
191215 /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
192- /// monitor.
216+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors .
193217 ///
194218 /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
219+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
195220 fn sign_holder_anchor_input (
196221 & self , anchor_tx : & Transaction , input : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
197222 ) -> Result < Signature , ( ) > ;
@@ -201,9 +226,9 @@ pub trait EcdsaChannelSigner: ChannelSigner {
201226 /// Channel announcements also require a signature from each node's network key. Our node
202227 /// signature is computed through [`NodeSigner::sign_gossip_message`].
203228 ///
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.
229+ /// This method is *not* asynchronous, if this fails or is rejected, the channel will not be
230+ /// publicly announced and our counterparty may (though likely will not) close the channel on
231+ /// us for violating the protocol.
207232 ///
208233 /// [`NodeSigner::sign_gossip_message`]: crate::sign::NodeSigner::sign_gossip_message
209234 fn sign_channel_announcement_with_funding_key (
@@ -219,6 +244,9 @@ pub trait EcdsaChannelSigner: ChannelSigner {
219244 /// spending the previous funding transaction's output
220245 ///
221246 /// `input_value`: The value of the previous funding transaction output.
247+ ///
248+ /// THis method is *not* asynchronous. If an `Err` is returned, the channel will be immediately
249+ /// closed.
222250 fn sign_splicing_funding_input (
223251 & self , tx : & Transaction , input_index : usize , input_value : u64 ,
224252 secp_ctx : & Secp256k1 < secp256k1:: All > ,
0 commit comments