@@ -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
@@ -390,12 +409,15 @@ mod sealed {
390
409
define_feature ! ( 45 , ChannelType , [ InitContext , NodeContext ] ,
391
410
"Feature flags for `option_channel_type`." , set_channel_type_optional,
392
411
set_channel_type_required, supports_channel_type, requires_channel_type) ;
412
+ define_feature ! ( 49 , PaymentMetadata , [ InvoiceContext ] ,
413
+ "Feature flags for payment metadata in invoices." , set_payment_metadata_optional,
414
+ set_payment_metadata_required, supports_payment_metadata, requires_payment_metadata) ;
393
415
define_feature ! ( 55 , Keysend , [ NodeContext ] ,
394
416
"Feature flags for keysend payments." , set_keysend_optional, set_keysend_required,
395
417
supports_keysend, requires_keysend) ;
396
418
397
419
#[ cfg( test) ]
398
- define_feature ! ( 123456789 , UnknownFeature , [ NodeContext , ChannelContext , InvoiceContext ] ,
420
+ define_feature ! ( 123456789 , UnknownFeature , [ NodeContext , ChannelContext , InitContext ] ,
399
421
"Feature flags for an unknown feature used in testing." , set_unknown_feature_optional,
400
422
set_unknown_feature_required, supports_unknown_test_feature, requires_unknown_test_feature) ;
401
423
}
@@ -885,10 +907,10 @@ mod tests {
885
907
#[ test]
886
908
fn convert_to_context_with_unknown_flags ( ) {
887
909
// Ensure the `from` context has fewer known feature bytes than the `to` context.
888
- assert ! ( InvoiceFeatures :: known( ) . flags. len( ) < NodeFeatures :: known( ) . flags. len( ) ) ;
889
- let invoice_features = InvoiceFeatures :: known ( ) . set_unknown_feature_optional ( ) ;
890
- assert ! ( invoice_features . supports_unknown_bits( ) ) ;
891
- let node_features: NodeFeatures = invoice_features . to_context ( ) ;
910
+ assert ! ( InitFeatures :: known( ) . flags. len( ) < NodeFeatures :: known( ) . flags. len( ) ) ;
911
+ let init_features = InitFeatures :: known ( ) . set_unknown_feature_optional ( ) ;
912
+ assert ! ( init_features . supports_unknown_bits( ) ) ;
913
+ let node_features: NodeFeatures = init_features . to_context ( ) ;
892
914
assert ! ( !node_features. supports_unknown_bits( ) ) ;
893
915
}
894
916
0 commit comments