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 := "/"
netRE, err := regexp.Compile(`(?m)^\s*(testnet|regtest)=[\d]+`)
if err != nil {
return "", "", "", err
}
netSubmatches := netRE.FindSubmatch(configContents)
if netSubmatches != nil {
switch string(netSubmatches[1]) {
case "testnet":
chainDir = "/testnet3/"
case "regtest":
chainDir = "/regtest/"
}
switch activeNetParams.Params.Name {
case "testnet3":
chainDir = "/testnet3/"
case "testnet4":
chainDir = "/testnet4/"
case "regtest":
chainDir = "/regtest/"
}
cookie, err := ioutil.ReadFile(dataDir + chainDir + ".cookie")