From c815fb8de79777b5a220bb41981a020cb8a26222 Mon Sep 17 00:00:00 2001 From: eugene Date: Mon, 4 Apr 2022 15:22:26 -0400 Subject: [PATCH] server+lncfg: protocol flag to enable scid-alias, zero-conf feature bits This allows the zero-conf and scid-alias feature bits to be toggled using the config. The feature bits are off by default to protect users from accidentally incurring the risk of a zero-conf channel. --- lncfg/protocol.go | 19 +++++++++++++++++++ lncfg/protocol_rpctest.go | 19 +++++++++++++++++++ server.go | 2 ++ 3 files changed, 40 insertions(+) diff --git a/lncfg/protocol.go b/lncfg/protocol.go index 54ca3be99..0e1bd80d6 100644 --- a/lncfg/protocol.go +++ b/lncfg/protocol.go @@ -29,6 +29,15 @@ type ProtocolOptions struct { // opening or accepting channels having the script enforced commitment // type for leased channel. NoScriptEnforcedLease bool `long:"no-script-enforced-lease" description:"disable support for script enforced lease commitments"` + + // OptionScidAlias should be set if we want to signal the + // option-scid-alias feature bit. This allows scid aliases and the + // option-scid-alias channel-type. + OptionScidAlias bool `long:"option-scid-alias" description:"enable support for option_scid_alias channels"` + + // OptionZeroConf should be set if we want to signal the zero-conf + // feature bit. + OptionZeroConf bool `long:"zero-conf" description:"enable support for zero-conf channels, must have option-scid-alias set also"` } // Wumbo returns true if lnd should permit the creation and acceptance of wumbo @@ -48,3 +57,13 @@ func (l *ProtocolOptions) NoAnchorCommitments() bool { func (l *ProtocolOptions) NoScriptEnforcementLease() bool { return l.NoScriptEnforcedLease } + +// ScidAlias returns true if we have enabled the option-scid-alias feature bit. +func (l *ProtocolOptions) ScidAlias() bool { + return l.OptionScidAlias +} + +// ZeroConf returns true if we have enabled the zero-conf feature bit. +func (l *ProtocolOptions) ZeroConf() bool { + return l.OptionZeroConf +} diff --git a/lncfg/protocol_rpctest.go b/lncfg/protocol_rpctest.go index 25668c4c0..651e2606e 100644 --- a/lncfg/protocol_rpctest.go +++ b/lncfg/protocol_rpctest.go @@ -30,6 +30,15 @@ type ProtocolOptions struct { // // TODO: Move to experimental? ScriptEnforcedLease bool `long:"script-enforced-lease" description:"enable support for script enforced lease commitments"` + + // OptionScidAlias should be set if we want to signal the + // option-scid-alias feature bit. This allows scid aliases and the + // option-scid-alias channel-type. + OptionScidAlias bool `long:"option-scid-alias" description:"enable support for option_scid_alias channels"` + + // OptionZeroConf should be set if we want to signal the zero-conf + // feature bit. + OptionZeroConf bool `long:"zero-conf" description:"enable support for zero-conf channels, must have option-scid-alias set also"` } // Wumbo returns true if lnd should permit the creation and acceptance of wumbo @@ -49,3 +58,13 @@ func (l *ProtocolOptions) NoAnchorCommitments() bool { func (l *ProtocolOptions) NoScriptEnforcementLease() bool { return !l.ScriptEnforcedLease } + +// ScidAlias returns true if we have enabled the option-scid-alias feature bit. +func (l *ProtocolOptions) ScidAlias() bool { + return l.OptionScidAlias +} + +// ZeroConf returns true if we have enabled the zero-conf feature bit. +func (l *ProtocolOptions) ZeroConf() bool { + return l.OptionZeroConf +} diff --git a/server.go b/server.go index 90cf60444..e793e14fb 100644 --- a/server.go +++ b/server.go @@ -530,6 +530,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr, NoWumbo: !cfg.ProtocolOptions.Wumbo(), NoScriptEnforcementLease: cfg.ProtocolOptions.NoScriptEnforcementLease(), NoKeysend: !cfg.AcceptKeySend, + NoOptionScidAlias: !cfg.ProtocolOptions.ScidAlias(), + NoZeroConf: !cfg.ProtocolOptions.ZeroConf(), }) if err != nil { return nil, err