@@ -58,14 +58,14 @@ use crate::util::invoice::construct_invoice_preimage;
58
58
#[ derive( Hash , Copy , Clone , PartialEq , Eq , Debug ) ]
59
59
pub struct KeyMaterial ( pub [ u8 ; 32 ] ) ;
60
60
61
- /// Information about a spendable output to a ` P2WSH` script.
61
+ /// Information about a spendable output to a P2WSH script.
62
62
///
63
63
/// See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this.
64
64
#[ derive( Clone , Debug , PartialEq , Eq ) ]
65
65
pub struct DelayedPaymentOutputDescriptor {
66
66
/// The outpoint which is spendable.
67
67
pub outpoint : OutPoint ,
68
- /// Per commitment point to derive `delayed_payment_key` by key holder
68
+ /// Per commitment point to derive the delayed payment key by key holder.
69
69
pub per_commitment_point : PublicKey ,
70
70
/// The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in
71
71
/// the witness_script.
@@ -151,40 +151,46 @@ pub enum SpendableOutputDescriptor {
151
151
/// The output which is referenced by the given outpoint.
152
152
output : TxOut ,
153
153
} ,
154
- /// An output to a ` P2WSH` script which can be spent with a single signature after an `OP_CSV`
154
+ /// An output to a P2WSH script which can be spent with a single signature after an `OP_CSV`
155
155
/// delay.
156
156
///
157
157
/// The witness in the spending input should be:
158
158
/// ```bitcoin
159
159
/// <BIP 143 signature> <empty vector> (MINIMALIF standard rule) <provided witnessScript>
160
160
/// ```
161
161
///
162
- /// Note that the `nSequence` field in the spending input must be set to `to_self_delay` (which
163
- /// means the transaction is not broadcastable until at least `to_self_delay` blocks after the
164
- /// outpoint confirms, see [BIP
165
- /// 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)).
162
+ /// Note that the `nSequence` field in the spending input must be set to
163
+ /// [`DelayedPaymentOutputDescriptor::to_self_delay`] (which means the transaction is not
164
+ /// broadcastable until at least [`DelayedPaymentOutputDescriptor::to_self_delay`] blocks after
165
+ /// the outpoint confirms, see [BIP
166
+ /// 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)). Also note that LDK
167
+ /// won't generate a [`SpendableOutputDescriptor`] until the corresponding block height
168
+ /// is reached.
166
169
///
167
170
/// These are generally the result of a "revocable" output to us, spendable only by us unless
168
171
/// it is an output from an old state which we broadcast (which should never happen).
169
172
///
170
- /// To derive the `delayed_payment` key which is used to sign this input, you must pass the
171
- /// holder ` delayed_payment_base_key` (i.e., the private key which corresponds to the
172
- /// ` delayed_payment_basepoint` in [`BaseSign::pubkeys`]) and the provided
173
- /// ` per_commitment_point` to [`chan_utils::derive_private_key`]. The public key can be
173
+ /// To derive the delayed payment key which is used to sign this input, you must pass the
174
+ /// holder [`InMemorySigner:: delayed_payment_base_key`] (i.e., the private key which corresponds to the
175
+ /// [`ChannelPublicKeys:: delayed_payment_basepoint`] in [`BaseSign::pubkeys`]) and the provided
176
+ /// [`DelayedPaymentOutputDescriptor:: per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be
174
177
/// generated without the secret key using [`chan_utils::derive_public_key`] and only the
175
- /// ` delayed_payment_basepoint` which appears in [`BaseSign::pubkeys`].
178
+ /// [`ChannelPublicKeys:: delayed_payment_basepoint`] which appears in [`BaseSign::pubkeys`].
176
179
///
177
- /// To derive the `revocation_pubkey` provided here (which is used in the witness script
178
- /// generation), you must pass the counterparty `revocation_basepoint` (which appears in the
179
- /// call to [`BaseSign::provide_channel_parameters`]) and the provided per_commitment point to
180
+ /// To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is
181
+ /// used in the witness script generation), you must pass the counterparty
182
+ /// [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to
183
+ /// [`BaseSign::provide_channel_parameters`]) and the provided
184
+ /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to
180
185
/// [`chan_utils::derive_public_revocation_key`].
181
186
///
182
187
/// The witness script which is hashed and included in the output `script_pubkey` may be
183
- /// regenerated by passing the `revocation_pubkey` (derived as above), our `delayed_payment`
184
- /// pubkey (derived as above), and the `to_self_delay` contained here to
188
+ /// regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived
189
+ /// as explained above), our delayed payment pubkey (derived as explained above), and the
190
+ /// [`DelayedPaymentOutputDescriptor::to_self_delay`] contained here to
185
191
/// [`chan_utils::get_revokeable_redeemscript`].
186
192
DelayedPaymentOutput ( DelayedPaymentOutputDescriptor ) ,
187
- /// An output to a ` P2WPKH` , spendable exclusively by our payment key (i.e., the private key
193
+ /// An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key
188
194
/// which corresponds to the `payment_point` in [`BaseSign::pubkeys`]). The witness
189
195
/// in the spending input is, thus, simply:
190
196
/// ```bitcoin
@@ -209,24 +215,10 @@ impl_writeable_tlv_based_enum!(SpendableOutputDescriptor,
209
215
/// A trait to sign Lightning channel transactions as described in
210
216
/// [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md).
211
217
///
212
- /// Signing services could be implemented on a hardware wallet. In this case,
213
- /// the current [`BaseSign`] would be a front-end on top of a communication
214
- /// channel connected to your secure device and lightning key material wouldn't
215
- /// reside on a hot server. Nevertheless, a this deployment would still need
216
- /// to trust the ChannelManager to avoid loss of funds as this latest component
217
- /// could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
218
- ///
219
- /// A more secure iteration would be to use hashlock (or payment points) to pair
220
- /// invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-[`ChannelManager`]
221
- /// at the price of more state and computation on the hardware wallet side. In the future,
222
- /// we are looking forward to design such interface.
223
- ///
224
- /// In any case, [`ChannelMonitor`] or fallback watchtowers are always going to be trusted
225
- /// to act, as liveness and breach reply correctness are always going to be hard requirements
226
- /// of LN security model, orthogonal of key management issues.
227
- ///
228
- /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
229
- /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
218
+ /// Signing services could be implemented on a hardware wallet and should implement signing
219
+ /// policies in order to be secure. Please refer to the [VLS Policy
220
+ /// Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
221
+ /// for an example of such policies.
230
222
pub trait BaseSign {
231
223
/// Gets the per-commitment point for a specific commitment number
232
224
///
@@ -287,12 +279,15 @@ pub trait BaseSign {
287
279
/// forward and it is safe to sign the next counterparty commitment.
288
280
fn validate_counterparty_revocation ( & self , idx : u64 , secret : & SecretKey ) -> Result < ( ) , ( ) > ;
289
281
/// Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
290
- /// This will only ever be called with a non-revoked `commitment_tx`. This will be called with the
291
- /// latest `commitment_tx` when we initiate a force-close.
292
- /// This will be called with the previous latest `commitment_tx`, just to get claiming HTLC
293
- /// signatures, if we are reacting to a [`ChannelMonitor`]
294
- /// [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
295
- /// that decided to broadcast before it had been updated to the latest `commitment_tx`.
282
+ ///
283
+ /// This will be called
284
+ /// - with a non-revoked `commitment_tx`.
285
+ /// - with the latest `commitment_tx` when we initiate a force-close.
286
+ /// - with the previous `commitment_tx`, just to get claiming HTLC
287
+ /// signatures, if we are reacting to a [`ChannelMonitor`]
288
+ /// [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
289
+ /// that decided to broadcast before it had been updated to the latest `commitment_tx`.
290
+ ///
296
291
/// This may be called multiple times for the same transaction.
297
292
///
298
293
/// An external signer implementation should check that the commitment has not been revoked.
@@ -305,10 +300,10 @@ pub trait BaseSign {
305
300
// TODO: Key derivation failure should panic rather than Err
306
301
fn sign_holder_commitment_and_htlcs ( & self , commitment_tx : & HolderCommitmentTransaction ,
307
302
secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > ;
308
- /// Same as `sign_holder_commitment` , but exists only for tests to get access to holder commitment
309
- /// transactions which will be broadcasted later, after the channel has moved on to a newer
310
- /// state. Thus, needs its own method as `sign_holder_commitment` may enforce that we only ever
311
- /// get called once.
303
+ /// Same as [`sign_holder_commitment_and_htlcs`] , but exists only for tests to get access to
304
+ /// holder commitment transactions which will be broadcasted later, after the channel has moved
305
+ /// on to a newer state. Thus, needs its own method as [`sign_holder_commitment_and_htlcs`] may
306
+ /// enforce that we only ever get called once.
312
307
#[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
313
308
fn unsafe_sign_holder_commitment_and_htlcs ( & self , commitment_tx : & HolderCommitmentTransaction ,
314
309
secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > ;
@@ -437,7 +432,7 @@ pub enum Recipient {
437
432
438
433
/// A trait to describe an object which can get user secrets and key material.
439
434
pub trait KeysInterface {
440
- /// A type which implements Sign which will be returned by [`Self::derive_channel_signer`].
435
+ /// A type which implements [` Sign`] which will be returned by [`Self::derive_channel_signer`].
441
436
type Signer : Sign ;
442
437
/// Get node secret key based on the provided [`Recipient`].
443
438
///
0 commit comments