lnwire+feature: add feature bit for script enforced lease support

This commit is contained in:
Wilmer Paulino
2021-07-13 15:20:46 -07:00
committed by Olaoluwa Osuntokun
parent 35fd985118
commit 6052a446dc
5 changed files with 41 additions and 4 deletions

View File

@@ -64,4 +64,8 @@ var defaultSetDesc = setDesc{
SetInit: {}, // I SetInit: {}, // I
SetNodeAnn: {}, // N SetNodeAnn: {}, // N
}, },
lnwire.ScriptEnforcedLeaseOptional: {
SetInit: {}, // I
SetNodeAnn: {}, // N
},
} }

View File

@@ -65,6 +65,10 @@ var deps = depDesc{
lnwire.PaymentAddrOptional: {}, lnwire.PaymentAddrOptional: {},
}, },
lnwire.ExplicitChannelTypeOptional: {}, lnwire.ExplicitChannelTypeOptional: {},
lnwire.ScriptEnforcedLeaseOptional: {
lnwire.ExplicitChannelTypeOptional: {},
lnwire.AnchorsZeroFeeHtlcTxOptional: {},
},
} }
// ValidateDeps asserts that a feature vector sets all features and their // ValidateDeps asserts that a feature vector sets all features and their

View File

@@ -23,6 +23,10 @@ type Config struct {
// NoWumbo unsets any bits signalling support for wumbo channels. // NoWumbo unsets any bits signalling support for wumbo channels.
NoWumbo bool NoWumbo bool
// NoScriptEnforcementLease unsets any bits signaling support for script
// enforced leases.
NoScriptEnforcementLease bool
} }
// Manager is responsible for generating feature vectors for different requested // Manager is responsible for generating feature vectors for different requested
@@ -92,6 +96,10 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) {
raw.Unset(lnwire.WumboChannelsOptional) raw.Unset(lnwire.WumboChannelsOptional)
raw.Unset(lnwire.WumboChannelsRequired) raw.Unset(lnwire.WumboChannelsRequired)
} }
if cfg.NoScriptEnforcementLease {
raw.Unset(lnwire.ScriptEnforcedLeaseOptional)
raw.Unset(lnwire.ScriptEnforcedLeaseRequired)
}
// Ensure that all of our feature sets properly set any // Ensure that all of our feature sets properly set any
// dependent features. // dependent features.

View File

@@ -159,6 +159,24 @@ const (
// TODO: Decide on actual feature bit value. // TODO: Decide on actual feature bit value.
ExplicitChannelTypeOptional = 2021 ExplicitChannelTypeOptional = 2021
// ScriptEnforcedLeaseOptional is an optional feature bit that signals
// that the node requires channels having zero-fee second-level HTLC
// transactions, which also imply anchor commitments, along with an
// additional CLTV constraint of a channel lease's expiration height
// applied to all outputs that pay directly to the channel initiator.
//
// TODO: Decide on actual feature bit value.
ScriptEnforcedLeaseRequired FeatureBit = 2022
// ScriptEnforcedLeaseOptional is a required feature bit that signals
// that the node requires channels having zero-fee second-level HTLC
// transactions, which also imply anchor commitments, along with an
// additional CLTV constraint of a channel lease's expiration height
// applied to all outputs that pay directly to the channel initiator.
//
// TODO: Decide on actual feature bit value.
ScriptEnforcedLeaseOptional FeatureBit = 2023
// maxAllowedSize is a maximum allowed size of feature vector. // maxAllowedSize is a maximum allowed size of feature vector.
// //
// NOTE: Within the protocol, the maximum allowed message size is 65535 // NOTE: Within the protocol, the maximum allowed message size is 65535
@@ -206,6 +224,8 @@ var Features = map[FeatureBit]string{
AMPOptional: "amp", AMPOptional: "amp",
ExplicitChannelTypeOptional: "explicit-commitment-type", ExplicitChannelTypeOptional: "explicit-commitment-type",
ExplicitChannelTypeRequired: "explicit-commitment-type", ExplicitChannelTypeRequired: "explicit-commitment-type",
ScriptEnforcedLeaseRequired: "script-enforced-lease",
ScriptEnforcedLeaseOptional: "script-enforced-lease",
} }
// RawFeatureVector represents a set of feature bits as defined in BOLT-09. A // RawFeatureVector represents a set of feature bits as defined in BOLT-09. A

View File

@@ -516,10 +516,11 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
) )
featureMgr, err := feature.NewManager(feature.Config{ featureMgr, err := feature.NewManager(feature.Config{
NoTLVOnion: cfg.ProtocolOptions.LegacyOnion(), NoTLVOnion: cfg.ProtocolOptions.LegacyOnion(),
NoStaticRemoteKey: cfg.ProtocolOptions.NoStaticRemoteKey(), NoStaticRemoteKey: cfg.ProtocolOptions.NoStaticRemoteKey(),
NoAnchors: cfg.ProtocolOptions.NoAnchorCommitments(), NoAnchors: cfg.ProtocolOptions.NoAnchorCommitments(),
NoWumbo: !cfg.ProtocolOptions.Wumbo(), NoWumbo: !cfg.ProtocolOptions.Wumbo(),
NoScriptEnforcementLease: cfg.ProtocolOptions.NoScriptEnforcementLease(),
}) })
if err != nil { if err != nil {
return nil, err return nil, err