Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename instances of is_public to is_announced #3257

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ pub fn do_test<Out: Output>(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;
Expand Down Expand Up @@ -738,7 +738,7 @@ pub fn do_test<Out: Output>(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;
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub fn do_test<Out: test_logger::Output>(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),
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
26 changes: 13 additions & 13 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ impl<SP: Deref> ChannelContext<SP> 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);

Expand Down Expand Up @@ -1589,7 +1589,7 @@ impl<SP: Deref> ChannelContext<SP> 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()));
}
}
Expand Down Expand Up @@ -1689,7 +1689,7 @@ impl<SP: Deref> ChannelContext<SP> 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,
},

Expand Down Expand Up @@ -1921,7 +1921,7 @@ impl<SP: Deref> ChannelContext<SP> 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,
},

Expand Down Expand Up @@ -2066,7 +2066,7 @@ impl<SP: Deref> ChannelContext<SP> 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 {
Expand Down Expand Up @@ -6920,7 +6920,7 @@ impl<SP: Deref> Channel<SP> where
fn get_channel_announcement<NS: Deref>(
&self, node_signer: &NS, chain_hash: ChainHash, user_config: &UserConfig,
) -> Result<msgs::UnsignedChannelAnnouncement, ChannelError> 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() {
Expand Down Expand Up @@ -7778,7 +7778,7 @@ impl<SP: Deref> OutboundV1Channel<SP> 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(),
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -8317,7 +8317,7 @@ impl<SP: Deref> OutboundV2Channel<SP> 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(),
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions lightning/src/ln/channel_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Node<'b, 'c, 'd>>, 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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down Expand Up @@ -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)];
Expand Down Expand Up @@ -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);
Expand Down
Loading
Loading