@@ -231,8 +231,6 @@ pub trait ChannelKeys : Send+Clone {
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
- // TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
235
- // making the callee generate it via some util function we expose)!
236
234
fn sign_counterparty_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , commitment_tx : & CommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > ;
237
235
238
236
/// Create a signature for a holder's commitment transaction. This will only ever be called with
@@ -241,7 +239,6 @@ pub trait ChannelKeys : Send+Clone {
241
239
/// An external signer implementation should check that the commitment has not been revoked.
242
240
//
243
241
// TODO: Document the things someone using this interface should enforce before signing.
244
- // TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
245
242
fn sign_holder_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > ;
246
243
247
244
/// Same as sign_holder_commitment, but exists only for tests to get access to holder commitment
@@ -260,10 +257,7 @@ pub trait ChannelKeys : Send+Clone {
260
257
/// ChannelMonitor decided to broadcast before it had been updated to the latest.
261
258
///
262
259
/// Either an Err should be returned, or a Vec with one entry for each HTLC which exists in
263
- /// holder_commitment_tx. For those HTLCs which have transaction_output_index set to None
264
- /// (implying they were considered dust at the time the commitment transaction was negotiated),
265
- /// a corresponding None should be included in the return value. All other positions in the
266
- /// return value must contain a signature.
260
+ /// holder_commitment_tx.
267
261
fn sign_holder_commitment_htlc_transactions < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Vec < Option < Signature > > , ( ) > ;
268
262
269
263
/// Create a signature for the given input in a transaction spending an HTLC or commitment
@@ -430,8 +424,7 @@ impl InMemoryChannelKeys {
430
424
431
425
/// The contest_delay value specified by our counterparty and applied on holder-broadcastable
432
426
/// transactions, ie the amount of time that we have to wait to recover our funds if we
433
- /// broadcast a transaction. You'll likely want to pass this to the
434
- /// ln::chan_utils::build*_transaction functions when signing holder's transactions.
427
+ /// broadcast a transaction.
435
428
/// Will panic if ready_channel wasn't called.
436
429
pub fn counterparty_selected_contest_delay ( & self ) -> u16 { self . channel_parameters . as_ref ( ) . unwrap ( ) . counterparty_parameters . as_ref ( ) . unwrap ( ) . selected_contest_delay }
437
430
@@ -463,15 +456,15 @@ impl ChannelKeys for InMemoryChannelKeys {
463
456
fn key_derivation_params ( & self ) -> ( u64 , u64 ) { self . key_derivation_params }
464
457
465
458
fn sign_counterparty_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , commitment_tx : & CommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > {
466
- let keys = commitment_tx. untrusted_key_derivation ( ) ;
459
+ let trusted_tx = commitment_tx. trust ( ) ;
460
+ let keys = trusted_tx. keys ( ) ;
467
461
468
462
let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
469
463
let channel_funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & self . counterparty_pubkeys ( ) . funding_pubkey ) ;
470
464
471
- let built_tx = commitment_tx . untrusted_built_transaction ( ) ;
465
+ let built_tx = trusted_tx . built_transaction ( ) ;
472
466
let commitment_sig = built_tx. sign ( & self . funding_key , & channel_funding_redeemscript, self . channel_value_satoshis , secp_ctx) ;
473
-
474
- let commitment_txid = commitment_tx. untrusted_txid ( ) ;
467
+ let commitment_txid = built_tx. txid ;
475
468
476
469
let mut htlc_sigs = Vec :: with_capacity ( commitment_tx. htlcs ( ) . len ( ) ) ;
477
470
for htlc in commitment_tx. htlcs ( ) {
@@ -491,28 +484,24 @@ impl ChannelKeys for InMemoryChannelKeys {
491
484
fn sign_holder_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > {
492
485
let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
493
486
let funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & self . counterparty_pubkeys ( ) . funding_pubkey ) ;
494
-
495
- let built_tx = commitment_tx. inner . untrusted_built_transaction ( ) ;
496
- let sig = built_tx. sign ( & self . funding_key , & funding_redeemscript, self . channel_value_satoshis , secp_ctx) ;
487
+ let sig = commitment_tx. trust ( ) . built_transaction ( ) . sign ( & self . funding_key , & funding_redeemscript, self . channel_value_satoshis , secp_ctx) ;
497
488
let htlc_sigs_o = self . sign_holder_commitment_htlc_transactions ( & commitment_tx, secp_ctx) ?;
498
489
let htlc_sigs = htlc_sigs_o. iter ( ) . map ( |o| o. unwrap ( ) ) . collect ( ) ;
499
490
500
491
Ok ( ( sig, htlc_sigs) )
501
492
}
502
493
503
494
#[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
504
- fn unsafe_sign_holder_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , holder_commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
495
+ fn unsafe_sign_holder_commitment < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
505
496
let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
506
497
let channel_funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & self . counterparty_pubkeys ( ) . funding_pubkey ) ;
507
-
508
- let built_tx = holder_commitment_tx. inner . untrusted_built_transaction ( ) ;
509
- Ok ( built_tx. sign ( & self . funding_key , & channel_funding_redeemscript, self . channel_value_satoshis , secp_ctx) )
498
+ Ok ( commitment_tx. trust ( ) . built_transaction ( ) . sign ( & self . funding_key , & channel_funding_redeemscript, self . channel_value_satoshis , secp_ctx) )
510
499
}
511
500
512
501
fn sign_holder_commitment_htlc_transactions < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < T > ) -> Result < Vec < Option < Signature > > , ( ) > {
513
502
let channel_parameters = self . make_channel_parameters ( ) ;
514
- let channel_parameters = channel_parameters . as_holder_broadcastable ( ) ;
515
- commitment_tx . inner . get_htlc_sigs ( & self . htlc_base_key , & channel_parameters, secp_ctx)
503
+ let trusted_tx = commitment_tx . trust ( ) ;
504
+ trusted_tx . get_htlc_sigs ( & self . htlc_base_key , & channel_parameters. as_holder_broadcastable ( ) , secp_ctx)
516
505
}
517
506
518
507
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 , ( ) > {
0 commit comments