Skip to content

Commit 912e44c

Browse files
f use clear_bits
1 parent 550fe7a commit 912e44c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

lightning/src/ln/channelmanager.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -2973,10 +2973,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
29732973
// addresses be sorted for future compatibility.
29742974
addresses.sort_by_key(|addr| addr.get_id());
29752975

2976-
let node_features = if self.advertise_onion_message_support.load(Ordering::Acquire) {
2977-
NodeFeatures::known() } else { NodeFeatures::known_without_onion_messages() };
2976+
let mut features = NodeFeatures::known();
2977+
if !self.advertise_onion_message_support.load(Ordering::Acquire) {
2978+
features = features.clear_onion_messages();
2979+
}
29782980
let announcement = msgs::UnsignedNodeAnnouncement {
2979-
features: node_features,
2981+
features,
29802982
timestamp: self.last_node_announcement_serial.fetch_add(1, Ordering::AcqRel) as u32,
29812983
node_id: self.get_our_node_id(),
29822984
rgb, alias, addresses,

lightning/src/ln/features.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,6 @@ impl InitFeatures {
550550
}
551551
}
552552

553-
impl NodeFeatures {
554-
pub(crate) fn known_without_onion_messages() -> Self {
555-
let mut features = Self::known();
556-
features.flags[4] &= 0b00111111;
557-
features
558-
}
559-
}
560-
561553
impl InvoiceFeatures {
562554
/// Converts `InvoiceFeatures` to `Features<C>`. Only known `InvoiceFeatures` relevant to
563555
/// context `C` are included in the result.
@@ -807,6 +799,13 @@ impl<T: sealed::Wumbo> Features<T> {
807799
}
808800
}
809801

802+
impl<T: sealed::OnionMessages> Features<T> {
803+
pub(crate) fn clear_onion_messages(mut self) -> Self {
804+
<T as sealed::OnionMessages>::clear_bits(&mut self.flags);
805+
self
806+
}
807+
}
808+
810809
macro_rules! impl_feature_len_prefixed_write {
811810
($features: ident) => {
812811
impl Writeable for $features {
@@ -921,8 +920,8 @@ mod tests {
921920
assert!(NodeFeatures::known().supports_onion_messages());
922921
assert!(!InitFeatures::known().requires_onion_messages());
923922
assert!(!NodeFeatures::known().requires_onion_messages());
924-
assert!(!NodeFeatures::known_without_onion_messages().supports_onion_messages());
925-
assert!(!NodeFeatures::known_without_onion_messages().requires_onion_messages());
923+
assert!(!InitFeatures::known().clear_onion_messages().supports_onion_messages());
924+
assert!(!NodeFeatures::known().clear_onion_messages().supports_onion_messages());
926925

927926
assert!(InitFeatures::known().supports_zero_conf());
928927
assert!(!InitFeatures::known().requires_zero_conf());

0 commit comments

Comments
 (0)