diff --git a/config.go b/config.go index c4c70540..6666942c 100644 --- a/config.go +++ b/config.go @@ -740,8 +740,8 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser, } } - str := "Failed to create lnd directory: %v" - return mkErr(str, err) + str := "Failed to create lnd directory '%s': %v" + return mkErr(str, dir, err) } return nil @@ -809,24 +809,6 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser, cfg.WalletUnlockPasswordFile, ) - // Create the lnd directory and all other sub directories if they don't - // already exist. This makes sure that directory trees are also created - // for files that point to outside of the lnddir. - dirs := []string{ - lndDir, cfg.DataDir, - cfg.LetsEncryptDir, cfg.Watchtower.TowerDir, - filepath.Dir(cfg.TLSCertPath), filepath.Dir(cfg.TLSKeyPath), - filepath.Dir(cfg.AdminMacPath), filepath.Dir(cfg.ReadMacPath), - filepath.Dir(cfg.InvoiceMacPath), - filepath.Dir(cfg.Tor.PrivateKeyPath), - filepath.Dir(cfg.Tor.WatchtowerKeyPath), - } - for _, dir := range dirs { - if err := makeDirectory(dir); err != nil { - return nil, err - } - } - // Ensure that the user didn't attempt to specify negative values for // any of the autopilot params. if cfg.Autopilot.MaxChannels < 0 { @@ -1307,12 +1289,6 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser, lncfg.NormalizeNetwork(cfg.ActiveNetParams.Name), ) - // We need to make sure the default network directory exists for when we - // try to create our default macaroons there. - if err := makeDirectory(cfg.networkDir); err != nil { - return nil, err - } - // If a custom macaroon directory wasn't specified and the data // directory has changed from the default path, then we'll also update // the path for the macaroons to be generated. @@ -1332,6 +1308,24 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser, ) } + // Create the lnd directory and all other sub-directories if they don't + // already exist. This makes sure that directory trees are also created + // for files that point to outside the lnddir. + dirs := []string{ + lndDir, cfg.DataDir, cfg.networkDir, + cfg.LetsEncryptDir, cfg.Watchtower.TowerDir, + filepath.Dir(cfg.TLSCertPath), filepath.Dir(cfg.TLSKeyPath), + filepath.Dir(cfg.AdminMacPath), filepath.Dir(cfg.ReadMacPath), + filepath.Dir(cfg.InvoiceMacPath), + filepath.Dir(cfg.Tor.PrivateKeyPath), + filepath.Dir(cfg.Tor.WatchtowerKeyPath), + } + for _, dir := range dirs { + if err := makeDirectory(dir); err != nil { + return nil, err + } + } + // Similarly, if a custom back up file path wasn't specified, then // we'll update the file location to match our set network directory. if cfg.BackupFilePath == "" {