lnd: fix #1990 LND can't read .cookie file in Bitcoin datadir (Windows)
This commit is contained in:
parent
b1309277b9
commit
2030b506b1
19
config.go
19
config.go
@ -11,7 +11,6 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@ -1598,7 +1597,7 @@ func extractBitcoindRPCParams(networkName string,
|
||||
|
||||
// Next, we'll try to find an auth cookie. We need to detect the chain
|
||||
// by seeing if one is specified in the configuration file.
|
||||
dataDir := path.Dir(bitcoindConfigPath)
|
||||
dataDir := filepath.Dir(bitcoindConfigPath)
|
||||
dataDirRE, err := regexp.Compile(`(?m)^\s*datadir\s*=\s*([^\s]+)`)
|
||||
if err != nil {
|
||||
return "", "", "", "", err
|
||||
@ -1608,17 +1607,17 @@ func extractBitcoindRPCParams(networkName string,
|
||||
dataDir = string(dataDirSubmatches[1])
|
||||
}
|
||||
|
||||
chainDir := "/"
|
||||
chainDir := ""
|
||||
switch networkName {
|
||||
case "testnet3":
|
||||
chainDir = "/testnet3/"
|
||||
case "testnet4":
|
||||
chainDir = "/testnet4/"
|
||||
case "regtest":
|
||||
chainDir = "/regtest/"
|
||||
case "mainnet":
|
||||
chainDir = ""
|
||||
case "regtest", "testnet3":
|
||||
chainDir = networkName
|
||||
default:
|
||||
return "", "", "", "", fmt.Errorf("unexpected networkname %v", networkName)
|
||||
}
|
||||
|
||||
cookie, err := ioutil.ReadFile(dataDir + chainDir + ".cookie")
|
||||
cookie, err := ioutil.ReadFile(filepath.Join(dataDir, chainDir, ".cookie"))
|
||||
if err == nil {
|
||||
splitCookie := strings.Split(string(cookie), ":")
|
||||
if len(splitCookie) == 2 {
|
||||
|
Loading…
Reference in New Issue
Block a user