]> git.bitcoin.ninja Git - rust-lightning/commitdiff
expose `feerate_sat_per_1000_weight` in `ChannelDetails`
authorJohn Cantrell <johncantrell97@gmail.com>
Thu, 9 Mar 2023 22:00:49 +0000 (17:00 -0500)
committerJohn Cantrell <johncantrell@tbd.email>
Wed, 15 Mar 2023 17:36:14 +0000 (13:36 -0400)
renames Channel::get_feerate to get_feerate_sat_per_1000_weight

fuzz/src/router.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/routing/router.rs

index ad0da138a85508d5bf38ff8902ab56d93796e066..568dcdf0250057c68e1cf946b4b543f97c8933c0 100644 (file)
@@ -268,6 +268,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
                                                                inbound_htlc_minimum_msat: None,
                                                                inbound_htlc_maximum_msat: None,
                                                                config: None,
+                                                               feerate_sat_per_1000_weight: None,
                                                        });
                                                }
                                                Some(&first_hops_vec[..])
index 9af0f6379e5a1672e851a61ef0c54d717235a1a5..17f7b1776ea6a4b993cb7b2f1a001495bb4173cd 100644 (file)
@@ -4777,7 +4777,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
                        })
        }
 
-       pub fn get_feerate(&self) -> u32 {
+       pub fn get_feerate_sat_per_1000_weight(&self) -> u32 {
                self.feerate_per_kw
        }
 
index 6e0cd1709809d5d15c03f3cc036904c1003c956c..1b26e1032bc150e953a0d6c4bfa6773448dcdce5 100644 (file)
@@ -1118,6 +1118,11 @@ pub struct ChannelDetails {
        /// inbound. This may be zero for inbound channels serialized with LDK versions prior to
        /// 0.0.113.
        pub user_channel_id: u128,
+       /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
+       /// which is applied to commitment and HTLC transactions.
+       ///
+       /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
+       pub feerate_sat_per_1000_weight: Option<u32>,
        /// Our total balance.  This is the amount we would get if we close the channel.
        /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
        /// amount is not likely to be recoverable on close.
@@ -1260,6 +1265,7 @@ impl ChannelDetails {
                        outbound_scid_alias: if channel.is_usable() { Some(channel.outbound_scid_alias()) } else { None },
                        inbound_scid_alias: channel.latest_inbound_scid_alias(),
                        channel_value_satoshis: channel.get_value_satoshis(),
+                       feerate_sat_per_1000_weight: Some(channel.get_feerate_sat_per_1000_weight()),
                        unspendable_punishment_reserve: to_self_reserve_satoshis,
                        balance_msat: balance.balance_msat,
                        inbound_capacity_msat: balance.inbound_capacity_msat,
@@ -3500,18 +3506,18 @@ where
        fn update_channel_fee(&self, chan_id: &[u8; 32], chan: &mut Channel<<SP::Target as SignerProvider>::Signer>, new_feerate: u32) -> NotifyOption {
                if !chan.is_outbound() { return NotifyOption::SkipPersist; }
                // If the feerate has decreased by less than half, don't bother
-               if new_feerate <= chan.get_feerate() && new_feerate * 2 > chan.get_feerate() {
+               if new_feerate <= chan.get_feerate_sat_per_1000_weight() && new_feerate * 2 > chan.get_feerate_sat_per_1000_weight() {
                        log_trace!(self.logger, "Channel {} does not qualify for a feerate change from {} to {}.",
-                               log_bytes!(chan_id[..]), chan.get_feerate(), new_feerate);
+                               log_bytes!(chan_id[..]), chan.get_feerate_sat_per_1000_weight(), new_feerate);
                        return NotifyOption::SkipPersist;
                }
                if !chan.is_live() {
                        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).",
-                               log_bytes!(chan_id[..]), chan.get_feerate(), new_feerate);
+                               log_bytes!(chan_id[..]), chan.get_feerate_sat_per_1000_weight(), new_feerate);
                        return NotifyOption::SkipPersist;
                }
                log_trace!(self.logger, "Channel {} qualifies for a feerate change from {} to {}.",
-                       log_bytes!(chan_id[..]), chan.get_feerate(), new_feerate);
+                       log_bytes!(chan_id[..]), chan.get_feerate_sat_per_1000_weight(), new_feerate);
 
                chan.queue_update_fee(new_feerate, &self.logger);
                NotifyOption::DoPersist
@@ -6570,6 +6576,7 @@ impl Writeable for ChannelDetails {
                        (33, self.inbound_htlc_minimum_msat, option),
                        (35, self.inbound_htlc_maximum_msat, option),
                        (37, user_channel_id_high_opt, option),
+                       (39, self.feerate_sat_per_1000_weight, option),
                });
                Ok(())
        }
@@ -6605,6 +6612,7 @@ impl Readable for ChannelDetails {
                        (33, inbound_htlc_minimum_msat, option),
                        (35, inbound_htlc_maximum_msat, option),
                        (37, user_channel_id_high_opt, option),
+                       (39, feerate_sat_per_1000_weight, option),
                });
 
                // `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 {
                        is_public: is_public.0.unwrap(),
                        inbound_htlc_minimum_msat,
                        inbound_htlc_maximum_msat,
+                       feerate_sat_per_1000_weight,
                })
        }
 }
index 1e99a475fe9f1501dd5042c8b4d344e55a7aa5f8..16ffa4bd120e18a0205ed1ed9a68a332483e8327 100644 (file)
@@ -697,7 +697,7 @@ macro_rules! get_feerate {
                        let mut per_peer_state_lock;
                        let mut peer_state_lock;
                        let chan = get_channel_ref!($node, $counterparty_node, per_peer_state_lock, peer_state_lock, $channel_id);
-                       chan.get_feerate()
+                       chan.get_feerate_sat_per_1000_weight()
                }
        }
 }
index 9682503ee45c22d5062a099f5c1af015bbe3ffc0..baa2ecce1b7f3dae5037d61b84b67cbcc0723a20 100644 (file)
@@ -2208,6 +2208,7 @@ mod tests {
                        inbound_htlc_minimum_msat: None,
                        inbound_htlc_maximum_msat: None,
                        config: None,
+                       feerate_sat_per_1000_weight: None
                }
        }
 
@@ -5737,6 +5738,7 @@ mod benches {
                        inbound_htlc_minimum_msat: None,
                        inbound_htlc_maximum_msat: None,
                        config: None,
+                       feerate_sat_per_1000_weight: None,
                }
        }