From 1bc25c1136c7c5a076f9078e5f0b29ab705af05f Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Mon, 18 Nov 2024 11:17:02 -0300 Subject: [PATCH] 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. --- config.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/config.go b/config.go index dc9a1453c..fa2575d28 100644 --- a/config.go +++ b/config.go @@ -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 {