@@ -1216,18 +1216,6 @@ impl<Signer: Sign> Channel<Signer> {
12161216 make_funding_redeemscript ( & self . get_holder_pubkeys ( ) . funding_pubkey , self . counterparty_funding_pubkey ( ) )
12171217 }
12181218
1219- /// Builds the htlc-success or htlc-timeout transaction which spends a given HTLC output
1220- /// @local is used only to convert relevant internal structures which refer to remote vs local
1221- /// to decide value of outputs and direction of HTLCs.
1222- fn build_htlc_transaction ( & self , prev_hash : & Txid , htlc : & HTLCOutputInCommitment , local : bool , keys : & TxCreationKeys , feerate_per_kw : u32 ) -> Transaction {
1223- chan_utils:: build_htlc_transaction ( prev_hash, feerate_per_kw,
1224- if local {
1225- self . get_counterparty_selected_contest_delay ( ) . unwrap ( )
1226- } else {
1227- self . get_holder_selected_contest_delay ( )
1228- } , htlc, & keys. broadcaster_delayed_payment_key , & keys. revocation_key )
1229- }
1230-
12311219 /// Per HTLC, only one get_update_fail_htlc or get_update_fulfill_htlc call may be made.
12321220 /// In such cases we debug_assert!(false) and return a ChannelError::Ignore. Thus, will always
12331221 /// return Ok(_) if debug assertions are turned on or preconditions are met.
@@ -2247,7 +2235,10 @@ impl<Signer: Sign> Channel<Signer> {
22472235 let mut htlcs_and_sigs = Vec :: with_capacity ( htlcs_cloned. len ( ) ) ;
22482236 for ( idx, ( htlc, source) ) in htlcs_cloned. drain ( ..) . enumerate ( ) {
22492237 if let Some ( _) = htlc. transaction_output_index {
2250- let htlc_tx = self . build_htlc_transaction ( & commitment_txid, & htlc, true , & keys, feerate_per_kw) ;
2238+ let htlc_tx = chan_utils:: build_htlc_transaction ( & commitment_txid, feerate_per_kw,
2239+ self . get_counterparty_selected_contest_delay ( ) . unwrap ( ) , & htlc,
2240+ & keys. broadcaster_delayed_payment_key , & keys. revocation_key ) ;
2241+
22512242 let htlc_redeemscript = chan_utils:: get_htlc_redeemscript ( & htlc, & keys) ;
22522243 let htlc_sighash = hash_to_message ! ( & bip143:: SigHashCache :: new( & htlc_tx) . signature_hash( 0 , & htlc_redeemscript, htlc. amount_msat / 1000 , SigHashType :: All ) [ ..] ) ;
22532244 log_trace ! ( logger, "Checking HTLC tx signature {} by key {} against tx {} (sighash {}) with redeemscript {} in channel {}." ,
@@ -5420,7 +5411,9 @@ mod tests {
54205411 let remote_signature = Signature :: from_der( & hex:: decode( $counterparty_htlc_sig_hex) . unwrap( ) [ ..] ) . unwrap( ) ;
54215412
54225413 let ref htlc = htlcs[ $htlc_idx] ;
5423- let htlc_tx = chan. build_htlc_transaction( & unsigned_tx. txid, & htlc, true , & keys, chan. feerate_per_kw) ;
5414+ let htlc_tx = chan_utils:: build_htlc_transaction( & unsigned_tx. txid, chan. feerate_per_kw,
5415+ chan. get_counterparty_selected_contest_delay( ) . unwrap( ) ,
5416+ & htlc, & keys. broadcaster_delayed_payment_key, & keys. revocation_key) ;
54245417 let htlc_redeemscript = chan_utils:: get_htlc_redeemscript( & htlc, & keys) ;
54255418 let htlc_sighash = Message :: from_slice( & bip143:: SigHashCache :: new( & htlc_tx) . signature_hash( 0 , & htlc_redeemscript, htlc. amount_msat / 1000 , SigHashType :: All ) [ ..] ) . unwrap( ) ;
54265419 secp_ctx. verify( & htlc_sighash, & remote_signature, & keys. countersignatory_htlc_key) . unwrap( ) ;
0 commit comments