From: Elias Rohrer Date: Tue, 20 Aug 2024 11:47:51 +0000 (+0200) Subject: Rename `ChannelDetails::is_public` to `is_announced` X-Git-Tag: v0.0.124-rc1~2^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=b3abb192ccf737bef6811907f55f9c1a9e37cbf4;p=rust-lightning Rename `ChannelDetails::is_public` to `is_announced` 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`. --- diff --git a/fuzz/src/router.rs b/fuzz/src/router.rs index cc28f5ae9..41e816257 100644 --- a/fuzz/src/router.rs +++ b/fuzz/src/router.rs @@ -241,7 +241,7 @@ pub fn do_test(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), diff --git a/lightning/src/ln/channel_state.rs b/lightning/src/ln/channel_state.rs index f0a5c37e8..97e6b0af1 100644 --- a/lightning/src/ln/channel_state.rs +++ b/lightning/src/ln/channel_state.rs @@ -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, @@ -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()), diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 05e0a9cfd..decbb3326 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -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); diff --git a/lightning/src/ln/invoice_utils.rs b/lightning/src/ln/invoice_utils.rs index 5a793052c..f23e9fe1f 100644 --- a/lightning/src/ln/invoice_utils.rs +++ b/lightning/src/ln/invoice_utils.rs @@ -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); } diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index fa2bbac1d..ed141c0ad 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1373,7 +1373,7 @@ impl<'a> CandidateRouteHop<'a> { #[inline] pub fn globally_unique_short_channel_id(&self) -> Option { 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,