@@ -487,31 +487,26 @@ pub trait EcdsaChannelSigner: ChannelSigner {
487
487
/// This is required in order for the signer to make sure that the state has moved
488
488
/// forward and it is safe to sign the next counterparty commitment.
489
489
fn validate_counterparty_revocation ( & self , idx : u64 , secret : & SecretKey ) -> Result < ( ) , ( ) > ;
490
- /// Creates a signature for a holder's commitment transaction and its claiming HTLC transactions .
490
+ /// Creates a signature for a holder's commitment transaction.
491
491
///
492
492
/// This will be called
493
493
/// - with a non-revoked `commitment_tx`.
494
494
/// - with the latest `commitment_tx` when we initiate a force-close.
495
- /// - with the previous `commitment_tx`, just to get claiming HTLC
496
- /// signatures, if we are reacting to a [`ChannelMonitor`]
497
- /// [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
498
- /// that decided to broadcast before it had been updated to the latest `commitment_tx`.
499
495
///
500
496
/// This may be called multiple times for the same transaction.
501
497
///
502
498
/// An external signer implementation should check that the commitment has not been revoked.
503
- ///
504
- /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
499
+ //
505
500
// TODO: Document the things someone using this interface should enforce before signing.
506
- fn sign_holder_commitment_and_htlcs ( & self , commitment_tx : & HolderCommitmentTransaction ,
507
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > ;
508
- /// Same as [`sign_holder_commitment_and_htlcs `], but exists only for tests to get access to
509
- /// holder commitment transactions which will be broadcasted later, after the channel has moved
510
- /// on to a newer state. Thus, needs its own method as [`sign_holder_commitment_and_htlcs `] may
511
- /// enforce that we only ever get called once.
501
+ fn sign_holder_commitment ( & self , commitment_tx : & HolderCommitmentTransaction ,
502
+ secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
503
+ /// Same as [`sign_holder_commitment `], but exists only for tests to get access to holder
504
+ /// commitment transactions which will be broadcasted later, after the channel has moved on to a
505
+ /// newer state. Thus, needs its own method as [`sign_holder_commitment `] may enforce that we
506
+ /// only ever get called once.
512
507
#[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
513
- fn unsafe_sign_holder_commitment_and_htlcs ( & self , commitment_tx : & HolderCommitmentTransaction ,
514
- secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > ;
508
+ fn unsafe_sign_holder_commitment ( & self , commitment_tx : & HolderCommitmentTransaction ,
509
+ secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
515
510
/// Create a signature for the given input in a transaction spending an HTLC transaction output
516
511
/// or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
517
512
///
@@ -554,7 +549,12 @@ pub trait EcdsaChannelSigner: ChannelSigner {
554
549
/// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
555
550
/// must be be computed using [`EcdsaSighashType::All`].
556
551
///
552
+ /// Note that this may be called for HTLCs in the penultimate commitment transaction if a
553
+ /// [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
554
+ /// broadcasts it before receiving the update for the latest commitment transaction.
555
+ ///
557
556
/// [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All
557
+ /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
558
558
fn sign_holder_htlc_transaction ( & self , htlc_tx : & Transaction , input : usize ,
559
559
htlc_descriptor : & HTLCDescriptor , secp_ctx : & Secp256k1 < secp256k1:: All >
560
560
) -> Result < Signature , ( ) > ;
@@ -1118,27 +1118,21 @@ impl EcdsaChannelSigner for InMemorySigner {
1118
1118
Ok ( ( ) )
1119
1119
}
1120
1120
1121
- fn sign_holder_commitment_and_htlcs ( & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > {
1121
+ fn sign_holder_commitment ( & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > {
1122
1122
let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
1123
1123
let counterparty_keys = self . counterparty_pubkeys ( ) . expect ( MISSING_PARAMS_ERR ) ;
1124
1124
let funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & counterparty_keys. funding_pubkey ) ;
1125
1125
let trusted_tx = commitment_tx. trust ( ) ;
1126
- let sig = trusted_tx. built_transaction ( ) . sign_holder_commitment ( & self . funding_key , & funding_redeemscript, self . channel_value_satoshis , & self , secp_ctx) ;
1127
- let channel_parameters = self . get_channel_parameters ( ) . expect ( MISSING_PARAMS_ERR ) ;
1128
- let htlc_sigs = trusted_tx. get_htlc_sigs ( & self . htlc_base_key , & channel_parameters. as_holder_broadcastable ( ) , & self , secp_ctx) ?;
1129
- Ok ( ( sig, htlc_sigs) )
1126
+ Ok ( trusted_tx. built_transaction ( ) . sign_holder_commitment ( & self . funding_key , & funding_redeemscript, self . channel_value_satoshis , & self , secp_ctx) )
1130
1127
}
1131
1128
1132
1129
#[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
1133
- fn unsafe_sign_holder_commitment_and_htlcs ( & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < ( Signature , Vec < Signature > ) , ( ) > {
1130
+ fn unsafe_sign_holder_commitment ( & self , commitment_tx : & HolderCommitmentTransaction , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > {
1134
1131
let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
1135
1132
let counterparty_keys = self . counterparty_pubkeys ( ) . expect ( MISSING_PARAMS_ERR ) ;
1136
1133
let funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & counterparty_keys. funding_pubkey ) ;
1137
1134
let trusted_tx = commitment_tx. trust ( ) ;
1138
- let sig = trusted_tx. built_transaction ( ) . sign_holder_commitment ( & self . funding_key , & funding_redeemscript, self . channel_value_satoshis , & self , secp_ctx) ;
1139
- let channel_parameters = self . get_channel_parameters ( ) . expect ( MISSING_PARAMS_ERR ) ;
1140
- let htlc_sigs = trusted_tx. get_htlc_sigs ( & self . htlc_base_key , & channel_parameters. as_holder_broadcastable ( ) , & self , secp_ctx) ?;
1141
- Ok ( ( sig, htlc_sigs) )
1135
+ Ok ( trusted_tx. built_transaction ( ) . sign_holder_commitment ( & self . funding_key , & funding_redeemscript, self . channel_value_satoshis , & self , secp_ctx) )
1142
1136
}
1143
1137
1144
1138
fn sign_justice_revoked_output ( & self , justice_tx : & Transaction , input : usize , amount : u64 , per_commitment_key : & SecretKey , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > {
0 commit comments