From: Matt Corallo Date: Tue, 7 Jan 2020 02:50:55 +0000 (-0500) Subject: Avoid treating option_upfront_shutdown (req) as unknown_required. X-Git-Tag: v0.0.12~132^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=a3ddb9fb19f68584c1724328931afbef37e9f172;p=rust-lightning Avoid treating option_upfront_shutdown (req) as unknown_required. This fixes the bitmask in requires_unknown_bits. --- 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