config: fix "lnd --debuglevel show" command

Previously, "lnd --debuglevel show" complained that bitcoin backend is not
configured:

$ lnd --debuglevel show
failed to load config: ValidateConfig: either --bitcoin.mainnet, or ...

To make it working, the user had to specify --bitcoin.mainnet and configure one
of the backends, e.g. "--bitcoin.node neutrino".

With this fix, the command works without any additional flags.
This commit is contained in:
Boris Nagaev
2024-11-18 11:17:02 -03:00
parent 411ad1d9cd
commit 1bc25c1136

View File

@@ -860,6 +860,18 @@ func LoadConfig(interceptor signal.Interceptor) (*Config, error) {
func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
flagParser *flags.Parser) (*Config, error) {
// Special show command to list supported subsystems and exit.
if cfg.DebugLevel == "show" {
subLogMgr := build.NewSubLoggerManager()
// Initialize logging at the default logging level.
SetupLoggers(subLogMgr, interceptor)
fmt.Println("Supported subsystems",
subLogMgr.SupportedSubsystems())
os.Exit(0)
}
// If the provided lnd directory is not the default, we'll modify the
// path to all of the files and directories that will live within it.
lndDir := CleanAndExpandPath(cfg.LndDir)
@@ -1408,13 +1420,6 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
// Initialize logging at the default logging level.
SetupLoggers(cfg.SubLogMgr, interceptor)
// Special show command to list supported subsystems and exit.
if cfg.DebugLevel == "show" {
fmt.Println("Supported subsystems",
cfg.SubLogMgr.SupportedSubsystems())
os.Exit(0)
}
if cfg.MaxLogFiles != 0 {
if cfg.LogConfig.File.MaxLogFiles !=
build.DefaultMaxLogFiles {