]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Rename `ChannelDetails::is_public` to `is_announced`
authorElias Rohrer <dev@tnull.de>
Tue, 20 Aug 2024 11:47:51 +0000 (13:47 +0200)
committerElias Rohrer <dev@tnull.de>
Wed, 21 Aug 2024 10:40:21 +0000 (12:40 +0200)
Referring to announced/unannounced channels as 'public'/'private'
regularly leads to confusion on what they are and when which should be
used. To avoid perpetuating this confusion, we should avoid referring to
announced channels as 'public' in our API.

Here we rename `ChannelDetails::is_public` (which breaks
previously-released API) to align it with the changes in
`OpenChannelRequest`.

fuzz/src/router.rs
lightning/src/ln/channel_state.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/invoice_utils.rs
lightning/src/routing/router.rs

index cc28f5ae9f63c15fd5a74e95380fe78a4e33e1b3..41e8162575aef7ff22e89d542f748ebf4cd3a8f1 100644 (file)
@@ -241,7 +241,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
                                                        is_outbound: true,
                                                        is_channel_ready: true,
                                                        is_usable: true,
-                                                       is_public: true,
+                                                       is_announced: true,
                                                        balance_msat: 0,
                                                        outbound_capacity_msat: capacity.saturating_mul(1000),
                                                        next_outbound_htlc_limit_msat: capacity.saturating_mul(1000),
index f0a5c37e86f637c0d10a6824f85db6a4fb5e1ea9..97e6b0af10cd5c96a3bf27171669d800fcbee6d7 100644 (file)
@@ -448,7 +448,7 @@ pub struct ChannelDetails {
        /// This is a strict superset of `is_channel_ready`.
        pub is_usable: bool,
        /// True if this channel is (or will be) publicly-announced.
-       pub is_public: bool,
+       pub is_announced: bool,
        /// The smallest value HTLC (in msat) we will accept, for this channel. This field
        /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
        pub inbound_htlc_minimum_msat: Option<u64>,
@@ -552,7 +552,7 @@ impl ChannelDetails {
                        is_outbound: context.is_outbound(),
                        is_channel_ready: context.is_usable(),
                        is_usable: context.is_live(),
-                       is_public: context.should_announce(),
+                       is_announced: context.should_announce(),
                        inbound_htlc_minimum_msat: Some(context.get_holder_htlc_minimum_msat()),
                        inbound_htlc_maximum_msat: context.get_holder_htlc_maximum_msat(),
                        config: Some(context.config()),
@@ -594,7 +594,7 @@ impl Writeable for ChannelDetails {
                                (26, self.is_outbound, required),
                                (28, self.is_channel_ready, required),
                                (30, self.is_usable, required),
-                               (32, self.is_public, required),
+                               (32, self.is_announced, required),
                                (33, self.inbound_htlc_minimum_msat, option),
                                (35, self.inbound_htlc_maximum_msat, option),
                                (37, user_channel_id_high_opt, option),
@@ -635,7 +635,7 @@ impl Readable for ChannelDetails {
                        (26, is_outbound, required),
                        (28, is_channel_ready, required),
                        (30, is_usable, required),
-                       (32, is_public, required),
+                       (32, is_announced, required),
                        (33, inbound_htlc_minimum_msat, option),
                        (35, inbound_htlc_maximum_msat, option),
                        (37, user_channel_id_high_opt, option),
@@ -675,7 +675,7 @@ impl Readable for ChannelDetails {
                        is_outbound: is_outbound.0.unwrap(),
                        is_channel_ready: is_channel_ready.0.unwrap(),
                        is_usable: is_usable.0.unwrap(),
-                       is_public: is_public.0.unwrap(),
+                       is_announced: is_announced.0.unwrap(),
                        inbound_htlc_minimum_msat,
                        inbound_htlc_maximum_msat,
                        feerate_sat_per_1000_weight,
@@ -774,7 +774,7 @@ mod tests {
                        is_outbound: true,
                        is_channel_ready: false,
                        is_usable: true,
-                       is_public: false,
+                       is_announced: false,
                        inbound_htlc_minimum_msat: Some(98),
                        inbound_htlc_maximum_msat: Some(983274),
                        config: Some(ChannelConfig::default()),
index 05e0a9cfd5b8cf649623002e97237cb73f277492..decbb332663f2b5b1b7e9c97d03118d788d73b45 100644 (file)
@@ -1492,7 +1492,7 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &
                if chan.channel_id == as_channel_ready.channel_id {
                        assert!(!found_a);
                        found_a = true;
-                       assert!(!chan.is_public);
+                       assert!(!chan.is_announced);
                }
        }
        assert!(found_a);
@@ -1502,7 +1502,7 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &
                if chan.channel_id == as_channel_ready.channel_id {
                        assert!(!found_b);
                        found_b = true;
-                       assert!(!chan.is_public);
+                       assert!(!chan.is_announced);
                }
        }
        assert!(found_b);
index 5a793052cc3958f18288331785c70a43778ffdd3..f23e9fe1fc61ef105ac893fa630df0fa2706c03b 100644 (file)
@@ -632,7 +632,7 @@ where
                        continue;
                }
 
-               if channel.is_public {
+               if channel.is_announced {
                        if channel.confirmations.is_some() && channel.confirmations < Some(7) {
                                // If we have a public channel, but it doesn't have enough confirmations to (yet)
                                // be in the public network graph (and have gotten a chance to propagate), include
@@ -668,7 +668,7 @@ where
                                let current_max_capacity = entry.get().inbound_capacity_msat;
                                // If this channel is public and the previous channel is not, ensure we replace the
                                // previous channel to avoid announcing non-public channels.
-                               let new_now_public = channel.is_public && !entry.get().is_public;
+                               let new_now_public = channel.is_announced && !entry.get().is_announced;
                                // Decide whether we prefer the currently selected channel with the node to the new one,
                                // based on their inbound capacity.
                                let prefer_current = prefer_current_channel(min_inbound_capacity_msat, current_max_capacity,
@@ -676,7 +676,7 @@ where
                                // If the public-ness of the channel has not changed (in which case simply defer to
                                // `new_now_public), and this channel has more desirable inbound than the incumbent,
                                // prefer to include this channel.
-                               let new_channel_preferable = channel.is_public == entry.get().is_public && !prefer_current;
+                               let new_channel_preferable = channel.is_announced == entry.get().is_announced && !prefer_current;
 
                                if new_now_public || new_channel_preferable {
                                        log_trace!(logger,
@@ -717,7 +717,7 @@ where
                                // If we have a public channel, but it doesn't have enough confirmations to (yet)
                                // be in the public network graph (and have gotten a chance to propagate), include
                                // route hints but only for public channels to protect private channel privacy.
-                               channel.is_public
+                               channel.is_announced
                        } else if online_min_capacity_channel_exists {
                                has_enough_capacity && channel.is_usable
                        } else if min_capacity_channel_exists && online_channel_exists {
@@ -738,7 +738,7 @@ where
                                log_trace!(logger, "Ignoring channel {} without enough capacity for invoice route hints",
                                        &channel.channel_id);
                        } else {
-                               debug_assert!(!channel.is_usable || (has_pub_unconf_chan && !channel.is_public));
+                               debug_assert!(!channel.is_usable || (has_pub_unconf_chan && !channel.is_announced));
                                log_trace!(logger, "Ignoring channel {} with disconnected peer",
                                        &channel.channel_id);
                        }
index fa2bbac1d14fac17e92405c9d491629c02da6ecb..ed141c0ada332f3409549ac0433757bf822f05ac 100644 (file)
@@ -1373,7 +1373,7 @@ impl<'a> CandidateRouteHop<'a> {
        #[inline]
        pub fn globally_unique_short_channel_id(&self) -> Option<u64> {
                match self {
-                       CandidateRouteHop::FirstHop(hop) => if hop.details.is_public { hop.details.short_channel_id } else { None },
+                       CandidateRouteHop::FirstHop(hop) => if hop.details.is_announced { hop.details.short_channel_id } else { None },
                        CandidateRouteHop::PublicHop(hop) => Some(hop.short_channel_id),
                        CandidateRouteHop::PrivateHop(_) => None,
                        CandidateRouteHop::Blinded(_) => None,
@@ -3327,7 +3327,7 @@ where L::Target: Logger {
                                true
                        } else if let CandidateRouteHop::FirstHop(first_hop) = &hop.candidate {
                                // If this is a first hop we also know if it's announced.
-                               first_hop.details.is_public
+                               first_hop.details.is_announced
                        } else {
                                // If we sourced it any other way, we double-check the network graph to see if
                                // there are announced channels between the endpoints. If so, the hop might be
@@ -3619,7 +3619,7 @@ mod tests {
                        confirmations: None,
                        force_close_spend_delay: None,
                        is_outbound: true, is_channel_ready: true,
-                       is_usable: true, is_public: true,
+                       is_usable: true, is_announced: true,
                        inbound_htlc_minimum_msat: None,
                        inbound_htlc_maximum_msat: None,
                        config: None,
@@ -8809,7 +8809,7 @@ pub(crate) mod bench_utils {
                        is_outbound: true,
                        is_channel_ready: true,
                        is_usable: true,
-                       is_public: true,
+                       is_announced: true,
                        inbound_htlc_minimum_msat: None,
                        inbound_htlc_maximum_msat: None,
                        config: None,