File tree 3 files changed +9
-2
lines changed
3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1052,7 +1052,9 @@ impl Invoice {
1052
1052
None if has_payment_secret => Err ( SemanticError :: InvalidFeatures ) ,
1053
1053
None => Ok ( ( ) ) ,
1054
1054
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 {
1056
1058
Ok ( ( ) )
1057
1059
} else if has_payment_secret {
1058
1060
Err ( SemanticError :: InvalidFeatures )
Original file line number Diff line number Diff line change @@ -154,6 +154,9 @@ fn deserialize() {
154
154
#[ test]
155
155
fn test_bolt_invaoid_invoices ( ) {
156
156
// Tests the BOLT 11 invalid invoice test vectors
157
+ assert_eq ! ( Invoice :: from_str(
158
+ "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqsqq40wa3khl49yue3zsgm26jrepqr2eghqlx86rttutve3ugd05em86nsefzh4pfurpd9ek9w2vp95zxqnfe2u7ckudyahsa52q66tgzcp6t2dyk"
159
+ ) , Err ( ParseOrSemanticError :: SemanticError ( SemanticError :: InvalidFeatures ) ) ) ;
157
160
assert_eq ! ( Invoice :: from_str(
158
161
"lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrnt"
159
162
) , 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> {
548
548
& self . flags
549
549
}
550
550
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 {
552
554
// Bitwise AND-ing with all even bits set except for known features will select required
553
555
// unknown features.
554
556
let byte_count = T :: KNOWN_FEATURE_MASK . len ( ) ;
You can’t perform that action at this time.
0 commit comments