@@ -219,52 +219,52 @@ pub trait ChannelKeys : Send+Clone {
219
219
/// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
220
220
/// TODO: return a Result so we can signal a validation error
221
221
fn release_commitment_secret ( & self , idx : u64 ) -> [ u8 ; 32 ] ;
222
- /// Gets the local channel public keys and basepoints
222
+ /// Gets the holder's channel public keys and basepoints
223
223
fn pubkeys ( & self ) -> & ChannelPublicKeys ;
224
224
/// Gets arbitrary identifiers describing the set of keys which are provided back to you in
225
225
/// some SpendableOutputDescriptor types. These should be sufficient to identify this
226
226
/// ChannelKeys object uniquely and lookup or re-derive its keys.
227
227
fn key_derivation_params ( & self ) -> ( u64 , u64 ) ;
228
228
229
- /// Create a signature for a remote commitment transaction and associated HTLC transactions.
229
+ /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
230
230
///
231
231
/// Note that if signing fails or is rejected, the channel will be force-closed.
232
232
//
233
233
// TODO: Document the things someone using this interface should enforce before signing.
234
234
// TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
235
235
// making the callee generate it via some util function we expose)!
236
- fn sign_remote_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , feerate_per_kw : u32 , commitment_tx : & Transaction , keys : & PreCalculatedTxCreationKeys , htlcs : & [ & HTLCOutputInCommitment ] , secp_ctx : & Secp256k1 < T > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > ;
236
+ fn sign_counterparty_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , feerate_per_kw : u32 , commitment_tx : & Transaction , keys : & PreCalculatedTxCreationKeys , htlcs : & [ & HTLCOutputInCommitment ] , secp_ctx : & Secp256k1 < T > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > ;
237
237
238
- /// Create a signature for a local commitment transaction. This will only ever be called with
239
- /// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
238
+ /// Create a signature for a holder's commitment transaction. This will only ever be called with
239
+ /// the same holder_commitment_tx (or a copy thereof), though there are currently no guarantees
240
240
/// that it will not be called multiple times.
241
241
/// An external signer implementation should check that the commitment has not been revoked.
242
242
//
243
243
// TODO: Document the things someone using this interface should enforce before signing.
244
244
// TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
245
- fn sign_local_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , local_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
245
+ fn sign_holder_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , holder_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
246
246
247
- /// Same as sign_local_commitment , but exists only for tests to get access to local commitment
247
+ /// Same as sign_holder_commitment , but exists only for tests to get access to holder commitment
248
248
/// transactions which will be broadcasted later, after the channel has moved on to a newer
249
- /// state. Thus, needs its own method as sign_local_commitment may enforce that we only ever
249
+ /// state. Thus, needs its own method as sign_holder_commitment may enforce that we only ever
250
250
/// get called once.
251
251
#[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
252
- fn unsafe_sign_local_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , local_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
252
+ fn unsafe_sign_holder_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , holder_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
253
253
254
- /// Create a signature for each HTLC transaction spending a local commitment transaction.
254
+ /// Create a signature for each HTLC transaction spending a holder's commitment transaction.
255
255
///
256
- /// Unlike sign_local_commitment , this may be called multiple times with *different*
257
- /// local_commitment_tx values. While this will never be called with a revoked
258
- /// local_commitment_tx , it is possible that it is called with the second-latest
259
- /// local_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
256
+ /// Unlike sign_holder_commitment , this may be called multiple times with *different*
257
+ /// holder_commitment_tx values. While this will never be called with a revoked
258
+ /// holder_commitment_tx , it is possible that it is called with the second-latest
259
+ /// holder_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
260
260
/// ChannelMonitor decided to broadcast before it had been updated to the latest.
261
261
///
262
262
/// Either an Err should be returned, or a Vec with one entry for each HTLC which exists in
263
- /// local_commitment_tx . For those HTLCs which have transaction_output_index set to None
263
+ /// holder_commitment_tx . For those HTLCs which have transaction_output_index set to None
264
264
/// (implying they were considered dust at the time the commitment transaction was negotiated),
265
265
/// a corresponding None should be included in the return value. All other positions in the
266
266
/// return value must contain a signature.
267
- fn sign_local_commitment_htlc_transactions < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , local_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Vec < Option < Signature > > , ( ) > ;
267
+ fn sign_holder_commitment_htlc_transactions < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , holder_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Vec < Option < Signature > > , ( ) > ;
268
268
269
269
/// Create a signature for the given input in a transaction spending an HTLC or commitment
270
270
/// transaction output when our counterparty broadcasts an old state.
@@ -277,16 +277,16 @@ pub trait ChannelKeys : Send+Clone {
277
277
/// Amount is value of the output spent by this input, committed to in the BIP 143 signature.
278
278
///
279
279
/// per_commitment_key is revocation secret which was provided by our counterparty when they
280
- /// revoked the state which they eventually broadcast. It's not a _local_ secret key and does
281
- /// not allow the spending of any funds by itself (you need our local revocation_secret to do
280
+ /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
281
+ /// not allow the spending of any funds by itself (you need our holder revocation_secret to do
282
282
/// so).
283
283
///
284
284
/// htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
285
285
/// changing the format of the witness script (which is committed to in the BIP 143
286
286
/// signatures).
287
287
fn sign_justice_transaction < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey , htlc : & Option < HTLCOutputInCommitment > , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
288
288
289
- /// Create a signature for a claiming transaction for a HTLC output on a remote commitment
289
+ /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
290
290
/// transaction, either offered or received.
291
291
///
292
292
/// Such a transaction may claim multiples offered outputs at same time if we know the
@@ -303,7 +303,7 @@ pub trait ChannelKeys : Send+Clone {
303
303
/// detected onchain. It has been generated by our counterparty and is used to derive
304
304
/// channel state keys, which are then included in the witness script and committed to in the
305
305
/// BIP 143 signature.
306
- fn sign_remote_htlc_transaction < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey , htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
306
+ fn sign_counterparty_htlc_transaction < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey , htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
307
307
308
308
/// Create a signature for a (proposed) closing transaction.
309
309
///
@@ -359,7 +359,7 @@ struct AcceptedChannelData {
359
359
/// The contest_delay value specified by our counterparty and applied on locally-broadcastable
360
360
/// transactions, ie the amount of time that we have to wait to recover our funds if we
361
361
/// broadcast a transaction. You'll likely want to pass this to the
362
- /// ln::chan_utils::build*_transaction functions when signing local transactions.
362
+ /// ln::chan_utils::build*_transaction functions when signing holder's transactions.
363
363
counterparty_selected_contest_delay : u16 ,
364
364
/// The contest_delay value specified by us and applied on transactions broadcastable
365
365
/// by our counterparty, ie the amount of time that they have to wait to recover their funds
@@ -372,18 +372,18 @@ struct AcceptedChannelData {
372
372
pub struct InMemoryChannelKeys {
373
373
/// Private key of anchor tx
374
374
pub funding_key : SecretKey ,
375
- /// Local secret key for blinded revocation pubkey
375
+ /// Holder secret key for blinded revocation pubkey
376
376
pub revocation_base_key : SecretKey ,
377
- /// Local secret key used for our balance in remote -broadcasted commitment transactions
377
+ /// Holder secret key used for our balance in counterparty -broadcasted commitment transactions
378
378
pub payment_key : SecretKey ,
379
- /// Local secret key used in HTLC tx
379
+ /// Holder secret key used in HTLC tx
380
380
pub delayed_payment_base_key : SecretKey ,
381
- /// Local htlc secret key used in commitment tx htlc outputs
381
+ /// Holder htlc secret key used in commitment tx htlc outputs
382
382
pub htlc_base_key : SecretKey ,
383
383
/// Commitment seed
384
384
pub commitment_seed : [ u8 ; 32 ] ,
385
- /// Local public keys and basepoints
386
- pub ( crate ) local_channel_pubkeys : ChannelPublicKeys ,
385
+ /// Holder public keys and basepoints
386
+ pub ( crate ) holder_channel_pubkeys : ChannelPublicKeys ,
387
387
/// Counterparty public keys and counterparty/locally selected_contest_delay, populated on channel acceptance
388
388
accepted_channel_data : Option < AcceptedChannelData > ,
389
389
/// The total value of this channel
@@ -404,8 +404,8 @@ impl InMemoryChannelKeys {
404
404
commitment_seed : [ u8 ; 32 ] ,
405
405
channel_value_satoshis : u64 ,
406
406
key_derivation_params : ( u64 , u64 ) ) -> InMemoryChannelKeys {
407
- let local_channel_pubkeys =
408
- InMemoryChannelKeys :: make_local_keys ( secp_ctx, & funding_key, & revocation_base_key,
407
+ let holder_channel_pubkeys =
408
+ InMemoryChannelKeys :: make_holder_keys ( secp_ctx, & funding_key, & revocation_base_key,
409
409
& payment_key, & delayed_payment_base_key,
410
410
& htlc_base_key) ;
411
411
InMemoryChannelKeys {
@@ -416,13 +416,13 @@ impl InMemoryChannelKeys {
416
416
htlc_base_key,
417
417
commitment_seed,
418
418
channel_value_satoshis,
419
- local_channel_pubkeys ,
419
+ holder_channel_pubkeys ,
420
420
accepted_channel_data : None ,
421
421
key_derivation_params,
422
422
}
423
423
}
424
424
425
- fn make_local_keys < C : Signing > ( secp_ctx : & Secp256k1 < C > ,
425
+ fn make_holder_keys < C : Signing > ( secp_ctx : & Secp256k1 < C > ,
426
426
funding_key : & SecretKey ,
427
427
revocation_base_key : & SecretKey ,
428
428
payment_key : & SecretKey ,
@@ -445,7 +445,7 @@ impl InMemoryChannelKeys {
445
445
/// The contest_delay value specified by our counterparty and applied on locally-broadcastable
446
446
/// transactions, ie the amount of time that we have to wait to recover our funds if we
447
447
/// broadcast a transaction. You'll likely want to pass this to the
448
- /// ln::chan_utils::build*_transaction functions when signing local transactions.
448
+ /// ln::chan_utils::build*_transaction functions when signing holder's transactions.
449
449
/// Will panic if on_accept wasn't called.
450
450
pub fn counterparty_selected_contest_delay ( & self ) -> u16 { self . accepted_channel_data . as_ref ( ) . unwrap ( ) . counterparty_selected_contest_delay }
451
451
@@ -466,10 +466,10 @@ impl ChannelKeys for InMemoryChannelKeys {
466
466
chan_utils:: build_commitment_secret ( & self . commitment_seed , idx)
467
467
}
468
468
469
- fn pubkeys ( & self ) -> & ChannelPublicKeys { & self . local_channel_pubkeys }
469
+ fn pubkeys ( & self ) -> & ChannelPublicKeys { & self . holder_channel_pubkeys }
470
470
fn key_derivation_params ( & self ) -> ( u64 , u64 ) { self . key_derivation_params }
471
471
472
- fn sign_remote_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , feerate_per_kw : u32 , commitment_tx : & Transaction , pre_keys : & PreCalculatedTxCreationKeys , htlcs : & [ & HTLCOutputInCommitment ] , secp_ctx : & Secp256k1 < T > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > {
472
+ fn sign_counterparty_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , feerate_per_kw : u32 , commitment_tx : & Transaction , pre_keys : & PreCalculatedTxCreationKeys , htlcs : & [ & HTLCOutputInCommitment ] , secp_ctx : & Secp256k1 < T > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > {
473
473
if commitment_tx. input . len ( ) != 1 { return Err ( ( ) ) ; }
474
474
let keys = pre_keys. trust_key_derivation ( ) ;
475
475
@@ -499,26 +499,26 @@ impl ChannelKeys for InMemoryChannelKeys {
499
499
Ok ( ( commitment_sig, htlc_sigs) )
500
500
}
501
501
502
- fn sign_local_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , local_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
502
+ fn sign_holder_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , holder_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
503
503
let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
504
504
let counterparty_channel_data = self . accepted_channel_data . as_ref ( ) . expect ( "must accept before signing" ) ;
505
505
let channel_funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & counterparty_channel_data. counterparty_channel_pubkeys . funding_pubkey ) ;
506
506
507
- Ok ( local_commitment_tx . get_local_sig ( & self . funding_key , & channel_funding_redeemscript, self . channel_value_satoshis , secp_ctx) )
507
+ Ok ( holder_commitment_tx . get_local_sig ( & self . funding_key , & channel_funding_redeemscript, self . channel_value_satoshis , secp_ctx) )
508
508
}
509
509
510
510
#[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
511
- fn unsafe_sign_local_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , local_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
511
+ fn unsafe_sign_holder_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , holder_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
512
512
let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
513
513
let counterparty_channel_pubkeys = & self . accepted_channel_data . as_ref ( ) . expect ( "must accept before signing" ) . counterparty_channel_pubkeys ;
514
514
let channel_funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & counterparty_channel_pubkeys. funding_pubkey ) ;
515
515
516
- Ok ( local_commitment_tx . get_local_sig ( & self . funding_key , & channel_funding_redeemscript, self . channel_value_satoshis , secp_ctx) )
516
+ Ok ( holder_commitment_tx . get_local_sig ( & self . funding_key , & channel_funding_redeemscript, self . channel_value_satoshis , secp_ctx) )
517
517
}
518
518
519
- fn sign_local_commitment_htlc_transactions < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , local_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Vec < Option < Signature > > , ( ) > {
520
- let local_csv = self . accepted_channel_data . as_ref ( ) . unwrap ( ) . counterparty_selected_contest_delay ;
521
- local_commitment_tx . get_htlc_sigs ( & self . htlc_base_key , local_csv , secp_ctx)
519
+ fn sign_holder_commitment_htlc_transactions < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , holder_commitment_tx : & LocalCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Vec < Option < Signature > > , ( ) > {
520
+ let counterparty_selected_contest_delay = self . accepted_channel_data . as_ref ( ) . unwrap ( ) . counterparty_selected_contest_delay ;
521
+ holder_commitment_tx . get_htlc_sigs ( & self . htlc_base_key , counterparty_selected_contest_delay , secp_ctx)
522
522
}
523
523
524
524
fn sign_justice_transaction < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey , htlc : & Option < HTLCOutputInCommitment > , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
@@ -536,11 +536,11 @@ impl ChannelKeys for InMemoryChannelKeys {
536
536
Ok ( counterparty_htlcpubkey) => counterparty_htlcpubkey,
537
537
Err ( _) => return Err ( ( ) )
538
538
} ;
539
- let local_htlcpubkey = match chan_utils:: derive_public_key ( & secp_ctx, & per_commitment_point, & self . pubkeys ( ) . htlc_basepoint ) {
540
- Ok ( local_htlcpubkey ) => local_htlcpubkey ,
539
+ let holder_htlcpubkey = match chan_utils:: derive_public_key ( & secp_ctx, & per_commitment_point, & self . pubkeys ( ) . htlc_basepoint ) {
540
+ Ok ( holder_htlcpubkey ) => holder_htlcpubkey ,
541
541
Err ( _) => return Err ( ( ) )
542
542
} ;
543
- chan_utils:: get_htlc_redeemscript_with_explicit_keys ( & htlc, & counterparty_htlcpubkey, & local_htlcpubkey , & revocation_pubkey)
543
+ chan_utils:: get_htlc_redeemscript_with_explicit_keys ( & htlc, & counterparty_htlcpubkey, & holder_htlcpubkey , & revocation_pubkey)
544
544
} else {
545
545
let counterparty_delayedpubkey = match chan_utils:: derive_public_key ( & secp_ctx, & per_commitment_point, & self . counterparty_pubkeys ( ) . delayed_payment_basepoint ) {
546
546
Ok ( counterparty_delayedpubkey) => counterparty_delayedpubkey,
@@ -553,7 +553,7 @@ impl ChannelKeys for InMemoryChannelKeys {
553
553
return Ok ( secp_ctx. sign ( & sighash, & revocation_key) )
554
554
}
555
555
556
- fn sign_remote_htlc_transaction < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey , htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
556
+ fn sign_counterparty_htlc_transaction < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , htlc_tx : & Transaction , input : usize , amount : u64 , per_commitment_point : & PublicKey , htlc : & HTLCOutputInCommitment , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
557
557
if let Ok ( htlc_key) = chan_utils:: derive_private_key ( & secp_ctx, & per_commitment_point, & self . htlc_base_key ) {
558
558
let witness_script = if let Ok ( revocation_pubkey) = chan_utils:: derive_public_revocation_key ( & secp_ctx, & per_commitment_point, & self . pubkeys ( ) . revocation_basepoint ) {
559
559
if let Ok ( counterparty_htlcpubkey) = chan_utils:: derive_public_key ( & secp_ctx, & per_commitment_point, & self . counterparty_pubkeys ( ) . htlc_basepoint ) {
@@ -629,8 +629,8 @@ impl Readable for InMemoryChannelKeys {
629
629
let counterparty_channel_data = Readable :: read ( reader) ?;
630
630
let channel_value_satoshis = Readable :: read ( reader) ?;
631
631
let secp_ctx = Secp256k1 :: signing_only ( ) ;
632
- let local_channel_pubkeys =
633
- InMemoryChannelKeys :: make_local_keys ( & secp_ctx, & funding_key, & revocation_base_key,
632
+ let holder_channel_pubkeys =
633
+ InMemoryChannelKeys :: make_holder_keys ( & secp_ctx, & funding_key, & revocation_base_key,
634
634
& payment_key, & delayed_payment_base_key,
635
635
& htlc_base_key) ;
636
636
let params_1 = Readable :: read ( reader) ?;
@@ -644,7 +644,7 @@ impl Readable for InMemoryChannelKeys {
644
644
htlc_base_key,
645
645
commitment_seed,
646
646
channel_value_satoshis,
647
- local_channel_pubkeys ,
647
+ holder_channel_pubkeys ,
648
648
accepted_channel_data : counterparty_channel_data,
649
649
key_derivation_params : ( params_1, params_2) ,
650
650
} )
0 commit comments