Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing feature flag (bolt9) #24

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions lnp2p/src/bolt/bolt9.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,30 @@ pub enum Feature {
/// Anchor outputs
#[display("option_anchor_outputs", alt = "20/21")]
OptionAnchorOutputs = 20,

/// Anchor commitment type with zero fee HTLC transactions
#[display("option_anchors_zero_fee_htlc_tx", alt = "22/23")]
OptionAnchorZeroFeeHtlcTx = 22,

/// Future segwit versions allowed in shutdown
#[display("option_shutdown_anysegwit", alt = "26/27")]
OptionShutdownAnySegwit = 26,

/// Node supports the channel_type field in open/accept
#[display("option_channel_type", alt = "44/45")]
OptionChannelType = 44,

/// Supply channel aliases for routing
#[display("option_scid_alias", alt = "46/47")]
OptionScidAlias = 46,

/// Payment metadata in tlv record
#[display("option_payment_metadata", alt = "48/49")]
OptionPaymentMetadata = 48,

/// Understands zeroconf channel types
#[display("option_zeroconf", alt = "50/51")]
OptionZeroConf = 50,
// NB: When adding new feature INCLUDE it into Feature::all
}

Expand All @@ -180,6 +204,12 @@ impl Feature {
Feature::BasicMpp,
Feature::OptionSupportLargeChannel,
Feature::OptionAnchorOutputs,
Feature::OptionAnchorZeroFeeHtlcTx,
Feature::OptionShutdownAnySegwit,
Feature::OptionChannelType,
Feature::OptionScidAlias,
Feature::OptionPaymentMetadata,
Feature::OptionZeroConf,
]
}

Expand Down Expand Up @@ -244,6 +274,24 @@ impl FromStr for Feature {
s if s == Feature::OptionAnchorOutputs.to_string() => {
Feature::OptionAnchorOutputs
}
s if s == Feature::OptionAnchorZeroFeeHtlcTx.to_string() => {
Feature::OptionAnchorZeroFeeHtlcTx
}
s if s == Feature::OptionShutdownAnySegwit.to_string() => {
Feature::OptionShutdownAnySegwit
}
s if s == Feature::OptionChannelType.to_string() => {
Feature::OptionChannelType
}
s if s == Feature::OptionScidAlias.to_string() => {
Feature::OptionScidAlias
}
s if s == Feature::OptionPaymentMetadata.to_string() => {
Feature::OptionPaymentMetadata
}
s if s == Feature::OptionZeroConf.to_string() => {
Feature::OptionZeroConf
}
other => return Err(UnknownFeatureError(other.to_owned())),
};
Ok(feature)
Expand Down Expand Up @@ -341,6 +389,48 @@ pub struct InitFeatures {
)]
pub option_anchor_outputs: Option<bool>,

/// Anchor commitment type with zero fee HTLC transactions
#[cfg_attr(
feature = "serde",
serde(with = "As::<Option<DisplayFromStr>>")
)]
pub option_anchors_zero_fee_htlc_tx: Option<bool>,

/// Future segwit versions allowed in shutdown
#[cfg_attr(
feature = "serde",
serde(with = "As::<Option<DisplayFromStr>>")
)]
pub option_shutdown_anysegwit: Option<bool>,

/// Node supports the channel_type field in open/accept
#[cfg_attr(
feature = "serde",
serde(with = "As::<Option<DisplayFromStr>>")
)]
pub option_channel_type: Option<bool>,

/// Supply channel aliases for routing
#[cfg_attr(
feature = "serde",
serde(with = "As::<Option<DisplayFromStr>>")
)]
pub option_scid_alias: Option<bool>,

/// Payment metadata in tlv record
#[cfg_attr(
feature = "serde",
serde(with = "As::<Option<DisplayFromStr>>")
)]
pub option_payment_metadata: Option<bool>,

/// Understands zeroconf channel types
#[cfg_attr(
feature = "serde",
serde(with = "As::<Option<DisplayFromStr>>")
)]
pub option_zeroconf: Option<bool>,

/// Rest of feature flags which are unknown to the current implementation
#[cfg_attr(feature = "serde", serde(with = "As::<DisplayFromStr>"))]
pub unknown: FlagVec,
Expand Down Expand Up @@ -437,6 +527,24 @@ impl InitFeatures {
if let Some(required) = self.option_anchor_outputs {
map.insert(Feature::OptionAnchorOutputs, required);
}
if let Some(required) = self.option_anchors_zero_fee_htlc_tx {
map.insert(Feature::OptionAnchorZeroFeeHtlcTx, required);
}
if let Some(required) = self.option_shutdown_anysegwit {
map.insert(Feature::OptionShutdownAnySegwit, required);
}
if let Some(required) = self.option_channel_type {
map.insert(Feature::OptionChannelType, required);
}
if let Some(required) = self.option_scid_alias {
map.insert(Feature::OptionScidAlias, required);
}
if let Some(required) = self.option_payment_metadata {
map.insert(Feature::OptionPaymentMetadata, required);
}
if let Some(required) = self.option_zeroconf {
map.insert(Feature::OptionZeroConf, required);
}
map
}
}
Expand Down Expand Up @@ -478,6 +586,18 @@ impl TryFrom<FlagVec> for InitFeatures {
Feature::OptionSupportLargeChannel,
),
option_anchor_outputs: requirements(Feature::OptionAnchorOutputs),
option_anchors_zero_fee_htlc_tx: requirements(
Feature::OptionAnchorZeroFeeHtlcTx,
),
option_shutdown_anysegwit: requirements(
Feature::OptionShutdownAnySegwit,
),
option_channel_type: requirements(Feature::OptionChannelType),
option_scid_alias: requirements(Feature::OptionScidAlias),
option_payment_metadata: requirements(
Feature::OptionPaymentMetadata,
),
option_zeroconf: requirements(Feature::OptionZeroConf),
unknown: none!(),
};

Expand Down