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.
This commit is contained in:
eugene 2022-04-04 15:22:26 -04:00 committed by Olaoluwa Osuntokun
parent 113de58d77
commit c815fb8de7
3 changed files with 40 additions and 0 deletions

View File

@ -29,6 +29,15 @@ type ProtocolOptions struct {
// opening or accepting channels having the script enforced commitment // opening or accepting channels having the script enforced commitment
// type for leased channel. // type for leased channel.
NoScriptEnforcedLease bool `long:"no-script-enforced-lease" description:"disable support for script enforced lease commitments"` 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 // 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 { func (l *ProtocolOptions) NoScriptEnforcementLease() bool {
return l.NoScriptEnforcedLease 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
}

View File

@ -30,6 +30,15 @@ type ProtocolOptions struct {
// //
// TODO: Move to experimental? // TODO: Move to experimental?
ScriptEnforcedLease bool `long:"script-enforced-lease" description:"enable support for script enforced lease commitments"` 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 // 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 { func (l *ProtocolOptions) NoScriptEnforcementLease() bool {
return !l.ScriptEnforcedLease 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
}

View File

@ -530,6 +530,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
NoWumbo: !cfg.ProtocolOptions.Wumbo(), NoWumbo: !cfg.ProtocolOptions.Wumbo(),
NoScriptEnforcementLease: cfg.ProtocolOptions.NoScriptEnforcementLease(), NoScriptEnforcementLease: cfg.ProtocolOptions.NoScriptEnforcementLease(),
NoKeysend: !cfg.AcceptKeySend, NoKeysend: !cfg.AcceptKeySend,
NoOptionScidAlias: !cfg.ProtocolOptions.ScidAlias(),
NoZeroConf: !cfg.ProtocolOptions.ZeroConf(),
}) })
if err != nil { if err != nil {
return nil, err return nil, err