From b9c73b176754f92acbadbaf35d10c02682eefd83 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Tue, 20 Aug 2024 13:43:40 +0200 Subject: [PATCH 1/3] Rename `OpenChannelRequest::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 the recently introduced field in `OpenChannelRequest` (which doesn't break released API), and will align the pre-existing instances of `is_public` in the following commit (which will break API). --- lightning/src/events/mod.rs | 2 +- lightning/src/ln/channelmanager.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs index d756eff1bad..bee7e85c822 100644 --- a/lightning/src/events/mod.rs +++ b/lightning/src/events/mod.rs @@ -1316,7 +1316,7 @@ pub enum Event { /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager channel_type: ChannelTypeFeatures, /// True if this channel is (or will be) publicly-announced. - is_public: bool, + is_announced: bool, /// Channel parameters given by the counterparty. params: msgs::ChannelParameters, }, diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 167ab0ac8fd..49f7a38ece7 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -7423,14 +7423,14 @@ where MsgHandleErrInternal::from_chan_no_close(e, msg.common_fields.temporary_channel_id) )?; let mut pending_events = self.pending_events.lock().unwrap(); - let is_public = (msg.common_fields.channel_flags & 1) == 1; + let is_announced = (msg.common_fields.channel_flags & 1) == 1; pending_events.push_back((events::Event::OpenChannelRequest { temporary_channel_id: msg.common_fields.temporary_channel_id.clone(), counterparty_node_id: counterparty_node_id.clone(), funding_satoshis: msg.common_fields.funding_satoshis, push_msat: msg.push_msat, channel_type, - is_public, + is_announced, params: msg.common_fields.channel_parameters(), }, None)); peer_state.inbound_channel_request_by_id.insert(channel_id, InboundChannelRequest { From b3abb192ccf737bef6811907f55f9c1a9e37cbf4 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Tue, 20 Aug 2024 13:47:51 +0200 Subject: [PATCH 2/3] 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`. --- fuzz/src/router.rs | 2 +- lightning/src/ln/channel_state.rs | 12 ++++++------ lightning/src/ln/functional_test_utils.rs | 4 ++-- lightning/src/ln/invoice_utils.rs | 10 +++++----- lightning/src/routing/router.rs | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/fuzz/src/router.rs b/fuzz/src/router.rs index cc28f5ae9f6..41e8162575a 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 f0a5c37e86f..97e6b0af10c 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 05e0a9cfd5b..decbb332663 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 5a793052cc3..f23e9fe1fc6 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 fa2bbac1d14..ed141c0ada3 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, From 5928063789a499169a6c9c6a92d2bc7683276e57 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Thu, 29 Aug 2024 20:16:51 +0200 Subject: [PATCH 3/3] Rename `announced_channel` to `is_announced_for_forwarding` .. we rename the flag configuring whether we announce a channel or not. --- fuzz/src/chanmon_consistency.rs | 4 +-- lightning/src/ln/channel.rs | 26 ++++++++++---------- lightning/src/ln/functional_test_utils.rs | 4 +-- lightning/src/ln/functional_tests.rs | 16 ++++++------ lightning/src/ln/invoice_utils.rs | 4 +-- lightning/src/ln/monitor_tests.rs | 4 +-- lightning/src/ln/onion_route_tests.rs | 18 +++++++------- lightning/src/ln/priv_short_conf_tests.rs | 20 +++++++-------- lightning/src/ln/shutdown_tests.rs | 14 +++++------ lightning/src/util/config.rs | 30 +++++++++++------------ 10 files changed, 70 insertions(+), 70 deletions(-) diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs index 84cc4bf260f..1af33cf8438 100644 --- a/fuzz/src/chanmon_consistency.rs +++ b/fuzz/src/chanmon_consistency.rs @@ -693,7 +693,7 @@ pub fn do_test(data: &[u8], underlying_out: Out, anchors: bool) { let mut config = UserConfig::default(); config.channel_config.forwarding_fee_proportional_millionths = 0; - config.channel_handshake_config.announced_channel = true; + config.channel_handshake_config.announce_for_forwarding = true; if anchors { config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true; config.manually_accept_inbound_channels = true; @@ -738,7 +738,7 @@ pub fn do_test(data: &[u8], underlying_out: Out, anchors: bool) { let mut config = UserConfig::default(); config.channel_config.forwarding_fee_proportional_millionths = 0; - config.channel_handshake_config.announced_channel = true; + config.channel_handshake_config.announce_for_forwarding = true; if anchors { config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true; config.manually_accept_inbound_channels = true; diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index f4d55f91693..f91de27f892 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -1515,7 +1515,7 @@ impl ChannelContext where SP::Target: SignerProvider { SP::Target: SignerProvider, { let logger = WithContext::from(logger, Some(counterparty_node_id), Some(open_channel_fields.temporary_channel_id), None); - let announced_channel = if (open_channel_fields.channel_flags & 1) == 1 { true } else { false }; + let announce_for_forwarding = if (open_channel_fields.channel_flags & 1) == 1 { true } else { false }; let channel_value_satoshis = our_funding_satoshis.saturating_add(open_channel_fields.funding_satoshis); @@ -1589,7 +1589,7 @@ impl ChannelContext where SP::Target: SignerProvider { // Convert things into internal flags and prep our state: if config.channel_handshake_limits.force_announced_channel_preference { - if config.channel_handshake_config.announced_channel != announced_channel { + if config.channel_handshake_config.announce_for_forwarding != announce_for_forwarding { return Err(ChannelError::close("Peer tried to open channel but their announcement preference is different from ours".to_owned())); } } @@ -1689,7 +1689,7 @@ impl ChannelContext where SP::Target: SignerProvider { config: LegacyChannelConfig { options: config.channel_config.clone(), - announced_channel, + announce_for_forwarding, commit_upfront_shutdown_pubkey: config.channel_handshake_config.commit_upfront_shutdown_pubkey, }, @@ -1921,7 +1921,7 @@ impl ChannelContext where SP::Target: SignerProvider { config: LegacyChannelConfig { options: config.channel_config.clone(), - announced_channel: config.channel_handshake_config.announced_channel, + announce_for_forwarding: config.channel_handshake_config.announce_for_forwarding, commit_upfront_shutdown_pubkey: config.channel_handshake_config.commit_upfront_shutdown_pubkey, }, @@ -2066,7 +2066,7 @@ impl ChannelContext where SP::Target: SignerProvider { } pub fn should_announce(&self) -> bool { - self.config.announced_channel + self.config.announce_for_forwarding } pub fn is_outbound(&self) -> bool { @@ -6920,7 +6920,7 @@ impl Channel where fn get_channel_announcement( &self, node_signer: &NS, chain_hash: ChainHash, user_config: &UserConfig, ) -> Result where NS::Target: NodeSigner { - if !self.context.config.announced_channel { + if !self.context.config.announce_for_forwarding { return Err(ChannelError::Ignore("Channel is not available for public announcements".to_owned())); } if !self.context.is_usable() { @@ -7778,7 +7778,7 @@ impl OutboundV1Channel where SP::Target: SignerProvider { delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(), htlc_basepoint: keys.htlc_basepoint.to_public_key(), first_per_commitment_point, - channel_flags: if self.context.config.announced_channel {1} else {0}, + channel_flags: if self.context.config.announce_for_forwarding {1} else {0}, shutdown_scriptpubkey: Some(match &self.context.shutdown_scriptpubkey { Some(script) => script.clone().into_inner(), None => Builder::new().into_script(), @@ -7943,8 +7943,8 @@ pub(super) fn channel_type_from_open_channel( if channel_type.requires_unknown_bits_from(&our_supported_features) { return Err(ChannelError::close("Channel Type contains unsupported features".to_owned())); } - let announced_channel = if (common_fields.channel_flags & 1) == 1 { true } else { false }; - if channel_type.requires_scid_privacy() && announced_channel { + let announce_for_forwarding = if (common_fields.channel_flags & 1) == 1 { true } else { false }; + if channel_type.requires_scid_privacy() && announce_for_forwarding { return Err(ChannelError::close("SCID Alias/Privacy Channel Type cannot be set on a public channel".to_owned())); } Ok(channel_type.clone()) @@ -8317,7 +8317,7 @@ impl OutboundV2Channel where SP::Target: SignerProvider { delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(), htlc_basepoint: keys.htlc_basepoint.to_public_key(), first_per_commitment_point, - channel_flags: if self.context.config.announced_channel {1} else {0}, + channel_flags: if self.context.config.announce_for_forwarding {1} else {0}, shutdown_scriptpubkey: Some(match &self.context.shutdown_scriptpubkey { Some(script) => script.clone().into_inner(), None => Builder::new().into_script(), @@ -8496,7 +8496,7 @@ fn get_initial_channel_type(config: &UserConfig, their_features: &InitFeatures) // available. If it's private, we first try `scid_privacy` as it provides better privacy // with no other changes, and fall back to `only_static_remotekey`. let mut ret = ChannelTypeFeatures::only_static_remote_key(); - if !config.channel_handshake_config.announced_channel && + if !config.channel_handshake_config.announce_for_forwarding && config.channel_handshake_config.negotiate_scid_privacy && their_features.supports_scid_privacy() { ret.set_scid_privacy_required(); @@ -8968,7 +8968,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch // Read the old serialization of the ChannelConfig from version 0.0.98. config.as_mut().unwrap().options.forwarding_fee_proportional_millionths = Readable::read(reader)?; config.as_mut().unwrap().options.cltv_expiry_delta = Readable::read(reader)?; - config.as_mut().unwrap().announced_channel = Readable::read(reader)?; + config.as_mut().unwrap().announce_for_forwarding = Readable::read(reader)?; config.as_mut().unwrap().commit_upfront_shutdown_pubkey = Readable::read(reader)?; } else { // Read the 8 bytes of backwards-compatibility ChannelConfig data. @@ -10287,7 +10287,7 @@ mod tests { let counterparty_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); let mut config = UserConfig::default(); - config.channel_handshake_config.announced_channel = false; + config.channel_handshake_config.announce_for_forwarding = false; let mut chan = OutboundV1Channel::<&Keys>::new(&LowerBoundedFeeEstimator::new(&feeest), &&keys_provider, &&keys_provider, counterparty_node_id, &channelmanager::provided_init_features(&config), 10_000_000, 0, 42, &config, 0, 42, None, &*logger).unwrap(); // Nothing uses their network key in this test chan.context.holder_dust_limit_satoshis = 546; chan.context.counterparty_selected_channel_reserve_satoshis = Some(0); // Filled in in accept_channel diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index decbb332663..b40277fd191 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -1448,7 +1448,7 @@ pub fn create_announced_chan_between_nodes_with_value<'a, 'b, 'c: 'd, 'd>(nodes: pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a Vec>, a: usize, b: usize, channel_value: u64, push_msat: u64) -> (msgs::ChannelReady, Transaction) { let mut no_announce_cfg = test_default_channel_config(); - no_announce_cfg.channel_handshake_config.announced_channel = false; + no_announce_cfg.channel_handshake_config.announce_for_forwarding = false; nodes[a].node.create_channel(nodes[b].node.get_our_node_id(), channel_value, push_msat, 42, None, Some(no_announce_cfg)).unwrap(); let open_channel = get_event_msg!(nodes[a], MessageSendEvent::SendOpenChannel, nodes[b].node.get_our_node_id()); nodes[b].node.handle_open_channel(&nodes[a].node.get_our_node_id(), &open_channel); @@ -3235,7 +3235,7 @@ pub fn test_default_channel_config() -> UserConfig { // Set cltv_expiry_delta slightly lower to keep the final CLTV values inside one byte in our // tests so that our script-length checks don't fail (see ACCEPTED_HTLC_SCRIPT_WEIGHT). default_config.channel_config.cltv_expiry_delta = MIN_CLTV_EXPIRY_DELTA; - default_config.channel_handshake_config.announced_channel = true; + default_config.channel_handshake_config.announce_for_forwarding = true; default_config.channel_handshake_limits.force_announced_channel_preference = false; // When most of our tests were written, the default HTLC minimum was fixed at 1000. // It now defaults to 1, so we simply set it to the expected value here. diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 12f1466e025..6ab9dec6874 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -2475,11 +2475,11 @@ fn channel_monitor_network_test() { fn test_justice_tx_htlc_timeout() { // Test justice txn built on revoked HTLC-Timeout tx, against both sides let mut alice_config = test_default_channel_config(); - alice_config.channel_handshake_config.announced_channel = true; + alice_config.channel_handshake_config.announce_for_forwarding = true; alice_config.channel_handshake_limits.force_announced_channel_preference = false; alice_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 5; let mut bob_config = test_default_channel_config(); - bob_config.channel_handshake_config.announced_channel = true; + bob_config.channel_handshake_config.announce_for_forwarding = true; bob_config.channel_handshake_limits.force_announced_channel_preference = false; bob_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 3; let user_cfgs = [Some(alice_config), Some(bob_config)]; @@ -2538,11 +2538,11 @@ fn test_justice_tx_htlc_timeout() { fn test_justice_tx_htlc_success() { // Test justice txn built on revoked HTLC-Success tx, against both sides let mut alice_config = test_default_channel_config(); - alice_config.channel_handshake_config.announced_channel = true; + alice_config.channel_handshake_config.announce_for_forwarding = true; alice_config.channel_handshake_limits.force_announced_channel_preference = false; alice_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 5; let mut bob_config = test_default_channel_config(); - bob_config.channel_handshake_config.announced_channel = true; + bob_config.channel_handshake_config.announce_for_forwarding = true; bob_config.channel_handshake_limits.force_announced_channel_preference = false; bob_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 3; let user_cfgs = [Some(alice_config), Some(bob_config)]; @@ -8017,16 +8017,16 @@ fn test_channel_update_has_correct_htlc_maximum_msat() { // 2. MUST be set to less than or equal to the `max_htlc_value_in_flight_msat` received from the peer. let mut config_30_percent = UserConfig::default(); - config_30_percent.channel_handshake_config.announced_channel = true; + config_30_percent.channel_handshake_config.announce_for_forwarding = true; config_30_percent.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 30; let mut config_50_percent = UserConfig::default(); - config_50_percent.channel_handshake_config.announced_channel = true; + config_50_percent.channel_handshake_config.announce_for_forwarding = true; config_50_percent.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 50; let mut config_95_percent = UserConfig::default(); - config_95_percent.channel_handshake_config.announced_channel = true; + config_95_percent.channel_handshake_config.announce_for_forwarding = true; config_95_percent.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 95; let mut config_100_percent = UserConfig::default(); - config_100_percent.channel_handshake_config.announced_channel = true; + config_100_percent.channel_handshake_config.announce_for_forwarding = true; config_100_percent.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 100; let chanmon_cfgs = create_chanmon_cfgs(4); diff --git a/lightning/src/ln/invoice_utils.rs b/lightning/src/ln/invoice_utils.rs index f23e9fe1fc6..a4f87c1f6bd 100644 --- a/lightning/src/ln/invoice_utils.rs +++ b/lightning/src/ln/invoice_utils.rs @@ -1159,7 +1159,7 @@ mod test { // `msgs::ChannelUpdate` is never handled for the node(s). As the `msgs::ChannelUpdate` // is never handled, the `channel.counterparty.forwarding_info` is never assigned. let mut private_chan_cfg = UserConfig::default(); - private_chan_cfg.channel_handshake_config.announced_channel = false; + private_chan_cfg.channel_handshake_config.announce_for_forwarding = false; let temporary_channel_id = nodes[2].node.create_channel(nodes[0].node.get_our_node_id(), 1_000_000, 500_000_000, 42, None, Some(private_chan_cfg)).unwrap(); let open_channel = get_event_msg!(nodes[2], MessageSendEvent::SendOpenChannel, nodes[0].node.get_our_node_id()); nodes[0].node.handle_open_channel(&nodes[2].node.get_our_node_id(), &open_channel); @@ -1568,7 +1568,7 @@ mod test { // `msgs::ChannelUpdate` is never handled for the node(s). As the `msgs::ChannelUpdate` // is never handled, the `channel.counterparty.forwarding_info` is never assigned. let mut private_chan_cfg = UserConfig::default(); - private_chan_cfg.channel_handshake_config.announced_channel = false; + private_chan_cfg.channel_handshake_config.announce_for_forwarding = false; let temporary_channel_id = nodes[1].node.create_channel(nodes[3].node.get_our_node_id(), 1_000_000, 500_000_000, 42, None, Some(private_chan_cfg)).unwrap(); let open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[3].node.get_our_node_id()); nodes[3].node.handle_open_channel(&nodes[1].node.get_our_node_id(), &open_channel); diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs index 3fbcef3449b..4efc2963db5 100644 --- a/lightning/src/ln/monitor_tests.rs +++ b/lightning/src/ln/monitor_tests.rs @@ -2469,7 +2469,7 @@ fn test_yield_anchors_events() { let mut chanmon_cfgs = create_chanmon_cfgs(2); let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); let mut anchors_config = test_default_channel_config(); - anchors_config.channel_handshake_config.announced_channel = true; + anchors_config.channel_handshake_config.announce_for_forwarding = true; anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true; anchors_config.manually_accept_inbound_channels = true; let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(anchors_config), Some(anchors_config)]); @@ -2620,7 +2620,7 @@ fn test_anchors_aggregated_revoked_htlc_tx() { let bob_chain_monitor; let mut anchors_config = test_default_channel_config(); - anchors_config.channel_handshake_config.announced_channel = true; + anchors_config.channel_handshake_config.announce_for_forwarding = true; anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true; anchors_config.manually_accept_inbound_channels = true; let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(anchors_config), Some(anchors_config)]); diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index 94c2cfd2ee4..0ddadd21614 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -328,7 +328,7 @@ fn test_onion_failure() { // Channel::get_counterparty_htlc_minimum_msat(). let mut node_2_cfg: UserConfig = test_default_channel_config(); node_2_cfg.channel_handshake_config.our_htlc_minimum_msat = 2000; - node_2_cfg.channel_handshake_config.announced_channel = true; + node_2_cfg.channel_handshake_config.announce_for_forwarding = true; node_2_cfg.channel_handshake_limits.force_announced_channel_preference = false; // When this test was written, the default base fee floated based on the HTLC count. @@ -754,13 +754,13 @@ fn test_overshoot_final_cltv() { claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage); } -fn do_test_onion_failure_stale_channel_update(announced_channel: bool) { +fn do_test_onion_failure_stale_channel_update(announce_for_forwarding: bool) { // Create a network of three nodes and two channels connecting them. We'll be updating the // HTLC relay policy of the second channel, causing forwarding failures at the first hop. let mut config = UserConfig::default(); - config.channel_handshake_config.announced_channel = announced_channel; + config.channel_handshake_config.announce_for_forwarding = announce_for_forwarding; config.channel_handshake_limits.force_announced_channel_preference = false; - config.accept_forwards_to_priv_channels = !announced_channel; + config.accept_forwards_to_priv_channels = !announce_for_forwarding; config.channel_config.max_dust_htlc_exposure = MaxDustHTLCExposure::FeeRateMultiplier(5_000_000 / 253); let chanmon_cfgs = create_chanmon_cfgs(3); let node_cfgs = create_node_cfgs(3, &chanmon_cfgs); @@ -773,7 +773,7 @@ fn do_test_onion_failure_stale_channel_update(announced_channel: bool) { let other_channel = create_chan_between_nodes( &nodes[0], &nodes[1], ); - let channel_to_update = if announced_channel { + let channel_to_update = if announce_for_forwarding { let channel = create_announced_chan_between_nodes( &nodes, 1, 2, ); @@ -790,7 +790,7 @@ fn do_test_onion_failure_stale_channel_update(announced_channel: bool) { // A test payment should succeed as the ChannelConfig has not been changed yet. const PAYMENT_AMT: u64 = 40000; - let (route, payment_hash, payment_preimage, payment_secret) = if announced_channel { + let (route, payment_hash, payment_preimage, payment_secret) = if announce_for_forwarding { get_route_and_payment_hash!(nodes[0], nodes[2], PAYMENT_AMT) } else { let hop_hints = vec![RouteHint(vec![RouteHintHop { @@ -833,12 +833,12 @@ fn do_test_onion_failure_stale_channel_update(announced_channel: bool) { } let new_update = match &events[0] { MessageSendEvent::BroadcastChannelUpdate { msg } => { - assert!(announced_channel); + assert!(announce_for_forwarding); msg.clone() }, MessageSendEvent::SendChannelUpdate { node_id, msg } => { assert_eq!(node_id, channel_to_update_counterparty); - assert!(!announced_channel); + assert!(!announce_for_forwarding); msg.clone() }, _ => panic!("expected Broadcast/SendChannelUpdate event"), @@ -1505,7 +1505,7 @@ fn do_test_phantom_dust_exposure_failure(multiplier_dust_limit: bool) { receiver_config.channel_config.max_dust_htlc_exposure = if multiplier_dust_limit { MaxDustHTLCExposure::FeeRateMultiplier(2) } else { MaxDustHTLCExposure::FixedLimitMsat(max_dust_exposure) }; - receiver_config.channel_handshake_config.announced_channel = true; + receiver_config.channel_handshake_config.announce_for_forwarding = true; let chanmon_cfgs = create_chanmon_cfgs(2); let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); diff --git a/lightning/src/ln/priv_short_conf_tests.rs b/lightning/src/ln/priv_short_conf_tests.rs index a68f22ac927..83ff296e177 100644 --- a/lightning/src/ln/priv_short_conf_tests.rs +++ b/lightning/src/ln/priv_short_conf_tests.rs @@ -139,12 +139,12 @@ fn do_test_1_conf_open(connect_style: ConnectStyle) { // tests that we properly send one in that case. let mut alice_config = UserConfig::default(); alice_config.channel_handshake_config.minimum_depth = 1; - alice_config.channel_handshake_config.announced_channel = true; + alice_config.channel_handshake_config.announce_for_forwarding = true; alice_config.channel_handshake_limits.force_announced_channel_preference = false; alice_config.channel_config.max_dust_htlc_exposure = MaxDustHTLCExposure::FeeRateMultiplier(5_000_000 / 253); let mut bob_config = UserConfig::default(); bob_config.channel_handshake_config.minimum_depth = 1; - bob_config.channel_handshake_config.announced_channel = true; + bob_config.channel_handshake_config.announce_for_forwarding = true; bob_config.channel_handshake_limits.force_announced_channel_preference = false; bob_config.channel_config.max_dust_htlc_exposure = MaxDustHTLCExposure::FeeRateMultiplier(5_000_000 / 253); let chanmon_cfgs = create_chanmon_cfgs(2); @@ -288,7 +288,7 @@ fn test_scid_privacy_on_pub_channel() { let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs); let mut scid_privacy_cfg = test_default_channel_config(); - scid_privacy_cfg.channel_handshake_config.announced_channel = true; + scid_privacy_cfg.channel_handshake_config.announce_for_forwarding = true; scid_privacy_cfg.channel_handshake_config.negotiate_scid_privacy = true; nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, Some(scid_privacy_cfg)).unwrap(); let mut open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()); @@ -312,7 +312,7 @@ fn test_scid_privacy_negotiation() { let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs); let mut scid_privacy_cfg = test_default_channel_config(); - scid_privacy_cfg.channel_handshake_config.announced_channel = false; + scid_privacy_cfg.channel_handshake_config.announce_for_forwarding = false; scid_privacy_cfg.channel_handshake_config.negotiate_scid_privacy = true; nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, Some(scid_privacy_cfg)).unwrap(); @@ -358,7 +358,7 @@ fn test_inbound_scid_privacy() { create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0); let mut no_announce_cfg = test_default_channel_config(); - no_announce_cfg.channel_handshake_config.announced_channel = false; + no_announce_cfg.channel_handshake_config.announce_for_forwarding = false; no_announce_cfg.channel_handshake_config.negotiate_scid_privacy = true; nodes[1].node.create_channel(nodes[2].node.get_our_node_id(), 100_000, 10_000, 42, None, Some(no_announce_cfg)).unwrap(); let mut open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[2].node.get_our_node_id()); @@ -591,7 +591,7 @@ fn test_0conf_channel_with_async_monitor() { create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0); - chan_config.channel_handshake_config.announced_channel = false; + chan_config.channel_handshake_config.announce_for_forwarding = false; nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, Some(chan_config)).unwrap(); let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()); @@ -758,7 +758,7 @@ fn test_0conf_close_no_early_chan_update() { let error_message = "Channel force-closed"; // This is the default but we force it on anyway - chan_config.channel_handshake_config.announced_channel = true; + chan_config.channel_handshake_config.announce_for_forwarding = true; open_zero_conf_channel(&nodes[0], &nodes[1], Some(chan_config)); // We can use the channel immediately, but won't generate a channel_update until we get confs @@ -782,7 +782,7 @@ fn test_public_0conf_channel() { let nodes = create_network(2, &node_cfgs, &node_chanmgrs); // This is the default but we force it on anyway - chan_config.channel_handshake_config.announced_channel = true; + chan_config.channel_handshake_config.announce_for_forwarding = true; let (tx, ..) = open_zero_conf_channel(&nodes[0], &nodes[1], Some(chan_config)); // We can use the channel immediately, but we can't announce it until we get 6+ confirmations @@ -836,7 +836,7 @@ fn test_0conf_channel_reorg() { let nodes = create_network(2, &node_cfgs, &node_chanmgrs); // This is the default but we force it on anyway - chan_config.channel_handshake_config.announced_channel = true; + chan_config.channel_handshake_config.announce_for_forwarding = true; let (tx, ..) = open_zero_conf_channel(&nodes[0], &nodes[1], Some(chan_config)); // We can use the channel immediately, but we can't announce it until we get 6+ confirmations @@ -1027,7 +1027,7 @@ fn test_0conf_ann_sigs_racing_conf() { let nodes = create_network(2, &node_cfgs, &node_chanmgrs); // This is the default but we force it on anyway - chan_config.channel_handshake_config.announced_channel = true; + chan_config.channel_handshake_config.announce_for_forwarding = true; let (tx, ..) = open_zero_conf_channel(&nodes[0], &nodes[1], Some(chan_config)); // We can use the channel immediately, but we can't announce it until we get 6+ confirmations diff --git a/lightning/src/ln/shutdown_tests.rs b/lightning/src/ln/shutdown_tests.rs index 0ba6e1259f5..3a92f02ccb5 100644 --- a/lightning/src/ln/shutdown_tests.rs +++ b/lightning/src/ln/shutdown_tests.rs @@ -728,7 +728,7 @@ fn test_upfront_shutdown_script() { // enforce it at shutdown message let mut config = UserConfig::default(); - config.channel_handshake_config.announced_channel = true; + config.channel_handshake_config.announce_for_forwarding = true; config.channel_handshake_limits.force_announced_channel_preference = false; config.channel_handshake_config.commit_upfront_shutdown_pubkey = false; let user_cfgs = [None, Some(config), None]; @@ -902,7 +902,7 @@ fn test_invalid_upfront_shutdown_script() { #[test] fn test_segwit_v0_shutdown_script() { let mut config = UserConfig::default(); - config.channel_handshake_config.announced_channel = true; + config.channel_handshake_config.announce_for_forwarding = true; config.channel_handshake_limits.force_announced_channel_preference = false; config.channel_handshake_config.commit_upfront_shutdown_pubkey = false; let user_cfgs = [None, Some(config), None]; @@ -937,7 +937,7 @@ fn test_segwit_v0_shutdown_script() { #[test] fn test_anysegwit_shutdown_script() { let mut config = UserConfig::default(); - config.channel_handshake_config.announced_channel = true; + config.channel_handshake_config.announce_for_forwarding = true; config.channel_handshake_limits.force_announced_channel_preference = false; config.channel_handshake_config.commit_upfront_shutdown_pubkey = false; let user_cfgs = [None, Some(config), None]; @@ -972,7 +972,7 @@ fn test_anysegwit_shutdown_script() { #[test] fn test_unsupported_anysegwit_shutdown_script() { let mut config = UserConfig::default(); - config.channel_handshake_config.announced_channel = true; + config.channel_handshake_config.announce_for_forwarding = true; config.channel_handshake_limits.force_announced_channel_preference = false; config.channel_handshake_config.commit_upfront_shutdown_pubkey = false; let user_cfgs = [None, Some(config), None]; @@ -1015,7 +1015,7 @@ fn test_unsupported_anysegwit_shutdown_script() { #[test] fn test_invalid_shutdown_script() { let mut config = UserConfig::default(); - config.channel_handshake_config.announced_channel = true; + config.channel_handshake_config.announce_for_forwarding = true; config.channel_handshake_limits.force_announced_channel_preference = false; config.channel_handshake_config.commit_upfront_shutdown_pubkey = false; let user_cfgs = [None, Some(config), None]; @@ -1042,7 +1042,7 @@ fn test_invalid_shutdown_script() { #[test] fn test_user_shutdown_script() { let mut config = test_default_channel_config(); - config.channel_handshake_config.announced_channel = true; + config.channel_handshake_config.announce_for_forwarding = true; config.channel_handshake_limits.force_announced_channel_preference = false; config.channel_handshake_config.commit_upfront_shutdown_pubkey = false; let user_cfgs = [None, Some(config), None]; @@ -1070,7 +1070,7 @@ fn test_user_shutdown_script() { #[test] fn test_already_set_user_shutdown_script() { let mut config = test_default_channel_config(); - config.channel_handshake_config.announced_channel = true; + config.channel_handshake_config.announce_for_forwarding = true; config.channel_handshake_limits.force_announced_channel_preference = false; let user_cfgs = [None, Some(config), None]; let chanmon_cfgs = create_chanmon_cfgs(3); diff --git a/lightning/src/util/config.rs b/lightning/src/util/config.rs index f369e793e9d..1c40aca87f3 100644 --- a/lightning/src/util/config.rs +++ b/lightning/src/util/config.rs @@ -99,7 +99,7 @@ pub struct ChannelHandshakeConfig { /// private channel without that option. /// /// Ignored if the channel is negotiated to be announced, see - /// [`ChannelHandshakeConfig::announced_channel`] and + /// [`ChannelHandshakeConfig::announce_for_forwarding`] and /// [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. /// /// Default value: `false` (This value is likely to change to `true` in the future.) @@ -116,7 +116,7 @@ pub struct ChannelHandshakeConfig { /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. /// /// Default value: `false` - pub announced_channel: bool, + pub announce_for_forwarding: bool, /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty /// supports it, they will then enforce the mutual-close output to us matches what we provided /// at intialization, preventing us from closing to an alternate pubkey. @@ -211,7 +211,7 @@ impl Default for ChannelHandshakeConfig { our_htlc_minimum_msat: 1, max_inbound_htlc_value_in_flight_percent_of_channel: 10, negotiate_scid_privacy: false, - announced_channel: false, + announce_for_forwarding: false, commit_upfront_shutdown_pubkey: true, their_channel_reserve_proportional_millionths: 10_000, negotiate_anchors_zero_fee_htlc_tx: false, @@ -232,7 +232,7 @@ impl Readable for ChannelHandshakeConfig { our_htlc_minimum_msat: Readable::read(reader)?, max_inbound_htlc_value_in_flight_percent_of_channel: Readable::read(reader)?, negotiate_scid_privacy: Readable::read(reader)?, - announced_channel: Readable::read(reader)?, + announce_for_forwarding: Readable::read(reader)?, commit_upfront_shutdown_pubkey: Readable::read(reader)?, their_channel_reserve_proportional_millionths: Readable::read(reader)?, negotiate_anchors_zero_fee_htlc_tx: Readable::read(reader)?, @@ -312,10 +312,10 @@ pub struct ChannelHandshakeLimits { /// Default value: `true` pub trust_own_funding_0conf: bool, /// Set to force an incoming channel to match our announced channel preference in - /// [`ChannelHandshakeConfig::announced_channel`]. + /// [`ChannelHandshakeConfig::announce_for_forwarding`]. /// /// For a node which is not online reliably, this should be set to true and - /// [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) + /// [`ChannelHandshakeConfig::announce_for_forwarding`] set to false, ensuring that no announced (aka public) /// channels will ever be opened. /// /// Default value: `true` @@ -693,14 +693,14 @@ impl From for ChannelConfigUpdate { } /// Legacy version of [`ChannelConfig`] that stored the static -/// [`ChannelHandshakeConfig::announced_channel`] and +/// [`ChannelHandshakeConfig::announce_for_forwarding`] and /// [`ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`] fields. #[derive(Copy, Clone, Debug)] pub(crate) struct LegacyChannelConfig { pub(crate) options: ChannelConfig, - /// Deprecated but may still be read from. See [`ChannelHandshakeConfig::announced_channel`] to + /// Deprecated but may still be read from. See [`ChannelHandshakeConfig::announce_for_forwarding`] to /// set this when opening/accepting a channel. - pub(crate) announced_channel: bool, + pub(crate) announce_for_forwarding: bool, /// Deprecated but may still be read from. See /// [`ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`] to set this when /// opening/accepting a channel. @@ -711,7 +711,7 @@ impl Default for LegacyChannelConfig { fn default() -> Self { Self { options: ChannelConfig::default(), - announced_channel: false, + announce_for_forwarding: false, commit_upfront_shutdown_pubkey: true, } } @@ -728,7 +728,7 @@ impl crate::util::ser::Writeable for LegacyChannelConfig { (1, max_dust_htlc_exposure_msat_fixed_limit, required), (2, self.options.cltv_expiry_delta, required), (3, self.options.force_close_avoidance_max_fee_satoshis, (default_value, 1000)), - (4, self.announced_channel, required), + (4, self.announce_for_forwarding, required), (5, self.options.max_dust_htlc_exposure, required), (6, self.commit_upfront_shutdown_pubkey, required), (8, self.options.forwarding_fee_base_msat, required), @@ -743,7 +743,7 @@ impl crate::util::ser::Readable for LegacyChannelConfig { let mut max_dust_htlc_exposure_msat_fixed_limit = None; let mut cltv_expiry_delta = 0; let mut force_close_avoidance_max_fee_satoshis = 1000; - let mut announced_channel = false; + let mut announce_for_forwarding = false; let mut commit_upfront_shutdown_pubkey = false; let mut forwarding_fee_base_msat = 0; let mut max_dust_htlc_exposure_enum = None; @@ -753,7 +753,7 @@ impl crate::util::ser::Readable for LegacyChannelConfig { (1, max_dust_htlc_exposure_msat_fixed_limit, option), (2, cltv_expiry_delta, required), (3, force_close_avoidance_max_fee_satoshis, (default_value, 1000u64)), - (4, announced_channel, required), + (4, announce_for_forwarding, required), (5, max_dust_htlc_exposure_enum, option), (6, commit_upfront_shutdown_pubkey, required), (8, forwarding_fee_base_msat, required), @@ -771,7 +771,7 @@ impl crate::util::ser::Readable for LegacyChannelConfig { forwarding_fee_base_msat, accept_underpaying_htlcs: false, }, - announced_channel, + announce_for_forwarding, commit_upfront_shutdown_pubkey, }) } @@ -794,7 +794,7 @@ pub struct UserConfig { /// node which is not online reliably. /// /// For nodes which are not online reliably, you should set all channels to *not* be announced - /// (using [`ChannelHandshakeConfig::announced_channel`] and + /// (using [`ChannelHandshakeConfig::announce_for_forwarding`] and /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to `false` to /// ensure you are not exposed to any forwarding risk. ///