Skip to content

Commit 43b14cd

Browse files
committed
Define blinded hop features for use in BOLT 12
BOLT 12 invoices may contain blinded_payinfo for each hop in a blinded path. Each blinded_payinfo contains features, whose length must be encoded since there may be multiple hops. Note these features are also needed in the BOLT 4 encrypted_data_tlv stream. But since they are a single TLV record, the length must *not* be encoded there.
1 parent 7da955f commit 43b14cd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lightning/src/ln/features.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ mod sealed {
167167
// Byte 2
168168
BasicMPP,
169169
]);
170+
define_context!(BlindedHopContext, []);
170171
// This isn't a "real" feature context, and is only used in the channel_type field in an
171172
// `OpenChannel` message.
172173
define_context!(ChannelTypeContext, [
@@ -377,7 +378,7 @@ mod sealed {
377378

378379
#[cfg(test)]
379380
define_feature!(123456789, UnknownFeature,
380-
[NodeContext, ChannelContext, InvoiceContext, OfferContext, InvoiceRequestContext, Bolt12InvoiceContext],
381+
[NodeContext, ChannelContext, InvoiceContext, OfferContext, InvoiceRequestContext, Bolt12InvoiceContext, BlindedHopContext],
381382
"Feature flags for an unknown feature used in testing.", set_unknown_feature_optional,
382383
set_unknown_feature_required, supports_unknown_test_feature, requires_unknown_test_feature);
383384
}
@@ -442,6 +443,8 @@ pub type OfferFeatures = Features<sealed::OfferContext>;
442443
pub type InvoiceRequestFeatures = Features<sealed::InvoiceRequestContext>;
443444
/// Features used within an `invoice`.
444445
pub type Bolt12InvoiceFeatures = Features<sealed::Bolt12InvoiceContext>;
446+
/// Features used within BOLT 4 encrypted_data_tlv and BOLT 12 blinded_payinfo
447+
pub type BlindedHopFeatures = Features<sealed::BlindedHopContext>;
445448

446449
/// Features used within the channel_type field in an OpenChannel message.
447450
///
@@ -729,6 +732,7 @@ impl_feature_len_prefixed_write!(InitFeatures);
729732
impl_feature_len_prefixed_write!(ChannelFeatures);
730733
impl_feature_len_prefixed_write!(NodeFeatures);
731734
impl_feature_len_prefixed_write!(InvoiceFeatures);
735+
impl_feature_len_prefixed_write!(BlindedHopFeatures);
732736

733737
// Some features only appear inside of TLVs, so they don't have a length prefix when serialized.
734738
macro_rules! impl_feature_tlv_write {

0 commit comments

Comments
 (0)