@@ -601,6 +601,10 @@ pub(super) struct Channel<Signer: ChannelSigner> {
601
601
next_holder_htlc_id : u64 ,
602
602
next_counterparty_htlc_id : u64 ,
603
603
feerate_per_kw : u32 ,
604
+ /// We keep an updated high priority feerate in order to calculate the max dust
605
+ /// exposure limit if [`ChannelConfig::max_dust_htlc_exposure_multiplier_thousandths`]
606
+ /// is set.
607
+ high_priority_feerate_per_kw : Option < u32 > ,
604
608
605
609
/// The timestamp set on our latest `channel_update` message for this channel. It is updated
606
610
/// when the channel is updated in ways which may impact the `channel_update` message or when a
@@ -1018,6 +1022,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1018
1022
debug_assert ! ( channel_type. is_subset( & channelmanager:: provided_channel_type_features( & config) ) ) ;
1019
1023
1020
1024
let feerate = fee_estimator. bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
1025
+ let high_priority_feerate = fee_estimator. bounded_sat_per_1000_weight ( ConfirmationTarget :: HighPriority ) ;
1021
1026
1022
1027
let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
1023
1028
let commitment_tx_fee = Self :: commit_tx_fee_msat ( feerate, MIN_AFFORDABLE_HTLC_COUNT , channel_type. requires_anchors_zero_fee_htlc_tx ( ) ) ;
@@ -1114,6 +1119,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1114
1119
channel_creation_height : current_chain_height,
1115
1120
1116
1121
feerate_per_kw : feerate,
1122
+ high_priority_feerate_per_kw : Some ( high_priority_feerate) ,
1117
1123
counterparty_dust_limit_satoshis : 0 ,
1118
1124
holder_dust_limit_satoshis : MIN_CHAN_DUST_LIMIT_SATOSHIS ,
1119
1125
counterparty_max_htlc_value_in_flight_msat : 0 ,
@@ -1470,6 +1476,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1470
1476
channel_creation_height : current_chain_height,
1471
1477
1472
1478
feerate_per_kw : msg. feerate_per_kw ,
1479
+ high_priority_feerate_per_kw : Some ( fee_estimator. bounded_sat_per_1000_weight ( ConfirmationTarget :: HighPriority ) ) ,
1473
1480
channel_value_satoshis : msg. funding_satoshis ,
1474
1481
counterparty_dust_limit_satoshis : msg. dust_limit_satoshis ,
1475
1482
holder_dust_limit_satoshis : MIN_CHAN_DUST_LIMIT_SATOSHIS ,
@@ -4962,6 +4969,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4962
4969
self . config . options . max_dust_htlc_exposure_msat
4963
4970
}
4964
4971
4972
+ /// Sets the channel's high priority feerate per kw.
4973
+ pub fn update_high_priority_feerate ( & mut self , high_priority_feerate_per_kw : u32 ) {
4974
+ self . high_priority_feerate_per_kw = Some ( high_priority_feerate_per_kw) ;
4975
+ }
4976
+
4965
4977
/// Returns the previous [`ChannelConfig`] applied to this channel, if any.
4966
4978
pub fn prev_config ( & self ) -> Option < ChannelConfig > {
4967
4979
self . prev_config . map ( |prev_config| prev_config. 0 )
@@ -7046,6 +7058,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7046
7058
let mut holder_max_accepted_htlcs: Option < u16 > = None ;
7047
7059
7048
7060
let mut pending_monitor_updates = Some ( Vec :: new ( ) ) ;
7061
+ let mut high_priority_feerate_per_kw = None ;
7049
7062
7050
7063
read_tlv_fields ! ( reader, {
7051
7064
( 0 , announcement_sigs, option) ,
@@ -7070,6 +7083,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7070
7083
( 29 , temporary_channel_id, option) ,
7071
7084
( 31 , channel_pending_event_emitted, option) ,
7072
7085
( 33 , pending_monitor_updates, vec_type) ,
7086
+ ( 35 , high_priority_feerate_per_kw, option) ,
7073
7087
} ) ;
7074
7088
7075
7089
let ( channel_keys_id, holder_signer) = if let Some ( channel_keys_id) = channel_keys_id {
@@ -7172,6 +7186,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7172
7186
next_counterparty_htlc_id,
7173
7187
update_time_counter,
7174
7188
feerate_per_kw,
7189
+ high_priority_feerate_per_kw,
7175
7190
7176
7191
#[ cfg( debug_assertions) ]
7177
7192
holder_max_commitment_tx_output : Mutex :: new ( ( 0 , 0 ) ) ,
0 commit comments