config: determine the bitcoind chain directory from the chain params instead of the config file. This is more reliable in case the chain was selected with a bitcoind commandline option instead of a line in the config file.

This commit is contained in:
Corné Plooy 2018-03-27 14:51:41 +02:00 committed by Olaoluwa Osuntokun
parent 6c00de1865
commit c2e5ba3b43

@ -1046,18 +1046,13 @@ func extractBitcoindRPCParams(bitcoindConfigPath string) (string, string, string
} }
chainDir := "/" chainDir := "/"
netRE, err := regexp.Compile(`(?m)^\s*(testnet|regtest)=[\d]+`) switch activeNetParams.Params.Name {
if err != nil { case "testnet3":
return "", "", "", err chainDir = "/testnet3/"
} case "testnet4":
netSubmatches := netRE.FindSubmatch(configContents) chainDir = "/testnet4/"
if netSubmatches != nil { case "regtest":
switch string(netSubmatches[1]) { chainDir = "/regtest/"
case "testnet":
chainDir = "/testnet3/"
case "regtest":
chainDir = "/regtest/"
}
} }
cookie, err := ioutil.ReadFile(dataDir + chainDir + ".cookie") cookie, err := ioutil.ReadFile(dataDir + chainDir + ".cookie")