@@ -487,31 +487,26 @@ pub trait EcdsaChannelSigner: ChannelSigner {
487487 /// This is required in order for the signer to make sure that the state has moved
488488 /// forward and it is safe to sign the next counterparty commitment.
489489 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.
491491 ///
492492 /// This will be called
493493 /// - with a non-revoked `commitment_tx`.
494494 /// - 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`.
499495 ///
500496 /// This may be called multiple times for the same transaction.
501497 ///
502498 /// An external signer implementation should check that the commitment has not been revoked.
503- ///
504- /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
499+ //
505500 // 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.
512507 #[ 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 , ( ) > ;
515510 /// Create a signature for the given input in a transaction spending an HTLC transaction output
516511 /// or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
517512 ///
@@ -554,7 +549,12 @@ pub trait EcdsaChannelSigner: ChannelSigner {
554549 /// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
555550 /// must be be computed using [`EcdsaSighashType::All`].
556551 ///
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+ ///
557556 /// [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All
557+ /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
558558 fn sign_holder_htlc_transaction ( & self , htlc_tx : & Transaction , input : usize ,
559559 htlc_descriptor : & HTLCDescriptor , secp_ctx : & Secp256k1 < secp256k1:: All >
560560 ) -> Result < Signature , ( ) > ;
@@ -1118,27 +1118,21 @@ impl EcdsaChannelSigner for InMemorySigner {
11181118 Ok ( ( ) )
11191119 }
11201120
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 , ( ) > {
11221122 let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
11231123 let counterparty_keys = self . counterparty_pubkeys ( ) . expect ( MISSING_PARAMS_ERR ) ;
11241124 let funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & counterparty_keys. funding_pubkey ) ;
11251125 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) )
11301127 }
11311128
11321129 #[ 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 , ( ) > {
11341131 let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
11351132 let counterparty_keys = self . counterparty_pubkeys ( ) . expect ( MISSING_PARAMS_ERR ) ;
11361133 let funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & counterparty_keys. funding_pubkey ) ;
11371134 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) )
11421136 }
11431137
11441138 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