Skip to content

Commit 952697f

Browse files
committed
Define the PaymentMetadata feature to be used in invoices
1 parent f368f80 commit 952697f

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);
@@ -885,13 +896,13 @@ mod tests {
885896
#[test]
886897
fn convert_to_context_with_unknown_flags() {
887898
// Ensure the `from` context has fewer known feature bytes than the `to` context.
888-
assert!(<sealed::InvoiceContext as sealed::Context>::KNOWN_FEATURE_MASK.len() <
889-
<sealed::NodeContext as sealed::Context>::KNOWN_FEATURE_MASK.len());
890-
let mut invoice_features = InvoiceFeatures::empty();
891-
invoice_features.set_unknown_feature_optional();
892-
assert!(invoice_features.supports_unknown_bits());
893-
let node_features: NodeFeatures = invoice_features.to_context();
894-
assert!(!node_features.supports_unknown_bits());
899+
assert!(<sealed::ChannelContext as sealed::Context>::KNOWN_FEATURE_MASK.len() <
900+
<sealed::InvoiceContext as sealed::Context>::KNOWN_FEATURE_MASK.len());
901+
let mut channel_features = ChannelFeatures::empty();
902+
channel_features.set_unknown_feature_optional();
903+
assert!(channel_features.supports_unknown_bits());
904+
let invoice_features: InvoiceFeatures = channel_features.to_context_internal();
905+
assert!(!invoice_features.supports_unknown_bits());
895906
}
896907

897908
#[test]

0 commit comments

Comments
 (0)