]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Avoid treating option_upfront_shutdown (req) as unknown_required.
authorMatt Corallo <git@bluematt.me>
Tue, 7 Jan 2020 02:50:55 +0000 (21:50 -0500)
committerMatt Corallo <git@bluematt.me>
Wed, 12 Feb 2020 22:13:50 +0000 (17:13 -0500)
This fixes the bitmask in requires_unknown_bits.

lightning/src/ln/features.rs

index dd0b7fa1a82aba540a259bd18ede2b5156c9eef1..4f45b9338c62c4e84c03e5223abcb248717e195e 100644 (file)
@@ -187,8 +187,14 @@ impl<T: sealed::Context> Features<T> {
        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<T: sealed::Context> Features<T> {
        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