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:
parent
6c00de1865
commit
c2e5ba3b43
13
config.go
13
config.go
@ -1046,19 +1046,14 @@ 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
|
|
||||||
}
|
|
||||||
netSubmatches := netRE.FindSubmatch(configContents)
|
|
||||||
if netSubmatches != nil {
|
|
||||||
switch string(netSubmatches[1]) {
|
|
||||||
case "testnet":
|
|
||||||
chainDir = "/testnet3/"
|
chainDir = "/testnet3/"
|
||||||
|
case "testnet4":
|
||||||
|
chainDir = "/testnet4/"
|
||||||
case "regtest":
|
case "regtest":
|
||||||
chainDir = "/regtest/"
|
chainDir = "/regtest/"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
cookie, err := ioutil.ReadFile(dataDir + chainDir + ".cookie")
|
cookie, err := ioutil.ReadFile(dataDir + chainDir + ".cookie")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user