lnd: support space characters surrounding = in bitcoind configuration files
lnd can't detect bitcoind configuration if the config file has spaces around the = character, e.g.: ``` zmqpubrawblock = tcp://127.0.0.1:28332 zmqpubrawtx = tcp://127.0.0.1:28332 rpcuser = rpcuser ``` I had to dig into the source code to understand what was wrong. This patch solves this problem, bitcoind's config parsing source code can be seen at https://github.com/bitcoin/bitcoin/blob/master/src/util.cpp
This commit is contained in:
1 parent
6be6b48e09
commit
5cb1a84356
1 file changed
+6
-6
@@ -976,7 +976,7 @@ func extractBtcdRPCParams(btcdConfigPath string) (string, string, error) {
|
|||||||
// Attempt to locate the RPC user using a regular expression. If we
|
// Attempt to locate the RPC user using a regular expression. If we
|
||||||
// don't have a match for our regular expression then we'll exit with
|
// don't have a match for our regular expression then we'll exit with
|
||||||
// an error.
|
// an error.
|
||||||
rpcUserRegexp, err := regexp.Compile(`(?m)^\s*rpcuser=([^\s]+)`)
|
rpcUserRegexp, err := regexp.Compile(`(?m)^\s*rpcuser\s*=\s*([^\s]+)`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
@@ -988,7 +988,7 @@ func extractBtcdRPCParams(btcdConfigPath string) (string, string, error) {
|
|||||||
// Similarly, we'll use another regular expression to find the set
|
// Similarly, we'll use another regular expression to find the set
|
||||||
// rpcpass (if any). If we can't find the pass, then we'll exit with an
|
// rpcpass (if any). If we can't find the pass, then we'll exit with an
|
||||||
// error.
|
// error.
|
||||||
rpcPassRegexp, err := regexp.Compile(`(?m)^\s*rpcpass=([^\s]+)`)
|
rpcPassRegexp, err := regexp.Compile(`(?m)^\s*rpcpass\s*=\s*([^\s]+)`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
@@ -1024,7 +1024,7 @@ func extractBitcoindRPCParams(bitcoindConfigPath string) (string, string, string
|
|||||||
|
|
||||||
// First, we look for the ZMQ path for raw blocks. If raw transactions
|
// First, we look for the ZMQ path for raw blocks. If raw transactions
|
||||||
// are sent over this interface, we can also get unconfirmed txs.
|
// are sent over this interface, we can also get unconfirmed txs.
|
||||||
zmqPathRE, err := regexp.Compile(`(?m)^\s*zmqpubrawblock=([^\s]+)`)
|
zmqPathRE, err := regexp.Compile(`(?m)^\s*zmqpubrawblock\s*=\s*([^\s]+)`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", "", err
|
return "", "", "", err
|
||||||
}
|
}
|
||||||
@@ -1036,7 +1036,7 @@ func extractBitcoindRPCParams(bitcoindConfigPath string) (string, string, string
|
|||||||
// Next, we'll try to find an auth cookie. We need to detect the chain
|
// 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.
|
// by seeing if one is specified in the configuration file.
|
||||||
dataDir := path.Dir(bitcoindConfigPath)
|
dataDir := path.Dir(bitcoindConfigPath)
|
||||||
dataDirRE, err := regexp.Compile(`(?m)^\s*datadir=([^\s]+)`)
|
dataDirRE, err := regexp.Compile(`(?m)^\s*datadir\s*=\s*([^\s]+)`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", "", err
|
return "", "", "", err
|
||||||
}
|
}
|
||||||
@@ -1067,7 +1067,7 @@ func extractBitcoindRPCParams(bitcoindConfigPath string) (string, string, string
|
|||||||
// We didn't find a cookie, so we attempt to locate the RPC user using
|
// We didn't find a cookie, so we attempt to locate the RPC user using
|
||||||
// a regular expression. If we don't have a match for our regular
|
// a regular expression. If we don't have a match for our regular
|
||||||
// expression then we'll exit with an error.
|
// expression then we'll exit with an error.
|
||||||
rpcUserRegexp, err := regexp.Compile(`(?m)^\s*rpcuser=([^\s]+)`)
|
rpcUserRegexp, err := regexp.Compile(`(?m)^\s*rpcuser\s*=\s*([^\s]+)`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", "", err
|
return "", "", "", err
|
||||||
}
|
}
|
||||||
@@ -1079,7 +1079,7 @@ func extractBitcoindRPCParams(bitcoindConfigPath string) (string, string, string
|
|||||||
// Similarly, we'll use another regular expression to find the set
|
// Similarly, we'll use another regular expression to find the set
|
||||||
// rpcpass (if any). If we can't find the pass, then we'll exit with an
|
// rpcpass (if any). If we can't find the pass, then we'll exit with an
|
||||||
// error.
|
// error.
|
||||||
rpcPassRegexp, err := regexp.Compile(`(?m)^\s*rpcpassword=([^\s]+)`)
|
rpcPassRegexp, err := regexp.Compile(`(?m)^\s*rpcpassword\s*=\s*([^\s]+)`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", "", err
|
return "", "", "", err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user