mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 01:18:17 +02:00
Merge pull request #6736 from bitromortac/2207-independent-cookie
config: allow independent rpccookie config
This commit is contained in:
61
config.go
61
config.go
@@ -1794,6 +1794,47 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the daemon name for displaying proper errors.
|
||||||
|
switch net {
|
||||||
|
case chainreg.BitcoinChain:
|
||||||
|
daemonName = "bitcoind"
|
||||||
|
confDir = conf.Dir
|
||||||
|
confFile = conf.ConfigPath
|
||||||
|
confFileBase = "bitcoin"
|
||||||
|
case chainreg.LitecoinChain:
|
||||||
|
daemonName = "litecoind"
|
||||||
|
confDir = conf.Dir
|
||||||
|
confFile = conf.ConfigPath
|
||||||
|
confFileBase = "litecoin"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that cookie and credentials don't contradict each
|
||||||
|
// other.
|
||||||
|
if (conf.RPCUser != "" || conf.RPCPass != "") &&
|
||||||
|
conf.RPCCookie != "" {
|
||||||
|
|
||||||
|
return fmt.Errorf("please only provide either "+
|
||||||
|
"%[1]v.rpccookie or %[1]v.rpcuser and "+
|
||||||
|
"%[1]v.rpcpass", daemonName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// We convert the cookie into a user name and password.
|
||||||
|
if conf.RPCCookie != "" {
|
||||||
|
cookie, err := ioutil.ReadFile(conf.RPCCookie)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot read cookie file: %w",
|
||||||
|
err)
|
||||||
|
}
|
||||||
|
|
||||||
|
splitCookie := strings.Split(string(cookie), ":")
|
||||||
|
if len(splitCookie) != 2 {
|
||||||
|
return fmt.Errorf("cookie file has a wrong " +
|
||||||
|
"format")
|
||||||
|
}
|
||||||
|
conf.RPCUser = splitCookie[0]
|
||||||
|
conf.RPCPass = splitCookie[1]
|
||||||
|
}
|
||||||
|
|
||||||
if conf.RPCUser != "" && conf.RPCPass != "" {
|
if conf.RPCUser != "" && conf.RPCPass != "" {
|
||||||
// If all of RPCUser, RPCPass, ZMQBlockHost, and
|
// If all of RPCUser, RPCPass, ZMQBlockHost, and
|
||||||
// ZMQTxHost are set, we assume those parameters are
|
// ZMQTxHost are set, we assume those parameters are
|
||||||
@@ -1809,28 +1850,14 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the daemon name for displaying proper errors.
|
|
||||||
switch net {
|
|
||||||
case chainreg.BitcoinChain:
|
|
||||||
daemonName = "bitcoind"
|
|
||||||
confDir = conf.Dir
|
|
||||||
confFile = conf.ConfigPath
|
|
||||||
confFileBase = "bitcoin"
|
|
||||||
case chainreg.LitecoinChain:
|
|
||||||
daemonName = "litecoind"
|
|
||||||
confDir = conf.Dir
|
|
||||||
confFile = conf.ConfigPath
|
|
||||||
confFileBase = "litecoin"
|
|
||||||
}
|
|
||||||
|
|
||||||
// If not all of the parameters are set, we'll assume the user
|
// If not all of the parameters are set, we'll assume the user
|
||||||
// did this unintentionally.
|
// did this unintentionally.
|
||||||
if conf.RPCUser != "" || conf.RPCPass != "" ||
|
if conf.RPCUser != "" || conf.RPCPass != "" ||
|
||||||
conf.ZMQPubRawBlock != "" || conf.ZMQPubRawTx != "" {
|
conf.ZMQPubRawBlock != "" || conf.ZMQPubRawTx != "" {
|
||||||
|
|
||||||
return fmt.Errorf("please set all or none of "+
|
return fmt.Errorf("please set %[1]v.rpcuser and "+
|
||||||
"%[1]v.rpcuser, %[1]v.rpcpass, "+
|
"%[1]v.rpcpass (or %[1]v.rpccookie) together "+
|
||||||
"%[1]v.zmqpubrawblock, %[1]v.zmqpubrawtx",
|
"with %[1]v.zmqpubrawblock, %[1]v.zmqpubrawtx",
|
||||||
daemonName)
|
daemonName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -115,6 +115,9 @@
|
|||||||
* [Re-initialise registered middleware index lookup map after removal of a
|
* [Re-initialise registered middleware index lookup map after removal of a
|
||||||
registered middleware](https://github.com/lightningnetwork/lnd/pull/6739)
|
registered middleware](https://github.com/lightningnetwork/lnd/pull/6739)
|
||||||
|
|
||||||
|
* [Bitcoind cookie file path can be specified with zmq
|
||||||
|
options](https://github.com/lightningnetwork/lnd/pull/6736)
|
||||||
|
|
||||||
## Code Health
|
## Code Health
|
||||||
|
|
||||||
### Code cleanup, refactor, typo fixes
|
### Code cleanup, refactor, typo fixes
|
||||||
@@ -135,6 +138,7 @@
|
|||||||
|
|
||||||
# Contributors (Alphabetical Order)
|
# Contributors (Alphabetical Order)
|
||||||
|
|
||||||
|
* bitromortac
|
||||||
* Carsten Otto
|
* Carsten Otto
|
||||||
* Elle Mouton
|
* Elle Mouton
|
||||||
* ErikEk
|
* ErikEk
|
||||||
|
Reference in New Issue
Block a user