From 18240c676104110a12a8a398bb9f9fae3b8a78c3 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 2 May 2020 21:58:11 -0400 Subject: [PATCH] f Fix incorrect/early feature addition noted by Jeff (TODO: Tweak commit message) --- lightning/src/ln/features.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 4f263d475..ad8942326 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -97,7 +97,7 @@ mod sealed { // Byte 0 DataLossProtect | InitialRoutingSync | UpfrontShutdownScript, // Byte 1 - VariableLengthOnion | StaticRemoteKey | PaymentSecret, + VariableLengthOnion | PaymentSecret, // Byte 2 BasicMPP, ], @@ -115,7 +115,7 @@ mod sealed { // Byte 0 DataLossProtect | UpfrontShutdownScript, // Byte 1 - VariableLengthOnion | StaticRemoteKey | PaymentSecret, + VariableLengthOnion | PaymentSecret, // Byte 2 BasicMPP, ], @@ -476,6 +476,10 @@ impl Features { pub(crate) fn supports_static_remote_key(&self) -> bool { ::supports_feature(&self.flags) } + #[cfg(test)] + pub(crate) fn requires_static_remote_key(&self) -> bool { + ::requires_feature(&self.flags) + } } impl Features { @@ -563,6 +567,11 @@ mod tests { assert!(!InitFeatures::known().requires_variable_length_onion()); assert!(!NodeFeatures::known().requires_variable_length_onion()); + assert!(!InitFeatures::known().supports_static_remote_key()); + assert!(!NodeFeatures::known().supports_static_remote_key()); + assert!(!InitFeatures::known().requires_static_remote_key()); + assert!(!NodeFeatures::known().requires_static_remote_key()); + assert!(InitFeatures::known().supports_payment_secret()); assert!(NodeFeatures::known().supports_payment_secret()); assert!(!InitFeatures::known().requires_payment_secret()); @@ -608,11 +617,11 @@ mod tests { { // Check that the flags are as expected: // - option_data_loss_protect - // - var_onion_optin | static_remote_key | payment_secret + // - var_onion_optin | payment_secret // - basic_mpp assert_eq!(node_features.flags.len(), 3); assert_eq!(node_features.flags[0], 0b00000010); - assert_eq!(node_features.flags[1], 0b10100010); + assert_eq!(node_features.flags[1], 0b10000010); assert_eq!(node_features.flags[2], 0b00000010); } -- 2.39.5