Skip to content

Commit d76b43f

Browse files
expose feerate_sat_per_1000_weight in ChannelDetails
renames Channel::get_feerate to get_feerate_sat_per_1000_weight
1 parent 36834b3 commit d76b43f

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

fuzz/src/router.rs

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
268268
inbound_htlc_minimum_msat: None,
269269
inbound_htlc_maximum_msat: None,
270270
config: None,
271+
feerate_sat_per_1000_weight: None,
271272
});
272273
}
273274
Some(&first_hops_vec[..])

lightning/src/ln/channel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4777,7 +4777,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
47774777
})
47784778
}
47794779

4780-
pub fn get_feerate(&self) -> u32 {
4780+
pub fn get_feerate_sat_per_1000_weight(&self) -> u32 {
47814781
self.feerate_per_kw
47824782
}
47834783

lightning/src/ln/channelmanager.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,11 @@ pub struct ChannelDetails {
11181118
/// inbound. This may be zero for inbound channels serialized with LDK versions prior to
11191119
/// 0.0.113.
11201120
pub user_channel_id: u128,
1121+
/// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
1122+
/// which is applied to commitment and HTLC transactions.
1123+
///
1124+
/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
1125+
pub feerate_sat_per_1000_weight: Option<u32>,
11211126
/// Our total balance. This is the amount we would get if we close the channel.
11221127
/// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
11231128
/// amount is not likely to be recoverable on close.
@@ -1260,6 +1265,7 @@ impl ChannelDetails {
12601265
outbound_scid_alias: if channel.is_usable() { Some(channel.outbound_scid_alias()) } else { None },
12611266
inbound_scid_alias: channel.latest_inbound_scid_alias(),
12621267
channel_value_satoshis: channel.get_value_satoshis(),
1268+
feerate_sat_per_1000_weight: Some(channel.get_feerate_sat_per_1000_weight()),
12631269
unspendable_punishment_reserve: to_self_reserve_satoshis,
12641270
balance_msat: balance.balance_msat,
12651271
inbound_capacity_msat: balance.inbound_capacity_msat,
@@ -3500,18 +3506,18 @@ where
35003506
fn update_channel_fee(&self, chan_id: &[u8; 32], chan: &mut Channel<<SP::Target as SignerProvider>::Signer>, new_feerate: u32) -> NotifyOption {
35013507
if !chan.is_outbound() { return NotifyOption::SkipPersist; }
35023508
// If the feerate has decreased by less than half, don't bother
3503-
if new_feerate <= chan.get_feerate() && new_feerate * 2 > chan.get_feerate() {
3509+
if new_feerate <= chan.get_feerate_sat_per_1000_weight() && new_feerate * 2 > chan.get_feerate_sat_per_1000_weight() {
35043510
log_trace!(self.logger, "Channel {} does not qualify for a feerate change from {} to {}.",
3505-
log_bytes!(chan_id[..]), chan.get_feerate(), new_feerate);
3511+
log_bytes!(chan_id[..]), chan.get_feerate_sat_per_1000_weight(), new_feerate);
35063512
return NotifyOption::SkipPersist;
35073513
}
35083514
if !chan.is_live() {
35093515
log_trace!(self.logger, "Channel {} does not qualify for a feerate change from {} to {} as it cannot currently be updated (probably the peer is disconnected).",
3510-
log_bytes!(chan_id[..]), chan.get_feerate(), new_feerate);
3516+
log_bytes!(chan_id[..]), chan.get_feerate_sat_per_1000_weight(), new_feerate);
35113517
return NotifyOption::SkipPersist;
35123518
}
35133519
log_trace!(self.logger, "Channel {} qualifies for a feerate change from {} to {}.",
3514-
log_bytes!(chan_id[..]), chan.get_feerate(), new_feerate);
3520+
log_bytes!(chan_id[..]), chan.get_feerate_sat_per_1000_weight(), new_feerate);
35153521

35163522
chan.queue_update_fee(new_feerate, &self.logger);
35173523
NotifyOption::DoPersist
@@ -6570,6 +6576,7 @@ impl Writeable for ChannelDetails {
65706576
(33, self.inbound_htlc_minimum_msat, option),
65716577
(35, self.inbound_htlc_maximum_msat, option),
65726578
(37, user_channel_id_high_opt, option),
6579+
(39, self.feerate_sat_per_1000_weight, option),
65736580
});
65746581
Ok(())
65756582
}
@@ -6605,6 +6612,7 @@ impl Readable for ChannelDetails {
66056612
(33, inbound_htlc_minimum_msat, option),
66066613
(35, inbound_htlc_maximum_msat, option),
66076614
(37, user_channel_id_high_opt, option),
6615+
(39, feerate_sat_per_1000_weight, option),
66086616
});
66096617

66106618
// `user_channel_id` used to be a single u64 value. In order to remain backwards compatible with
@@ -6638,6 +6646,7 @@ impl Readable for ChannelDetails {
66386646
is_public: is_public.0.unwrap(),
66396647
inbound_htlc_minimum_msat,
66406648
inbound_htlc_maximum_msat,
6649+
feerate_sat_per_1000_weight,
66416650
})
66426651
}
66436652
}

lightning/src/ln/functional_test_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ macro_rules! get_feerate {
697697
let mut per_peer_state_lock;
698698
let mut peer_state_lock;
699699
let chan = get_channel_ref!($node, $counterparty_node, per_peer_state_lock, peer_state_lock, $channel_id);
700-
chan.get_feerate()
700+
chan.get_feerate_sat_per_1000_weight()
701701
}
702702
}
703703
}

lightning/src/routing/router.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,7 @@ mod tests {
22082208
inbound_htlc_minimum_msat: None,
22092209
inbound_htlc_maximum_msat: None,
22102210
config: None,
2211+
feerate_sat_per_1000_weight: None
22112212
}
22122213
}
22132214

@@ -5737,6 +5738,7 @@ mod benches {
57375738
inbound_htlc_minimum_msat: None,
57385739
inbound_htlc_maximum_msat: None,
57395740
config: None,
5741+
feerate_sat_per_1000_weight: None,
57405742
}
57415743
}
57425744

0 commit comments

Comments
 (0)