Skip to content

Commit caf0daa

Browse files
authored
Merge pull request #3257 from tnull/2024-08-fix-is-public
Rename instances of `is_public` to `is_announced`
2 parents 1122e82 + 5928063 commit caf0daa

15 files changed

+91
-91
lines changed

fuzz/src/chanmon_consistency.rs

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

696696
let mut config = UserConfig::default();
697697
config.channel_config.forwarding_fee_proportional_millionths = 0;
698-
config.channel_handshake_config.announced_channel = true;
698+
config.channel_handshake_config.announce_for_forwarding = true;
699699
if anchors {
700700
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
701701
config.manually_accept_inbound_channels = true;
@@ -740,7 +740,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
740740

741741
let mut config = UserConfig::default();
742742
config.channel_config.forwarding_fee_proportional_millionths = 0;
743-
config.channel_handshake_config.announced_channel = true;
743+
config.channel_handshake_config.announce_for_forwarding = true;
744744
if anchors {
745745
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
746746
config.manually_accept_inbound_channels = true;

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/events/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ pub enum Event {
13481348
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
13491349
channel_type: ChannelTypeFeatures,
13501350
/// True if this channel is (or will be) publicly-announced.
1351-
is_public: bool,
1351+
is_announced: bool,
13521352
/// Channel parameters given by the counterparty.
13531353
params: msgs::ChannelParameters,
13541354
},

lightning/src/ln/channel.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
15231523
SP::Target: SignerProvider,
15241524
{
15251525
let logger = WithContext::from(logger, Some(counterparty_node_id), Some(open_channel_fields.temporary_channel_id), None);
1526-
let announced_channel = if (open_channel_fields.channel_flags & 1) == 1 { true } else { false };
1526+
let announce_for_forwarding = if (open_channel_fields.channel_flags & 1) == 1 { true } else { false };
15271527

15281528
let channel_value_satoshis = our_funding_satoshis.saturating_add(open_channel_fields.funding_satoshis);
15291529

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

15991599
if config.channel_handshake_limits.force_announced_channel_preference {
1600-
if config.channel_handshake_config.announced_channel != announced_channel {
1600+
if config.channel_handshake_config.announce_for_forwarding != announce_for_forwarding {
16011601
return Err(ChannelError::close("Peer tried to open channel but their announcement preference is different from ours".to_owned()));
16021602
}
16031603
}
@@ -1697,7 +1697,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
16971697

16981698
config: LegacyChannelConfig {
16991699
options: config.channel_config.clone(),
1700-
announced_channel,
1700+
announce_for_forwarding,
17011701
commit_upfront_shutdown_pubkey: config.channel_handshake_config.commit_upfront_shutdown_pubkey,
17021702
},
17031703

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

19321932
config: LegacyChannelConfig {
19331933
options: config.channel_config.clone(),
1934-
announced_channel: config.channel_handshake_config.announced_channel,
1934+
announce_for_forwarding: config.channel_handshake_config.announce_for_forwarding,
19351935
commit_upfront_shutdown_pubkey: config.channel_handshake_config.commit_upfront_shutdown_pubkey,
19361936
},
19371937

@@ -2078,7 +2078,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
20782078
}
20792079

20802080
pub fn should_announce(&self) -> bool {
2081-
self.config.announced_channel
2081+
self.config.announce_for_forwarding
20822082
}
20832083

20842084
pub fn is_outbound(&self) -> bool {
@@ -6969,7 +6969,7 @@ impl<SP: Deref> Channel<SP> where
69696969
fn get_channel_announcement<NS: Deref>(
69706970
&self, node_signer: &NS, chain_hash: ChainHash, user_config: &UserConfig,
69716971
) -> Result<msgs::UnsignedChannelAnnouncement, ChannelError> where NS::Target: NodeSigner {
6972-
if !self.context.config.announced_channel {
6972+
if !self.context.config.announce_for_forwarding {
69736973
return Err(ChannelError::Ignore("Channel is not available for public announcements".to_owned()));
69746974
}
69756975
if !self.context.is_usable() {
@@ -7827,7 +7827,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
78277827
delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(),
78287828
htlc_basepoint: keys.htlc_basepoint.to_public_key(),
78297829
first_per_commitment_point,
7830-
channel_flags: if self.context.config.announced_channel {1} else {0},
7830+
channel_flags: if self.context.config.announce_for_forwarding {1} else {0},
78317831
shutdown_scriptpubkey: Some(match &self.context.shutdown_scriptpubkey {
78327832
Some(script) => script.clone().into_inner(),
78337833
None => Builder::new().into_script(),
@@ -7992,8 +7992,8 @@ pub(super) fn channel_type_from_open_channel(
79927992
if channel_type.requires_unknown_bits_from(&our_supported_features) {
79937993
return Err(ChannelError::close("Channel Type contains unsupported features".to_owned()));
79947994
}
7995-
let announced_channel = if (common_fields.channel_flags & 1) == 1 { true } else { false };
7996-
if channel_type.requires_scid_privacy() && announced_channel {
7995+
let announce_for_forwarding = if (common_fields.channel_flags & 1) == 1 { true } else { false };
7996+
if channel_type.requires_scid_privacy() && announce_for_forwarding {
79977997
return Err(ChannelError::close("SCID Alias/Privacy Channel Type cannot be set on a public channel".to_owned()));
79987998
}
79997999
Ok(channel_type.clone())
@@ -8366,7 +8366,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
83668366
delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(),
83678367
htlc_basepoint: keys.htlc_basepoint.to_public_key(),
83688368
first_per_commitment_point,
8369-
channel_flags: if self.context.config.announced_channel {1} else {0},
8369+
channel_flags: if self.context.config.announce_for_forwarding {1} else {0},
83708370
shutdown_scriptpubkey: Some(match &self.context.shutdown_scriptpubkey {
83718371
Some(script) => script.clone().into_inner(),
83728372
None => Builder::new().into_script(),
@@ -8545,7 +8545,7 @@ fn get_initial_channel_type(config: &UserConfig, their_features: &InitFeatures)
85458545
// available. If it's private, we first try `scid_privacy` as it provides better privacy
85468546
// with no other changes, and fall back to `only_static_remotekey`.
85478547
let mut ret = ChannelTypeFeatures::only_static_remote_key();
8548-
if !config.channel_handshake_config.announced_channel &&
8548+
if !config.channel_handshake_config.announce_for_forwarding &&
85498549
config.channel_handshake_config.negotiate_scid_privacy &&
85508550
their_features.supports_scid_privacy() {
85518551
ret.set_scid_privacy_required();
@@ -9017,7 +9017,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
90179017
// Read the old serialization of the ChannelConfig from version 0.0.98.
90189018
config.as_mut().unwrap().options.forwarding_fee_proportional_millionths = Readable::read(reader)?;
90199019
config.as_mut().unwrap().options.cltv_expiry_delta = Readable::read(reader)?;
9020-
config.as_mut().unwrap().announced_channel = Readable::read(reader)?;
9020+
config.as_mut().unwrap().announce_for_forwarding = Readable::read(reader)?;
90219021
config.as_mut().unwrap().commit_upfront_shutdown_pubkey = Readable::read(reader)?;
90229022
} else {
90239023
// Read the 8 bytes of backwards-compatibility ChannelConfig data.
@@ -10338,7 +10338,7 @@ mod tests {
1033810338

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

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/channelmanager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7432,14 +7432,14 @@ where
74327432
MsgHandleErrInternal::from_chan_no_close(e, msg.common_fields.temporary_channel_id)
74337433
)?;
74347434
let mut pending_events = self.pending_events.lock().unwrap();
7435-
let is_public = (msg.common_fields.channel_flags & 1) == 1;
7435+
let is_announced = (msg.common_fields.channel_flags & 1) == 1;
74367436
pending_events.push_back((events::Event::OpenChannelRequest {
74377437
temporary_channel_id: msg.common_fields.temporary_channel_id.clone(),
74387438
counterparty_node_id: counterparty_node_id.clone(),
74397439
funding_satoshis: msg.common_fields.funding_satoshis,
74407440
push_msat: msg.push_msat,
74417441
channel_type,
7442-
is_public,
7442+
is_announced,
74437443
params: msg.common_fields.channel_parameters(),
74447444
}, None));
74457445
peer_state.inbound_channel_request_by_id.insert(channel_id, InboundChannelRequest {

lightning/src/ln/functional_test_utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ pub fn create_announced_chan_between_nodes_with_value<'a, 'b, 'c: 'd, 'd>(nodes:
14371437

14381438
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) {
14391439
let mut no_announce_cfg = test_default_channel_config();
1440-
no_announce_cfg.channel_handshake_config.announced_channel = false;
1440+
no_announce_cfg.channel_handshake_config.announce_for_forwarding = false;
14411441
nodes[a].node.create_channel(nodes[b].node.get_our_node_id(), channel_value, push_msat, 42, None, Some(no_announce_cfg)).unwrap();
14421442
let open_channel = get_event_msg!(nodes[a], MessageSendEvent::SendOpenChannel, nodes[b].node.get_our_node_id());
14431443
nodes[b].node.handle_open_channel(&nodes[a].node.get_our_node_id(), &open_channel);
@@ -1481,7 +1481,7 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &
14811481
if chan.channel_id == as_channel_ready.channel_id {
14821482
assert!(!found_a);
14831483
found_a = true;
1484-
assert!(!chan.is_public);
1484+
assert!(!chan.is_announced);
14851485
}
14861486
}
14871487
assert!(found_a);
@@ -1491,7 +1491,7 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &
14911491
if chan.channel_id == as_channel_ready.channel_id {
14921492
assert!(!found_b);
14931493
found_b = true;
1494-
assert!(!chan.is_public);
1494+
assert!(!chan.is_announced);
14951495
}
14961496
}
14971497
assert!(found_b);
@@ -3224,7 +3224,7 @@ pub fn test_default_channel_config() -> UserConfig {
32243224
// Set cltv_expiry_delta slightly lower to keep the final CLTV values inside one byte in our
32253225
// tests so that our script-length checks don't fail (see ACCEPTED_HTLC_SCRIPT_WEIGHT).
32263226
default_config.channel_config.cltv_expiry_delta = MIN_CLTV_EXPIRY_DELTA;
3227-
default_config.channel_handshake_config.announced_channel = true;
3227+
default_config.channel_handshake_config.announce_for_forwarding = true;
32283228
default_config.channel_handshake_limits.force_announced_channel_preference = false;
32293229
// When most of our tests were written, the default HTLC minimum was fixed at 1000.
32303230
// 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);

0 commit comments

Comments
 (0)