@@ -23,7 +23,6 @@ use crate::ln::chan_utils::{
23
23
ANCHOR_INPUT_WITNESS_WEIGHT , HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT ,
24
24
HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT , ChannelTransactionParameters , HTLCOutputInCommitment
25
25
} ;
26
- use crate :: ln:: features:: ChannelTypeFeatures ;
27
26
use crate :: ln:: PaymentPreimage ;
28
27
use crate :: prelude:: * ;
29
28
use crate :: sign:: { EcdsaChannelSigner , SignerProvider , WriteableEcdsaChannelSigner , P2WPKH_WITNESS_WEIGHT } ;
@@ -136,6 +135,10 @@ pub struct HTLCDescriptor {
136
135
///
137
136
/// See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
138
137
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 same as the
140
+ /// commitment transaction's feerate.
141
+ pub feerate_per_kw : u32 ,
139
142
/// The details of the HTLC as it appears in the commitment transaction.
140
143
pub htlc : HTLCOutputInCommitment ,
141
144
/// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
@@ -146,13 +149,14 @@ pub struct HTLCDescriptor {
146
149
}
147
150
148
151
impl_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) ,
156
160
} ) ;
157
161
158
162
impl HTLCDescriptor {
@@ -177,7 +181,9 @@ impl HTLCDescriptor {
177
181
/// Returns the unsigned transaction input spending the HTLC output in the commitment
178
182
/// transaction.
179
183
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
+ )
181
187
}
182
188
183
189
/// Returns the delayed output created as a result of spending the HTLC output in the commitment
@@ -193,8 +199,8 @@ impl HTLCDescriptor {
193
199
secp, & self . per_commitment_point , & counterparty_keys. revocation_basepoint
194
200
) ;
195
201
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
198
204
)
199
205
}
200
206
@@ -213,7 +219,7 @@ impl HTLCDescriptor {
213
219
secp, & self . per_commitment_point , & counterparty_keys. revocation_basepoint
214
220
) ;
215
221
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,
217
223
& counterparty_revocation_key,
218
224
)
219
225
}
@@ -222,7 +228,8 @@ impl HTLCDescriptor {
222
228
/// transaction.
223
229
pub fn tx_input_witness ( & self , signature : & Signature , witness_script : & Script ) -> Witness {
224
230
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
226
233
)
227
234
}
228
235
0 commit comments