From 6043113857fe7c0361f59547d21ef9dd73b95cc3 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 3 Aug 2021 09:57:31 +0200 Subject: [PATCH] config: make sure network dir is created The wallet and macaroon databases are the first files that are created for a new node. When initializing those databases, the parent directory is created if it does not exist. With both of the databases now potentially being remote, that code that creates the parent directory might never be executed and we need to do that manually when parsing the configuration. Otherwise we run into an error when we later try to create our default macaroons in that folder and it doesn't exist. --- config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config.go b/config.go index d80995a3c..33cd2e849 100644 --- a/config.go +++ b/config.go @@ -1228,6 +1228,12 @@ func ValidateConfig(cfg Config, usageMessage string, 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.