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.
This commit is contained in:
Oliver Gugger 2021-08-03 09:57:31 +02:00
parent f7b17df452
commit 6043113857
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -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.