File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1052,7 +1052,9 @@ impl Invoice {
10521052 None if has_payment_secret => Err ( SemanticError :: InvalidFeatures ) ,
10531053 None => Ok ( ( ) ) ,
10541054 Some ( TaggedField :: Features ( features) ) => {
1055- if features. supports_payment_secret ( ) && has_payment_secret {
1055+ if features. requires_unknown_bits ( ) {
1056+ Err ( SemanticError :: InvalidFeatures )
1057+ } else if features. supports_payment_secret ( ) && has_payment_secret {
10561058 Ok ( ( ) )
10571059 } else if has_payment_secret {
10581060 Err ( SemanticError :: InvalidFeatures )
Original file line number Diff line number Diff line change @@ -154,6 +154,9 @@ fn deserialize() {
154154#[ test]
155155fn test_bolt_invaoid_invoices ( ) {
156156 // Tests the BOLT 11 invalid invoice test vectors
157+ assert_eq ! ( Invoice :: from_str(
158+ "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqsqq40wa3khl49yue3zsgm26jrepqr2eghqlx86rttutve3ugd05em86nsefzh4pfurpd9ek9w2vp95zxqnfe2u7ckudyahsa52q66tgzcp6t2dyk"
159+ ) , Err ( ParseOrSemanticError :: SemanticError ( SemanticError :: InvalidFeatures ) ) ) ;
157160 assert_eq ! ( Invoice :: from_str(
158161 "lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrnt"
159162 ) , Err ( ParseOrSemanticError :: ParseError ( ParseError :: Bech32Error ( bech32:: Error :: InvalidChecksum ) ) ) ) ;
Original file line number Diff line number Diff line change @@ -548,7 +548,9 @@ impl<T: sealed::Context> Features<T> {
548548 & self . flags
549549 }
550550
551- pub ( crate ) fn requires_unknown_bits ( & self ) -> bool {
551+ /// Returns true if this `Features` object contains unknown feature flags which are set as
552+ /// "required".
553+ pub fn requires_unknown_bits ( & self ) -> bool {
552554 // Bitwise AND-ing with all even bits set except for known features will select required
553555 // unknown features.
554556 let byte_count = T :: KNOWN_FEATURE_MASK . len ( ) ;
You can’t perform that action at this time.
0 commit comments