X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffeatures.rs;h=b372e6af6bf3df3fcf50a8c2ea3177c7f9989e07;hb=559ed20f92cb86b02094421fa51ad243dbf800b6;hp=4425a78e03f9ad406fe885e9f65d91a00d866115;hpb=b83e93c799b26fe1cb37e6a43a693e6ed66cdb59;p=rust-lightning diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 4425a78e..b372e6af 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -203,6 +203,12 @@ mod sealed { /// [`ODD_BIT`]: #associatedconstant.ODD_BIT const ASSERT_ODD_BIT_PARITY: usize; + /// Assertion that the bits are set in the context's [`KNOWN_FEATURE_MASK`]. + /// + /// [`KNOWN_FEATURE_MASK`]: Context::KNOWN_FEATURE_MASK + #[cfg(not(test))] // We violate this constraint with `UnknownFeature` + const ASSERT_BITS_IN_MASK: u8; + /// The byte where the feature is set. const BYTE_OFFSET: usize = Self::EVEN_BIT / 8; @@ -289,6 +295,12 @@ mod sealed { // ODD_BIT % 2 == 1 const ASSERT_ODD_BIT_PARITY: usize = (::ODD_BIT % 2) - 1; + + // (byte & (REQUIRED_MASK | OPTIONAL_MASK)) >> (EVEN_BIT % 8) == 3 + #[cfg(not(test))] // We violate this constraint with `UnknownFeature` + const ASSERT_BITS_IN_MASK: u8 = + ((<$context>::KNOWN_FEATURE_MASK[::BYTE_OFFSET] & (::REQUIRED_MASK | ::OPTIONAL_MASK)) + >> (::EVEN_BIT % 8)) - 3; } )* };