@@ -192,14 +192,33 @@ mod sealed {
192
192
VariableLengthOnion | PaymentSecret ,
193
193
// Byte 2
194
194
,
195
+ // Byte 3
196
+ ,
197
+ // Byte 4
198
+ ,
199
+ // Byte 5
200
+ ,
201
+ // Byte 6
202
+ ,
195
203
] ,
204
+ // Note that the optional feature bits set here are used to check if a bit is "known", but
205
+ // the `InvoiceBuilder` in lightning-invoice starts with `empty()` and does not set these
206
+ // bits unless the relevant data is included in the invoice.
196
207
optional_features: [
197
208
// Byte 0
198
209
,
199
210
// Byte 1
200
211
,
201
212
// Byte 2
202
213
BasicMPP ,
214
+ // Byte 3
215
+ ,
216
+ // Byte 4
217
+ ,
218
+ // Byte 5
219
+ ,
220
+ // Byte 6
221
+ PaymentMetadata ,
203
222
] ,
204
223
} ) ;
205
224
// This isn't a "real" feature context, and is only used in the channel_type field in an
@@ -402,13 +421,15 @@ mod sealed {
402
421
define_feature ! ( 47 , SCIDPrivacy , [ InitContext , NodeContext , ChannelTypeContext ] ,
403
422
"Feature flags for only forwarding with SCID aliasing. Called `option_scid_alias` in the BOLTs" ,
404
423
set_scid_privacy_optional, set_scid_privacy_required, supports_scid_privacy, requires_scid_privacy) ;
405
-
424
+ define_feature ! ( 49 , PaymentMetadata , [ InvoiceContext ] ,
425
+ "Feature flags for payment metadata in invoices." , set_payment_metadata_optional,
426
+ set_payment_metadata_required, supports_payment_metadata, requires_payment_metadata) ;
406
427
define_feature ! ( 55 , Keysend , [ NodeContext ] ,
407
428
"Feature flags for keysend payments." , set_keysend_optional, set_keysend_required,
408
429
supports_keysend, requires_keysend) ;
409
430
410
431
#[ cfg( test) ]
411
- define_feature ! ( 123456789 , UnknownFeature , [ NodeContext , ChannelContext , InvoiceContext ] ,
432
+ define_feature ! ( 123456789 , UnknownFeature , [ NodeContext , ChannelContext , InitContext ] ,
412
433
"Feature flags for an unknown feature used in testing." , set_unknown_feature_optional,
413
434
set_unknown_feature_required, supports_unknown_test_feature, requires_unknown_test_feature) ;
414
435
}
@@ -921,11 +942,11 @@ mod tests {
921
942
#[ test]
922
943
fn convert_to_context_with_unknown_flags ( ) {
923
944
// Ensure the `from` context has fewer known feature bytes than the `to` context.
924
- assert ! ( InvoiceFeatures :: known( ) . flags. len( ) < NodeFeatures :: known( ) . flags. len( ) ) ;
925
- let mut invoice_features = InvoiceFeatures :: known ( ) ;
926
- invoice_features . set_unknown_feature_optional ( ) ;
927
- assert ! ( invoice_features . supports_unknown_bits( ) ) ;
928
- let node_features: NodeFeatures = invoice_features . to_context ( ) ;
945
+ assert ! ( InitFeatures :: known( ) . flags. len( ) < NodeFeatures :: known( ) . flags. len( ) ) ;
946
+ let mut init_features = InitFeatures :: known ( ) ;
947
+ init_features . set_unknown_feature_optional ( ) ;
948
+ assert ! ( init_features . supports_unknown_bits( ) ) ;
949
+ let node_features: NodeFeatures = init_features . to_context ( ) ;
929
950
assert ! ( !node_features. supports_unknown_bits( ) ) ;
930
951
}
931
952
0 commit comments