@@ -2001,10 +2001,6 @@ func extractBitcoindRPCParams(networkName, bitcoindDataDir, bitcoindConfigPath,
20012001 return "" , "" , "" , "" , err
20022002 }
20032003 userSubmatches := rpcUserRegexp .FindSubmatch (configContents )
2004- if userSubmatches == nil {
2005- return "" , "" , "" , "" , fmt .Errorf ("unable to find rpcuser in " +
2006- "config" )
2007- }
20082004
20092005 // Similarly, we'll use another regular expression to find the set
20102006 // 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,
20142010 return "" , "" , "" , "" , err
20152011 }
20162012 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+ }
20172025 if passSubmatches == nil {
20182026 return "" , "" , "" , "" , fmt .Errorf ("unable to find rpcpassword " +
20192027 "in config" )
0 commit comments