From c2e5ba3b43b1f759a6b3c1430162cdba69e61b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corn=C3=A9=20Plooy?= Date: Tue, 27 Mar 2018 14:51:41 +0200 Subject: [PATCH] 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. --- config.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/config.go b/config.go index 005e08b8..6abfeaf8 100644 --- a/config.go +++ b/config.go @@ -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")