Skip to content

Commit

Permalink
Define blinded hop features for use in BOLT 12
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jkczyz committed Jan 6, 2023
1 parent d985ced commit b50fc4e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lightning/src/ln/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ mod sealed {
// Byte 2
BasicMPP,
]);
define_context!(BlindedHopContext, []);
// This isn't a "real" feature context, and is only used in the channel_type field in an
// `OpenChannel` message.
define_context!(ChannelTypeContext, [
Expand Down Expand Up @@ -377,7 +378,7 @@ mod sealed {

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

/// Features used within the channel_type field in an OpenChannel message.
///
Expand Down Expand Up @@ -729,6 +732,7 @@ impl_feature_len_prefixed_write!(InitFeatures);
impl_feature_len_prefixed_write!(ChannelFeatures);
impl_feature_len_prefixed_write!(NodeFeatures);
impl_feature_len_prefixed_write!(InvoiceFeatures);
impl_feature_len_prefixed_write!(BlindedHopFeatures);

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

0 comments on commit b50fc4e

Please sign in to comment.