@@ -142,28 +142,6 @@ impl Readable for SpendableOutputDescriptor {
142
142
}
143
143
}
144
144
145
- /// A trait to describe an object which can get user secrets and key material.
146
- pub trait KeysInterface : Send + Sync {
147
- /// A type which implements ChannelKeys which will be returned by get_channel_keys.
148
- type ChanKeySigner : ChannelKeys ;
149
-
150
- /// Get node secret key (aka node_id or network_key)
151
- fn get_node_secret ( & self ) -> SecretKey ;
152
- /// Get destination redeemScript to encumber static protocol exit points.
153
- fn get_destination_script ( & self ) -> Script ;
154
- /// Get shutdown_pubkey to use as PublicKey at channel closure
155
- fn get_shutdown_pubkey ( & self ) -> PublicKey ;
156
- /// Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
157
- /// restarted with some stale data!
158
- fn get_channel_keys ( & self , inbound : bool , channel_value_satoshis : u64 ) -> Self :: ChanKeySigner ;
159
- /// Get a secret and PRNG seed for construting an onion packet
160
- fn get_onion_rand ( & self ) -> ( SecretKey , [ u8 ; 32 ] ) ;
161
- /// Get a unique temporary channel id. Channels will be referred to by this until the funding
162
- /// transaction is created, at which point they will use the outpoint in the funding
163
- /// transaction.
164
- fn get_channel_id ( & self ) -> [ u8 ; 32 ] ;
165
- }
166
-
167
145
/// Set of lightning keys needed to operate a channel as described in BOLT 3.
168
146
///
169
147
/// Signing services could be implemented on a hardware wallet. In this case,
@@ -192,26 +170,34 @@ pub trait KeysInterface: Send + Sync {
192
170
// TODO: We should remove Clone by instead requesting a new ChannelKeys copy when we create
193
171
// ChannelMonitors instead of expecting to clone the one out of the Channel into the monitors.
194
172
pub trait ChannelKeys : Send +Clone {
173
+ /// (C-not exported) due to references
195
174
/// Gets the private key for the anchor tx
196
175
fn funding_key < ' a > ( & ' a self ) -> & ' a SecretKey ;
197
176
/// Gets the local secret key for blinded revocation pubkey
177
+ /// (C-not exported) due to references
198
178
fn revocation_base_key < ' a > ( & ' a self ) -> & ' a SecretKey ;
199
179
/// Gets the local secret key used in the to_remote output of remote commitment tx (ie the
200
180
/// output to us in transactions our counterparty broadcasts).
201
181
/// Also as part of obscured commitment number.
182
+ /// (C-not exported) due to references
202
183
fn payment_key < ' a > ( & ' a self ) -> & ' a SecretKey ;
203
184
/// Gets the local secret key used in HTLC-Success/HTLC-Timeout txn and to_local output
185
+ /// (C-not exported) due to references
204
186
fn delayed_payment_base_key < ' a > ( & ' a self ) -> & ' a SecretKey ;
205
187
/// Gets the local htlc secret key used in commitment tx htlc outputs
188
+ /// (C-not exported) due to references
206
189
fn htlc_base_key < ' a > ( & ' a self ) -> & ' a SecretKey ;
207
190
/// Gets the commitment seed
191
+ /// (C-not exported) due to references
208
192
fn commitment_seed < ' a > ( & ' a self ) -> & ' a [ u8 ; 32 ] ;
209
193
/// Gets the local channel public keys and basepoints
194
+ /// (C-not exported) due to references
210
195
fn pubkeys < ' a > ( & ' a self ) -> & ' a ChannelPublicKeys ;
211
196
212
197
/// Create a signature for a remote commitment transaction and associated HTLC transactions.
213
198
///
214
199
/// Note that if signing fails or is rejected, the channel will be force-closed.
200
+ /// (C-not exported) due to references
215
201
//
216
202
// TODO: Document the things someone using this interface should enforce before signing.
217
203
// TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
@@ -221,6 +207,7 @@ pub trait ChannelKeys : Send+Clone {
221
207
/// Create a signature for a local commitment transaction. This will only ever be called with
222
208
/// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
223
209
/// that it will not be called multiple times.
210
+ /// (C-not exported) due to references
224
211
//
225
212
// TODO: Document the things someone using this interface should enforce before signing.
226
213
// TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
@@ -246,12 +233,14 @@ pub trait ChannelKeys : Send+Clone {
246
233
/// (implying they were considered dust at the time the commitment transaction was negotiated),
247
234
/// a corresponding None should be included in the return value. All other positions in the
248
235
/// return value must contain a signature.
236
+ /// (C-not exported) due to references
249
237
fn sign_local_commitment_htlc_transactions < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , local_commitment_tx : & LocalCommitmentTransaction , local_csv : u16 , secp_ctx : & Secp256k1 < T > ) -> Result < Vec < Option < Signature > > , ( ) > ;
250
238
251
239
/// Create a signature for a (proposed) closing transaction.
252
240
///
253
241
/// Note that, due to rounding, there may be one "missing" satoshi, and either party may have
254
242
/// chosen to forgo their output as dust.
243
+ /// (C-not exported) due to references
255
244
fn sign_closing_transaction < T : secp256k1:: Signing > ( & self , closing_tx : & Transaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
256
245
257
246
/// Signs a channel announcement message with our funding key, proving it comes from one
@@ -260,15 +249,42 @@ pub trait ChannelKeys : Send+Clone {
260
249
/// Note that if this fails or is rejected, the channel will not be publicly announced and
261
250
/// our counterparty may (though likely will not) close the channel on us for violating the
262
251
/// protocol.
252
+ /// (C-not exported) due to references
263
253
fn sign_channel_announcement < T : secp256k1:: Signing > ( & self , msg : & msgs:: UnsignedChannelAnnouncement , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
264
254
265
255
/// Set the remote channel basepoints. This is done immediately on incoming channels
266
256
/// and as soon as the channel is accepted on outgoing channels.
267
257
///
268
258
/// Will be called before any signatures are applied.
259
+ /// (C-not exported) due to references
269
260
fn set_remote_channel_pubkeys ( & mut self , channel_points : & ChannelPublicKeys ) ;
270
261
}
271
262
263
+
264
+ /// A trait to describe an object which can get user secrets and key material.
265
+ pub trait KeysInterface : Send + Sync {
266
+ /// A type which implements ChannelKeys which will be returned by get_channel_keys.
267
+ type ChanKeySigner : ChannelKeys ;
268
+
269
+ /// Get node secret key (aka node_id or network_key)
270
+ fn get_node_secret ( & self ) -> SecretKey ;
271
+ /// Get destination redeemScript to encumber static protocol exit points.
272
+ fn get_destination_script ( & self ) -> Script ;
273
+ /// Get shutdown_pubkey to use as PublicKey at channel closure
274
+ fn get_shutdown_pubkey ( & self ) -> PublicKey ;
275
+ /// Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
276
+ /// restarted with some stale data!
277
+ /// (C-not exported) due to Self (though it *should* work...)
278
+ fn get_channel_keys ( & self , inbound : bool , channel_value_satoshis : u64 ) -> Self :: ChanKeySigner ;
279
+ /// Get a secret and PRNG seed for construting an onion packet
280
+ /// (C-not exported) due to tuple
281
+ fn get_onion_rand ( & self ) -> ( SecretKey , [ u8 ; 32 ] ) ;
282
+ /// Get a unique temporary channel id. Channels will be referred to by this until the funding
283
+ /// transaction is created, at which point they will use the outpoint in the funding
284
+ /// transaction.
285
+ fn get_channel_id ( & self ) -> [ u8 ; 32 ] ;
286
+ }
287
+
272
288
#[ derive( Clone ) ]
273
289
/// A simple implementation of ChannelKeys that just keeps the private keys in memory.
274
290
pub struct InMemoryChannelKeys {
@@ -294,6 +310,7 @@ pub struct InMemoryChannelKeys {
294
310
295
311
impl InMemoryChannelKeys {
296
312
/// Create a new InMemoryChannelKeys
313
+ /// (C-not exported) due to secp context
297
314
pub fn new < C : Signing > (
298
315
secp_ctx : & Secp256k1 < C > ,
299
316
funding_key : SecretKey ,
@@ -509,7 +526,7 @@ impl KeysManager {
509
526
/// Note that until the 0.1 release there is no guarantee of backward compatibility between
510
527
/// versions. Once the library is more fully supported, the docs will be updated to include a
511
528
/// detailed description of the guarantee.
512
- pub fn new ( seed : & [ u8 ; 32 ] , network : Network , logger : Arc < Logger > , starting_time_secs : u64 , starting_time_nanos : u32 ) -> KeysManager {
529
+ pub fn new ( seed : & [ u8 ; 32 ] , network : Network , logger : Arc < Logger > , starting_time_secs : u64 , starting_time_nanos : u32 ) -> Self {
513
530
let secp_ctx = Secp256k1 :: signing_only ( ) ;
514
531
match ExtendedPrivKey :: new_master ( network. clone ( ) , seed) {
515
532
Ok ( master_key) => {
0 commit comments