Skip to content

Commit 760f187

Browse files
committed
Define the PaymentMetadata feature to be used in invoices
1 parent 6b230a5 commit 760f187

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

lightning/src/ln/features.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ mod sealed {
160160
VariableLengthOnion | PaymentSecret,
161161
// Byte 2
162162
BasicMPP,
163+
// Byte 3
164+
,
165+
// Byte 4
166+
,
167+
// Byte 5
168+
,
169+
// Byte 6
170+
PaymentMetadata,
163171
]);
164172
define_context!(OfferContext, []);
165173
define_context!(InvoiceRequestContext, []);
@@ -376,6 +384,9 @@ mod sealed {
376384
define_feature!(47, SCIDPrivacy, [InitContext, NodeContext, ChannelTypeContext],
377385
"Feature flags for only forwarding with SCID aliasing. Called `option_scid_alias` in the BOLTs",
378386
set_scid_privacy_optional, set_scid_privacy_required, supports_scid_privacy, requires_scid_privacy);
387+
define_feature!(49, PaymentMetadata, [InvoiceContext],
388+
"Feature flags for payment metadata in invoices.", set_payment_metadata_optional,
389+
set_payment_metadata_required, supports_payment_metadata, requires_payment_metadata);
379390
define_feature!(51, ZeroConf, [InitContext, NodeContext, ChannelTypeContext],
380391
"Feature flags for accepting channels with zero confirmations. Called `option_zeroconf` in the BOLTs",
381392
set_zero_conf_optional, set_zero_conf_required, supports_zero_conf, requires_zero_conf);
@@ -884,13 +895,13 @@ mod tests {
884895
#[test]
885896
fn convert_to_context_with_unknown_flags() {
886897
// Ensure the `from` context has fewer known feature bytes than the `to` context.
887-
assert!(<sealed::InvoiceContext as sealed::Context>::KNOWN_FEATURE_MASK.len() <
888-
<sealed::NodeContext as sealed::Context>::KNOWN_FEATURE_MASK.len());
889-
let mut invoice_features = InvoiceFeatures::empty();
890-
invoice_features.set_unknown_feature_optional();
891-
assert!(invoice_features.supports_unknown_bits());
892-
let node_features: NodeFeatures = invoice_features.to_context();
893-
assert!(!node_features.supports_unknown_bits());
898+
assert!(<sealed::ChannelContext as sealed::Context>::KNOWN_FEATURE_MASK.len() <
899+
<sealed::InvoiceContext as sealed::Context>::KNOWN_FEATURE_MASK.len());
900+
let mut channel_features = ChannelFeatures::empty();
901+
channel_features.set_unknown_feature_optional();
902+
assert!(channel_features.supports_unknown_bits());
903+
let invoice_features: InvoiceFeatures = channel_features.to_context_internal();
904+
assert!(!invoice_features.supports_unknown_bits());
894905
}
895906

896907
#[test]

0 commit comments

Comments
 (0)