lncfg+config: only allow btcd or bitcoind backends

This commit is contained in:
Elle Mouton 2023-08-03 18:50:11 +02:00 committed by Olaoluwa Osuntokun
parent 913aa36fe9
commit 94c4642db6
2 changed files with 12 additions and 27 deletions

View file

@ -1767,17 +1767,10 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
return nil
}
// Get the daemon name for displaying proper errors.
switch net {
case chainreg.BitcoinChain:
// Set the daemon name for displaying proper errors.
daemonName = "btcd"
confDir = conf.Dir
confFileBase = "btcd"
case chainreg.LitecoinChain:
daemonName = "ltcd"
confDir = conf.Dir
confFileBase = "ltcd"
}
// If only ONE of RPCUser or RPCPass is set, we assume the
// user did that unintentionally.
@ -1807,19 +1800,11 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
}
}
// Get the daemon name for displaying proper errors.
switch net {
case chainreg.BitcoinChain:
// Set the daemon name for displaying proper errors.
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.
@ -1890,7 +1875,7 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
confFileBase))
}
switch cConfig.Node {
case "btcd", "ltcd":
case "btcd":
nConf := nodeConfig.(*lncfg.Btcd)
rpcUser, rpcPass, err := extractBtcdRPCParams(confFile)
if err != nil {
@ -1899,7 +1884,7 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
}
nConf.RPCUser, nConf.RPCPass = rpcUser, rpcPass
case "bitcoind", "litecoind":
case "bitcoind":
nConf := nodeConfig.(*lncfg.Bitcoind)
rpcUser, rpcPass, zmqBlockHost, zmqTxHost, err :=
extractBitcoindRPCParams(netParams.Params.Name,

View file

@ -13,7 +13,7 @@ type Chain struct {
Active bool `long:"active" description:"DEPRECATED: If the chain should be active or not. This field is now ignored since only the Bitcoin chain is supported"`
ChainDir string `long:"chaindir" description:"The directory to store the chain's data within."`
Node string `long:"node" description:"The blockchain interface to use." choice:"btcd" choice:"bitcoind" choice:"neutrino" choice:"ltcd" choice:"litecoind" choice:"nochainbackend"`
Node string `long:"node" description:"The blockchain interface to use." choice:"btcd" choice:"bitcoind" choice:"neutrino" choice:"nochainbackend"`
MainNet bool `long:"mainnet" description:"Use the main network"`
TestNet3 bool `long:"testnet" description:"Use the test network"`