@@ -2001,10 +2001,6 @@ func extractBitcoindRPCParams(networkName, bitcoindDataDir, bitcoindConfigPath,
2001
2001
return "" , "" , "" , "" , err
2002
2002
}
2003
2003
userSubmatches := rpcUserRegexp .FindSubmatch (configContents )
2004
- if userSubmatches == nil {
2005
- return "" , "" , "" , "" , fmt .Errorf ("unable to find rpcuser in " +
2006
- "config" )
2007
- }
2008
2004
2009
2005
// Similarly, we'll use another regular expression to find the set
2010
2006
// 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,
2014
2010
return "" , "" , "" , "" , err
2015
2011
}
2016
2012
passSubmatches := rpcPassRegexp .FindSubmatch (configContents )
2013
+
2014
+ // Exit with an error if the cookie file, is defined in config, and
2015
+ // can not be found, with both rpcuser and rpcpassword undefined.
2016
+ if rpcCookiePath != "" && userSubmatches == nil && passSubmatches == nil {
2017
+ return "" , "" , "" , "" , fmt .Errorf ("unable to open cookie file (%v)" ,
2018
+ rpcCookiePath )
2019
+ }
2020
+
2021
+ if userSubmatches == nil {
2022
+ return "" , "" , "" , "" , fmt .Errorf ("unable to find rpcuser in " +
2023
+ "config" )
2024
+ }
2017
2025
if passSubmatches == nil {
2018
2026
return "" , "" , "" , "" , fmt .Errorf ("unable to find rpcpassword " +
2019
2027
"in config" )
0 commit comments