From a3ddb9fb19f68584c1724328931afbef37e9f172 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 6 Jan 2020 21:50:55 -0500 Subject: [PATCH] Avoid treating option_upfront_shutdown (req) as unknown_required. This fixes the bitmask in requires_unknown_bits. --- lightning/src/ln/features.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index dd0b7fa1a..4f45b9338 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -187,8 +187,14 @@ impl Features { pub(crate) fn requires_unknown_bits(&self) -> bool { self.flags.iter().enumerate().any(|(idx, &byte)| { (match idx { - 0 => (byte & 0b00010100), + // Unknown bits are even bits which we don't understand, we list ones which we do + // here: + // unknown, upfront_shutdown_script, unknown (actually initial_routing_sync, but it + // is only valid as an optional feature), and data_loss_protect: + 0 => (byte & 0b01000100), + // unknown, unknown, unknown, var_onion_optin: 1 => (byte & 0b01010100), + // fallback, all even bits set: _ => (byte & 0b01010101), }) != 0 }) @@ -197,7 +203,10 @@ impl Features { pub(crate) fn supports_unknown_bits(&self) -> bool { self.flags.iter().enumerate().any(|(idx, &byte)| { (match idx { + // unknown, upfront_shutdown_script, initial_routing_sync (is only valid as an + // optional feature), and data_loss_protect: 0 => (byte & 0b11000100), + // unknown, unknown, unknown, var_onion_optin: 1 => (byte & 0b11111100), _ => byte, }) != 0 -- 2.39.5