@@ -23,7 +23,6 @@ use crate::ln::chan_utils::{
2323 ANCHOR_INPUT_WITNESS_WEIGHT , HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT ,
2424 HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT , ChannelTransactionParameters , HTLCOutputInCommitment
2525} ;
26- use crate :: ln:: features:: ChannelTypeFeatures ;
2726use crate :: ln:: PaymentPreimage ;
2827use crate :: prelude:: * ;
2928use crate :: sign:: { EcdsaChannelSigner , SignerProvider , WriteableEcdsaChannelSigner , P2WPKH_WITNESS_WEIGHT } ;
@@ -136,6 +135,10 @@ pub struct HTLCDescriptor {
136135 ///
137136 /// See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
138137 pub per_commitment_point : PublicKey ,
138+ /// The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs
139+ /// originating from a channel supporting anchor outputs, otherwise it is the channel's
140+ /// negotiated feerate at the time the commitment transaction was built.
141+ pub feerate_per_kw : u32 ,
139142 /// The details of the HTLC as it appears in the commitment transaction.
140143 pub htlc : HTLCOutputInCommitment ,
141144 /// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
@@ -146,13 +149,14 @@ pub struct HTLCDescriptor {
146149}
147150
148151impl_writeable_tlv_based ! ( HTLCDescriptor , {
149- ( 0 , channel_derivation_parameters, required) ,
150- ( 2 , commitment_txid, required) ,
151- ( 4 , per_commitment_number, required) ,
152- ( 6 , per_commitment_point, required) ,
153- ( 8 , htlc, required) ,
154- ( 10 , preimage, option) ,
155- ( 12 , counterparty_sig, required) ,
152+ ( 0 , channel_derivation_parameters, required) ,
153+ ( 1 , feerate_per_kw, ( default_value, 0 ) ) ,
154+ ( 2 , commitment_txid, required) ,
155+ ( 4 , per_commitment_number, required) ,
156+ ( 6 , per_commitment_point, required) ,
157+ ( 8 , htlc, required) ,
158+ ( 10 , preimage, option) ,
159+ ( 12 , counterparty_sig, required) ,
156160} ) ;
157161
158162impl HTLCDescriptor {
@@ -177,7 +181,9 @@ impl HTLCDescriptor {
177181 /// Returns the unsigned transaction input spending the HTLC output in the commitment
178182 /// transaction.
179183 pub fn unsigned_tx_input ( & self ) -> TxIn {
180- chan_utils:: build_htlc_input ( & self . commitment_txid , & self . htlc , & ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) )
184+ chan_utils:: build_htlc_input (
185+ & self . commitment_txid , & self . htlc , & self . channel_derivation_parameters . transaction_parameters . channel_type_features
186+ )
181187 }
182188
183189 /// Returns the delayed output created as a result of spending the HTLC output in the commitment
@@ -193,8 +199,8 @@ impl HTLCDescriptor {
193199 secp, & self . per_commitment_point , & counterparty_keys. revocation_basepoint
194200 ) ;
195201 chan_utils:: build_htlc_output (
196- 0 /* feerate_per_kw */ , channel_params. contest_delay ( ) , & self . htlc ,
197- & ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) , & broadcaster_delayed_key, & counterparty_revocation_key
202+ self . feerate_per_kw , channel_params. contest_delay ( ) , & self . htlc ,
203+ channel_params . channel_type_features ( ) , & broadcaster_delayed_key, & counterparty_revocation_key
198204 )
199205 }
200206
@@ -213,7 +219,7 @@ impl HTLCDescriptor {
213219 secp, & self . per_commitment_point , & counterparty_keys. revocation_basepoint
214220 ) ;
215221 chan_utils:: get_htlc_redeemscript_with_explicit_keys (
216- & self . htlc , & ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) , & broadcaster_htlc_key, & counterparty_htlc_key,
222+ & self . htlc , channel_params . channel_type_features ( ) , & broadcaster_htlc_key, & counterparty_htlc_key,
217223 & counterparty_revocation_key,
218224 )
219225 }
@@ -222,7 +228,8 @@ impl HTLCDescriptor {
222228 /// transaction.
223229 pub fn tx_input_witness ( & self , signature : & Signature , witness_script : & Script ) -> Witness {
224230 chan_utils:: build_htlc_input_witness (
225- signature, & self . counterparty_sig , & self . preimage , witness_script, & ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) /* opt_anchors */
231+ signature, & self . counterparty_sig , & self . preimage , witness_script,
232+ & self . channel_derivation_parameters . transaction_parameters . channel_type_features
226233 )
227234 }
228235
0 commit comments