config: cookie missing error fix

This commit is contained in:
ErikEk 2022-05-13 19:30:17 +02:00
parent 7106ea59db
commit fbf00f6e26
2 changed files with 14 additions and 4 deletions

View file

@ -2001,10 +2001,6 @@ func extractBitcoindRPCParams(networkName, bitcoindDataDir, bitcoindConfigPath,
return "", "", "", "", err
}
userSubmatches := rpcUserRegexp.FindSubmatch(configContents)
if userSubmatches == nil {
return "", "", "", "", fmt.Errorf("unable to find rpcuser in " +
"config")
}
// Similarly, we'll use another regular expression to find the set
// rpcpass (if any). If we can't find the pass, then we'll exit with an
@ -2014,6 +2010,18 @@ func extractBitcoindRPCParams(networkName, bitcoindDataDir, bitcoindConfigPath,
return "", "", "", "", err
}
passSubmatches := rpcPassRegexp.FindSubmatch(configContents)
// Exit with an error if the cookie file, is defined in config, and
// can not be found, with both rpcuser and rpcpassword undefined.
if rpcCookiePath != "" && userSubmatches == nil && passSubmatches == nil {
return "", "", "", "", fmt.Errorf("unable to open cookie file (%v)",
rpcCookiePath)
}
if userSubmatches == nil {
return "", "", "", "", fmt.Errorf("unable to find rpcuser in " +
"config")
}
if passSubmatches == nil {
return "", "", "", "", fmt.Errorf("unable to find rpcpassword " +
"in config")

View file

@ -258,6 +258,8 @@ from occurring that would result in an erroneous force close.](https://github.co
* [Some of the invoice update logic has been refactored to be less verbose.](https://github.com/lightningnetwork/lnd/pull/6415)
* [Clarify error msg when bitcoind cookie file is missing](https://github.com/lightningnetwork/lnd/pull/6536).
## RPC Server
* [Add value to the field