X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffeatures.rs;h=492cf5ccd198c2829b73b81ab4e5558b9cd14028;hb=288b93b3dada1f8b6f4a4359f0977d2a0c7c61fe;hp=a9f5a10ee2dad14395e18eda253cbaba2943106c;hpb=06ecbecd6d5944281bbe1f1407114af49eb293d3;p=rust-lightning diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index a9f5a10e..492cf5cc 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -124,6 +124,12 @@ mod sealed { , // Byte 3 , + // Byte 4 + , + // Byte 5 + , + // Byte 6 + , ], optional_features: [ // Byte 0 @@ -134,6 +140,12 @@ mod sealed { BasicMPP, // Byte 3 ShutdownAnySegwit, + // Byte 4 + , + // Byte 5 + , + // Byte 6 + Keysend, ], }); define_context!(ChannelContext { @@ -299,9 +311,11 @@ mod sealed { define_feature!(27, ShutdownAnySegwit, [InitContext, NodeContext], "Feature flags for `opt_shutdown_anysegwit`.", set_shutdown_any_segwit_optional, set_shutdown_any_segwit_required); + define_feature!(55, Keysend, [NodeContext], + "Feature flags for keysend payments.", set_keysend_optional, set_keysend_required); #[cfg(test)] - define_feature!(123456789, UnknownFeature, [NodeContext, ChannelContext], + define_feature!(123456789, UnknownFeature, [NodeContext, ChannelContext, InvoiceContext], "Feature flags for an unknown feature used in testing.", set_unknown_feature_optional, set_unknown_feature_required); } @@ -774,6 +788,16 @@ mod tests { assert!(!init_features.supports_gossip_queries()); } + #[test] + fn convert_to_context_with_unknown_flags() { + // Ensure the `from` context has fewer known feature bytes than the `to` context. + assert!(InvoiceFeatures::known().byte_count() < NodeFeatures::known().byte_count()); + let invoice_features = InvoiceFeatures::known().set_unknown_feature_optional(); + assert!(invoice_features.supports_unknown_bits()); + let node_features: NodeFeatures = invoice_features.to_context(); + assert!(!node_features.supports_unknown_bits()); + } + #[test] fn set_feature_bits() { let features = InvoiceFeatures::empty()