Skip to content

Commit b3abb19

Browse files
committed
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`.
1 parent b9c73b1 commit b3abb19

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

fuzz/src/router.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
241241
is_outbound: true,
242242
is_channel_ready: true,
243243
is_usable: true,
244-
is_public: true,
244+
is_announced: true,
245245
balance_msat: 0,
246246
outbound_capacity_msat: capacity.saturating_mul(1000),
247247
next_outbound_htlc_limit_msat: capacity.saturating_mul(1000),

lightning/src/ln/channel_state.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ pub struct ChannelDetails {
448448
/// This is a strict superset of `is_channel_ready`.
449449
pub is_usable: bool,
450450
/// True if this channel is (or will be) publicly-announced.
451-
pub is_public: bool,
451+
pub is_announced: bool,
452452
/// The smallest value HTLC (in msat) we will accept, for this channel. This field
453453
/// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
454454
pub inbound_htlc_minimum_msat: Option<u64>,
@@ -552,7 +552,7 @@ impl ChannelDetails {
552552
is_outbound: context.is_outbound(),
553553
is_channel_ready: context.is_usable(),
554554
is_usable: context.is_live(),
555-
is_public: context.should_announce(),
555+
is_announced: context.should_announce(),
556556
inbound_htlc_minimum_msat: Some(context.get_holder_htlc_minimum_msat()),
557557
inbound_htlc_maximum_msat: context.get_holder_htlc_maximum_msat(),
558558
config: Some(context.config()),
@@ -594,7 +594,7 @@ impl Writeable for ChannelDetails {
594594
(26, self.is_outbound, required),
595595
(28, self.is_channel_ready, required),
596596
(30, self.is_usable, required),
597-
(32, self.is_public, required),
597+
(32, self.is_announced, required),
598598
(33, self.inbound_htlc_minimum_msat, option),
599599
(35, self.inbound_htlc_maximum_msat, option),
600600
(37, user_channel_id_high_opt, option),
@@ -635,7 +635,7 @@ impl Readable for ChannelDetails {
635635
(26, is_outbound, required),
636636
(28, is_channel_ready, required),
637637
(30, is_usable, required),
638-
(32, is_public, required),
638+
(32, is_announced, required),
639639
(33, inbound_htlc_minimum_msat, option),
640640
(35, inbound_htlc_maximum_msat, option),
641641
(37, user_channel_id_high_opt, option),
@@ -675,7 +675,7 @@ impl Readable for ChannelDetails {
675675
is_outbound: is_outbound.0.unwrap(),
676676
is_channel_ready: is_channel_ready.0.unwrap(),
677677
is_usable: is_usable.0.unwrap(),
678-
is_public: is_public.0.unwrap(),
678+
is_announced: is_announced.0.unwrap(),
679679
inbound_htlc_minimum_msat,
680680
inbound_htlc_maximum_msat,
681681
feerate_sat_per_1000_weight,
@@ -774,7 +774,7 @@ mod tests {
774774
is_outbound: true,
775775
is_channel_ready: false,
776776
is_usable: true,
777-
is_public: false,
777+
is_announced: false,
778778
inbound_htlc_minimum_msat: Some(98),
779779
inbound_htlc_maximum_msat: Some(983274),
780780
config: Some(ChannelConfig::default()),

lightning/src/ln/functional_test_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &
14921492
if chan.channel_id == as_channel_ready.channel_id {
14931493
assert!(!found_a);
14941494
found_a = true;
1495-
assert!(!chan.is_public);
1495+
assert!(!chan.is_announced);
14961496
}
14971497
}
14981498
assert!(found_a);
@@ -1502,7 +1502,7 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &
15021502
if chan.channel_id == as_channel_ready.channel_id {
15031503
assert!(!found_b);
15041504
found_b = true;
1505-
assert!(!chan.is_public);
1505+
assert!(!chan.is_announced);
15061506
}
15071507
}
15081508
assert!(found_b);

lightning/src/ln/invoice_utils.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ where
632632
continue;
633633
}
634634

635-
if channel.is_public {
635+
if channel.is_announced {
636636
if channel.confirmations.is_some() && channel.confirmations < Some(7) {
637637
// If we have a public channel, but it doesn't have enough confirmations to (yet)
638638
// be in the public network graph (and have gotten a chance to propagate), include
@@ -668,15 +668,15 @@ where
668668
let current_max_capacity = entry.get().inbound_capacity_msat;
669669
// If this channel is public and the previous channel is not, ensure we replace the
670670
// previous channel to avoid announcing non-public channels.
671-
let new_now_public = channel.is_public && !entry.get().is_public;
671+
let new_now_public = channel.is_announced && !entry.get().is_announced;
672672
// Decide whether we prefer the currently selected channel with the node to the new one,
673673
// based on their inbound capacity.
674674
let prefer_current = prefer_current_channel(min_inbound_capacity_msat, current_max_capacity,
675675
channel.inbound_capacity_msat);
676676
// If the public-ness of the channel has not changed (in which case simply defer to
677677
// `new_now_public), and this channel has more desirable inbound than the incumbent,
678678
// prefer to include this channel.
679-
let new_channel_preferable = channel.is_public == entry.get().is_public && !prefer_current;
679+
let new_channel_preferable = channel.is_announced == entry.get().is_announced && !prefer_current;
680680

681681
if new_now_public || new_channel_preferable {
682682
log_trace!(logger,
@@ -717,7 +717,7 @@ where
717717
// If we have a public channel, but it doesn't have enough confirmations to (yet)
718718
// be in the public network graph (and have gotten a chance to propagate), include
719719
// route hints but only for public channels to protect private channel privacy.
720-
channel.is_public
720+
channel.is_announced
721721
} else if online_min_capacity_channel_exists {
722722
has_enough_capacity && channel.is_usable
723723
} else if min_capacity_channel_exists && online_channel_exists {
@@ -738,7 +738,7 @@ where
738738
log_trace!(logger, "Ignoring channel {} without enough capacity for invoice route hints",
739739
&channel.channel_id);
740740
} else {
741-
debug_assert!(!channel.is_usable || (has_pub_unconf_chan && !channel.is_public));
741+
debug_assert!(!channel.is_usable || (has_pub_unconf_chan && !channel.is_announced));
742742
log_trace!(logger, "Ignoring channel {} with disconnected peer",
743743
&channel.channel_id);
744744
}

lightning/src/routing/router.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ impl<'a> CandidateRouteHop<'a> {
13731373
#[inline]
13741374
pub fn globally_unique_short_channel_id(&self) -> Option<u64> {
13751375
match self {
1376-
CandidateRouteHop::FirstHop(hop) => if hop.details.is_public { hop.details.short_channel_id } else { None },
1376+
CandidateRouteHop::FirstHop(hop) => if hop.details.is_announced { hop.details.short_channel_id } else { None },
13771377
CandidateRouteHop::PublicHop(hop) => Some(hop.short_channel_id),
13781378
CandidateRouteHop::PrivateHop(_) => None,
13791379
CandidateRouteHop::Blinded(_) => None,
@@ -3327,7 +3327,7 @@ where L::Target: Logger {
33273327
true
33283328
} else if let CandidateRouteHop::FirstHop(first_hop) = &hop.candidate {
33293329
// If this is a first hop we also know if it's announced.
3330-
first_hop.details.is_public
3330+
first_hop.details.is_announced
33313331
} else {
33323332
// If we sourced it any other way, we double-check the network graph to see if
33333333
// there are announced channels between the endpoints. If so, the hop might be
@@ -3619,7 +3619,7 @@ mod tests {
36193619
confirmations: None,
36203620
force_close_spend_delay: None,
36213621
is_outbound: true, is_channel_ready: true,
3622-
is_usable: true, is_public: true,
3622+
is_usable: true, is_announced: true,
36233623
inbound_htlc_minimum_msat: None,
36243624
inbound_htlc_maximum_msat: None,
36253625
config: None,
@@ -8809,7 +8809,7 @@ pub(crate) mod bench_utils {
88098809
is_outbound: true,
88108810
is_channel_ready: true,
88118811
is_usable: true,
8812-
is_public: true,
8812+
is_announced: true,
88138813
inbound_htlc_minimum_msat: None,
88148814
inbound_htlc_maximum_msat: None,
88158815
config: None,

0 commit comments

Comments
 (0)