Skip to content

Commit 5928063

Browse files
committed
Rename announced_channel to is_announced_for_forwarding
.. we rename the flag configuring whether we announce a channel or not.
1 parent b3abb19 commit 5928063

10 files changed

+70
-70
lines changed

fuzz/src/chanmon_consistency.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
693693

694694
let mut config = UserConfig::default();
695695
config.channel_config.forwarding_fee_proportional_millionths = 0;
696-
config.channel_handshake_config.announced_channel = true;
696+
config.channel_handshake_config.announce_for_forwarding = true;
697697
if anchors {
698698
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
699699
config.manually_accept_inbound_channels = true;
@@ -738,7 +738,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
738738

739739
let mut config = UserConfig::default();
740740
config.channel_config.forwarding_fee_proportional_millionths = 0;
741-
config.channel_handshake_config.announced_channel = true;
741+
config.channel_handshake_config.announce_for_forwarding = true;
742742
if anchors {
743743
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
744744
config.manually_accept_inbound_channels = true;

lightning/src/ln/channel.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
15151515
SP::Target: SignerProvider,
15161516
{
15171517
let logger = WithContext::from(logger, Some(counterparty_node_id), Some(open_channel_fields.temporary_channel_id), None);
1518-
let announced_channel = if (open_channel_fields.channel_flags & 1) == 1 { true } else { false };
1518+
let announce_for_forwarding = if (open_channel_fields.channel_flags & 1) == 1 { true } else { false };
15191519

15201520
let channel_value_satoshis = our_funding_satoshis.saturating_add(open_channel_fields.funding_satoshis);
15211521

@@ -1589,7 +1589,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
15891589
// Convert things into internal flags and prep our state:
15901590

15911591
if config.channel_handshake_limits.force_announced_channel_preference {
1592-
if config.channel_handshake_config.announced_channel != announced_channel {
1592+
if config.channel_handshake_config.announce_for_forwarding != announce_for_forwarding {
15931593
return Err(ChannelError::close("Peer tried to open channel but their announcement preference is different from ours".to_owned()));
15941594
}
15951595
}
@@ -1689,7 +1689,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
16891689

16901690
config: LegacyChannelConfig {
16911691
options: config.channel_config.clone(),
1692-
announced_channel,
1692+
announce_for_forwarding,
16931693
commit_upfront_shutdown_pubkey: config.channel_handshake_config.commit_upfront_shutdown_pubkey,
16941694
},
16951695

@@ -1921,7 +1921,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
19211921

19221922
config: LegacyChannelConfig {
19231923
options: config.channel_config.clone(),
1924-
announced_channel: config.channel_handshake_config.announced_channel,
1924+
announce_for_forwarding: config.channel_handshake_config.announce_for_forwarding,
19251925
commit_upfront_shutdown_pubkey: config.channel_handshake_config.commit_upfront_shutdown_pubkey,
19261926
},
19271927

@@ -2066,7 +2066,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
20662066
}
20672067

20682068
pub fn should_announce(&self) -> bool {
2069-
self.config.announced_channel
2069+
self.config.announce_for_forwarding
20702070
}
20712071

20722072
pub fn is_outbound(&self) -> bool {
@@ -6920,7 +6920,7 @@ impl<SP: Deref> Channel<SP> where
69206920
fn get_channel_announcement<NS: Deref>(
69216921
&self, node_signer: &NS, chain_hash: ChainHash, user_config: &UserConfig,
69226922
) -> Result<msgs::UnsignedChannelAnnouncement, ChannelError> where NS::Target: NodeSigner {
6923-
if !self.context.config.announced_channel {
6923+
if !self.context.config.announce_for_forwarding {
69246924
return Err(ChannelError::Ignore("Channel is not available for public announcements".to_owned()));
69256925
}
69266926
if !self.context.is_usable() {
@@ -7778,7 +7778,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77787778
delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(),
77797779
htlc_basepoint: keys.htlc_basepoint.to_public_key(),
77807780
first_per_commitment_point,
7781-
channel_flags: if self.context.config.announced_channel {1} else {0},
7781+
channel_flags: if self.context.config.announce_for_forwarding {1} else {0},
77827782
shutdown_scriptpubkey: Some(match &self.context.shutdown_scriptpubkey {
77837783
Some(script) => script.clone().into_inner(),
77847784
None => Builder::new().into_script(),
@@ -7943,8 +7943,8 @@ pub(super) fn channel_type_from_open_channel(
79437943
if channel_type.requires_unknown_bits_from(&our_supported_features) {
79447944
return Err(ChannelError::close("Channel Type contains unsupported features".to_owned()));
79457945
}
7946-
let announced_channel = if (common_fields.channel_flags & 1) == 1 { true } else { false };
7947-
if channel_type.requires_scid_privacy() && announced_channel {
7946+
let announce_for_forwarding = if (common_fields.channel_flags & 1) == 1 { true } else { false };
7947+
if channel_type.requires_scid_privacy() && announce_for_forwarding {
79487948
return Err(ChannelError::close("SCID Alias/Privacy Channel Type cannot be set on a public channel".to_owned()));
79497949
}
79507950
Ok(channel_type.clone())
@@ -8317,7 +8317,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
83178317
delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(),
83188318
htlc_basepoint: keys.htlc_basepoint.to_public_key(),
83198319
first_per_commitment_point,
8320-
channel_flags: if self.context.config.announced_channel {1} else {0},
8320+
channel_flags: if self.context.config.announce_for_forwarding {1} else {0},
83218321
shutdown_scriptpubkey: Some(match &self.context.shutdown_scriptpubkey {
83228322
Some(script) => script.clone().into_inner(),
83238323
None => Builder::new().into_script(),
@@ -8496,7 +8496,7 @@ fn get_initial_channel_type(config: &UserConfig, their_features: &InitFeatures)
84968496
// available. If it's private, we first try `scid_privacy` as it provides better privacy
84978497
// with no other changes, and fall back to `only_static_remotekey`.
84988498
let mut ret = ChannelTypeFeatures::only_static_remote_key();
8499-
if !config.channel_handshake_config.announced_channel &&
8499+
if !config.channel_handshake_config.announce_for_forwarding &&
85008500
config.channel_handshake_config.negotiate_scid_privacy &&
85018501
their_features.supports_scid_privacy() {
85028502
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
89688968
// Read the old serialization of the ChannelConfig from version 0.0.98.
89698969
config.as_mut().unwrap().options.forwarding_fee_proportional_millionths = Readable::read(reader)?;
89708970
config.as_mut().unwrap().options.cltv_expiry_delta = Readable::read(reader)?;
8971-
config.as_mut().unwrap().announced_channel = Readable::read(reader)?;
8971+
config.as_mut().unwrap().announce_for_forwarding = Readable::read(reader)?;
89728972
config.as_mut().unwrap().commit_upfront_shutdown_pubkey = Readable::read(reader)?;
89738973
} else {
89748974
// Read the 8 bytes of backwards-compatibility ChannelConfig data.
@@ -10287,7 +10287,7 @@ mod tests {
1028710287

1028810288
let counterparty_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
1028910289
let mut config = UserConfig::default();
10290-
config.channel_handshake_config.announced_channel = false;
10290+
config.channel_handshake_config.announce_for_forwarding = false;
1029110291
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
1029210292
chan.context.holder_dust_limit_satoshis = 546;
1029310293
chan.context.counterparty_selected_channel_reserve_satoshis = Some(0); // Filled in in accept_channel

lightning/src/ln/functional_test_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ pub fn create_announced_chan_between_nodes_with_value<'a, 'b, 'c: 'd, 'd>(nodes:
14481448

14491449
pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize, channel_value: u64, push_msat: u64) -> (msgs::ChannelReady, Transaction) {
14501450
let mut no_announce_cfg = test_default_channel_config();
1451-
no_announce_cfg.channel_handshake_config.announced_channel = false;
1451+
no_announce_cfg.channel_handshake_config.announce_for_forwarding = false;
14521452
nodes[a].node.create_channel(nodes[b].node.get_our_node_id(), channel_value, push_msat, 42, None, Some(no_announce_cfg)).unwrap();
14531453
let open_channel = get_event_msg!(nodes[a], MessageSendEvent::SendOpenChannel, nodes[b].node.get_our_node_id());
14541454
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 {
32353235
// Set cltv_expiry_delta slightly lower to keep the final CLTV values inside one byte in our
32363236
// tests so that our script-length checks don't fail (see ACCEPTED_HTLC_SCRIPT_WEIGHT).
32373237
default_config.channel_config.cltv_expiry_delta = MIN_CLTV_EXPIRY_DELTA;
3238-
default_config.channel_handshake_config.announced_channel = true;
3238+
default_config.channel_handshake_config.announce_for_forwarding = true;
32393239
default_config.channel_handshake_limits.force_announced_channel_preference = false;
32403240
// When most of our tests were written, the default HTLC minimum was fixed at 1000.
32413241
// It now defaults to 1, so we simply set it to the expected value here.

lightning/src/ln/functional_tests.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -2475,11 +2475,11 @@ fn channel_monitor_network_test() {
24752475
fn test_justice_tx_htlc_timeout() {
24762476
// Test justice txn built on revoked HTLC-Timeout tx, against both sides
24772477
let mut alice_config = test_default_channel_config();
2478-
alice_config.channel_handshake_config.announced_channel = true;
2478+
alice_config.channel_handshake_config.announce_for_forwarding = true;
24792479
alice_config.channel_handshake_limits.force_announced_channel_preference = false;
24802480
alice_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 5;
24812481
let mut bob_config = test_default_channel_config();
2482-
bob_config.channel_handshake_config.announced_channel = true;
2482+
bob_config.channel_handshake_config.announce_for_forwarding = true;
24832483
bob_config.channel_handshake_limits.force_announced_channel_preference = false;
24842484
bob_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 3;
24852485
let user_cfgs = [Some(alice_config), Some(bob_config)];
@@ -2538,11 +2538,11 @@ fn test_justice_tx_htlc_timeout() {
25382538
fn test_justice_tx_htlc_success() {
25392539
// Test justice txn built on revoked HTLC-Success tx, against both sides
25402540
let mut alice_config = test_default_channel_config();
2541-
alice_config.channel_handshake_config.announced_channel = true;
2541+
alice_config.channel_handshake_config.announce_for_forwarding = true;
25422542
alice_config.channel_handshake_limits.force_announced_channel_preference = false;
25432543
alice_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 5;
25442544
let mut bob_config = test_default_channel_config();
2545-
bob_config.channel_handshake_config.announced_channel = true;
2545+
bob_config.channel_handshake_config.announce_for_forwarding = true;
25462546
bob_config.channel_handshake_limits.force_announced_channel_preference = false;
25472547
bob_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 3;
25482548
let user_cfgs = [Some(alice_config), Some(bob_config)];
@@ -8017,16 +8017,16 @@ fn test_channel_update_has_correct_htlc_maximum_msat() {
80178017
// 2. MUST be set to less than or equal to the `max_htlc_value_in_flight_msat` received from the peer.
80188018

80198019
let mut config_30_percent = UserConfig::default();
8020-
config_30_percent.channel_handshake_config.announced_channel = true;
8020+
config_30_percent.channel_handshake_config.announce_for_forwarding = true;
80218021
config_30_percent.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 30;
80228022
let mut config_50_percent = UserConfig::default();
8023-
config_50_percent.channel_handshake_config.announced_channel = true;
8023+
config_50_percent.channel_handshake_config.announce_for_forwarding = true;
80248024
config_50_percent.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 50;
80258025
let mut config_95_percent = UserConfig::default();
8026-
config_95_percent.channel_handshake_config.announced_channel = true;
8026+
config_95_percent.channel_handshake_config.announce_for_forwarding = true;
80278027
config_95_percent.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 95;
80288028
let mut config_100_percent = UserConfig::default();
8029-
config_100_percent.channel_handshake_config.announced_channel = true;
8029+
config_100_percent.channel_handshake_config.announce_for_forwarding = true;
80308030
config_100_percent.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 100;
80318031

80328032
let chanmon_cfgs = create_chanmon_cfgs(4);

lightning/src/ln/invoice_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ mod test {
11591159
// `msgs::ChannelUpdate` is never handled for the node(s). As the `msgs::ChannelUpdate`
11601160
// is never handled, the `channel.counterparty.forwarding_info` is never assigned.
11611161
let mut private_chan_cfg = UserConfig::default();
1162-
private_chan_cfg.channel_handshake_config.announced_channel = false;
1162+
private_chan_cfg.channel_handshake_config.announce_for_forwarding = false;
11631163
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();
11641164
let open_channel = get_event_msg!(nodes[2], MessageSendEvent::SendOpenChannel, nodes[0].node.get_our_node_id());
11651165
nodes[0].node.handle_open_channel(&nodes[2].node.get_our_node_id(), &open_channel);
@@ -1568,7 +1568,7 @@ mod test {
15681568
// `msgs::ChannelUpdate` is never handled for the node(s). As the `msgs::ChannelUpdate`
15691569
// is never handled, the `channel.counterparty.forwarding_info` is never assigned.
15701570
let mut private_chan_cfg = UserConfig::default();
1571-
private_chan_cfg.channel_handshake_config.announced_channel = false;
1571+
private_chan_cfg.channel_handshake_config.announce_for_forwarding = false;
15721572
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();
15731573
let open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[3].node.get_our_node_id());
15741574
nodes[3].node.handle_open_channel(&nodes[1].node.get_our_node_id(), &open_channel);

lightning/src/ln/monitor_tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,7 @@ fn test_yield_anchors_events() {
24692469
let mut chanmon_cfgs = create_chanmon_cfgs(2);
24702470
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
24712471
let mut anchors_config = test_default_channel_config();
2472-
anchors_config.channel_handshake_config.announced_channel = true;
2472+
anchors_config.channel_handshake_config.announce_for_forwarding = true;
24732473
anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
24742474
anchors_config.manually_accept_inbound_channels = true;
24752475
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() {
26202620
let bob_chain_monitor;
26212621

26222622
let mut anchors_config = test_default_channel_config();
2623-
anchors_config.channel_handshake_config.announced_channel = true;
2623+
anchors_config.channel_handshake_config.announce_for_forwarding = true;
26242624
anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
26252625
anchors_config.manually_accept_inbound_channels = true;
26262626
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(anchors_config), Some(anchors_config)]);

lightning/src/ln/onion_route_tests.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ fn test_onion_failure() {
328328
// Channel::get_counterparty_htlc_minimum_msat().
329329
let mut node_2_cfg: UserConfig = test_default_channel_config();
330330
node_2_cfg.channel_handshake_config.our_htlc_minimum_msat = 2000;
331-
node_2_cfg.channel_handshake_config.announced_channel = true;
331+
node_2_cfg.channel_handshake_config.announce_for_forwarding = true;
332332
node_2_cfg.channel_handshake_limits.force_announced_channel_preference = false;
333333

334334
// When this test was written, the default base fee floated based on the HTLC count.
@@ -754,13 +754,13 @@ fn test_overshoot_final_cltv() {
754754
claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage);
755755
}
756756

757-
fn do_test_onion_failure_stale_channel_update(announced_channel: bool) {
757+
fn do_test_onion_failure_stale_channel_update(announce_for_forwarding: bool) {
758758
// Create a network of three nodes and two channels connecting them. We'll be updating the
759759
// HTLC relay policy of the second channel, causing forwarding failures at the first hop.
760760
let mut config = UserConfig::default();
761-
config.channel_handshake_config.announced_channel = announced_channel;
761+
config.channel_handshake_config.announce_for_forwarding = announce_for_forwarding;
762762
config.channel_handshake_limits.force_announced_channel_preference = false;
763-
config.accept_forwards_to_priv_channels = !announced_channel;
763+
config.accept_forwards_to_priv_channels = !announce_for_forwarding;
764764
config.channel_config.max_dust_htlc_exposure = MaxDustHTLCExposure::FeeRateMultiplier(5_000_000 / 253);
765765
let chanmon_cfgs = create_chanmon_cfgs(3);
766766
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -773,7 +773,7 @@ fn do_test_onion_failure_stale_channel_update(announced_channel: bool) {
773773
let other_channel = create_chan_between_nodes(
774774
&nodes[0], &nodes[1],
775775
);
776-
let channel_to_update = if announced_channel {
776+
let channel_to_update = if announce_for_forwarding {
777777
let channel = create_announced_chan_between_nodes(
778778
&nodes, 1, 2,
779779
);
@@ -790,7 +790,7 @@ fn do_test_onion_failure_stale_channel_update(announced_channel: bool) {
790790

791791
// A test payment should succeed as the ChannelConfig has not been changed yet.
792792
const PAYMENT_AMT: u64 = 40000;
793-
let (route, payment_hash, payment_preimage, payment_secret) = if announced_channel {
793+
let (route, payment_hash, payment_preimage, payment_secret) = if announce_for_forwarding {
794794
get_route_and_payment_hash!(nodes[0], nodes[2], PAYMENT_AMT)
795795
} else {
796796
let hop_hints = vec![RouteHint(vec![RouteHintHop {
@@ -833,12 +833,12 @@ fn do_test_onion_failure_stale_channel_update(announced_channel: bool) {
833833
}
834834
let new_update = match &events[0] {
835835
MessageSendEvent::BroadcastChannelUpdate { msg } => {
836-
assert!(announced_channel);
836+
assert!(announce_for_forwarding);
837837
msg.clone()
838838
},
839839
MessageSendEvent::SendChannelUpdate { node_id, msg } => {
840840
assert_eq!(node_id, channel_to_update_counterparty);
841-
assert!(!announced_channel);
841+
assert!(!announce_for_forwarding);
842842
msg.clone()
843843
},
844844
_ => panic!("expected Broadcast/SendChannelUpdate event"),
@@ -1505,7 +1505,7 @@ fn do_test_phantom_dust_exposure_failure(multiplier_dust_limit: bool) {
15051505
receiver_config.channel_config.max_dust_htlc_exposure =
15061506
if multiplier_dust_limit { MaxDustHTLCExposure::FeeRateMultiplier(2) }
15071507
else { MaxDustHTLCExposure::FixedLimitMsat(max_dust_exposure) };
1508-
receiver_config.channel_handshake_config.announced_channel = true;
1508+
receiver_config.channel_handshake_config.announce_for_forwarding = true;
15091509

15101510
let chanmon_cfgs = create_chanmon_cfgs(2);
15111511
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);

0 commit comments

Comments
 (0)