Merge pull request #916 from PWKad/master

Fix error labels when missing LTC configuration
This commit is contained in:
Olaoluwa Osuntokun 2018-03-23 18:45:47 -07:00 committed by GitHub
commit ead55783c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -861,20 +861,27 @@ func parseRPCParams(cConfig *chainConfig, nodeConfig interface{}, net chainCode,
if conf.RPCUser != "" && conf.RPCPass != "" { if conf.RPCUser != "" && conf.RPCPass != "" {
return nil return nil
} }
// Get the daemon name for displaying proper errors.
switch net {
case bitcoinChain:
daemonName = "btcd"
case litecoinChain:
daemonName = "ltcd"
}
// If only ONE of RPCUser or RPCPass is set, we assume the // If only ONE of RPCUser or RPCPass is set, we assume the
// user did that unintentionally. // user did that unintentionally.
if conf.RPCUser != "" || conf.RPCPass != "" { if conf.RPCUser != "" || conf.RPCPass != "" {
return fmt.Errorf("please set both or neither of " + return fmt.Errorf("please set both or neither of " +
"btcd.rpcuser and btcd.rpcpass") "%[1]v.rpcuser, %[1]v.rpcpass", daemonName)
} }
switch net { switch net {
case bitcoinChain: case bitcoinChain:
daemonName = "btcd"
confDir = conf.Dir confDir = conf.Dir
confFile = "btcd" confFile = "btcd"
case litecoinChain: case litecoinChain:
daemonName = "ltcd"
confDir = conf.Dir confDir = conf.Dir
confFile = "ltcd" confFile = "ltcd"
} }
@ -884,21 +891,27 @@ func parseRPCParams(cConfig *chainConfig, nodeConfig interface{}, net chainCode,
if conf.RPCUser != "" && conf.RPCPass != "" && conf.ZMQPath != "" { if conf.RPCUser != "" && conf.RPCPass != "" && conf.ZMQPath != "" {
return nil return nil
} }
// Get the daemon name for displaying proper errors.
switch net {
case bitcoinChain:
daemonName = "bitcoind"
case litecoinChain:
daemonName = "litecoind"
}
// If only one or two of the parameters are set, we assume the // If only one or two of the parameters are set, we assume the
// user did that unintentionally. // user did that unintentionally.
if conf.RPCUser != "" || conf.RPCPass != "" || conf.ZMQPath != "" { if conf.RPCUser != "" || conf.RPCPass != "" || conf.ZMQPath != "" {
return fmt.Errorf("please set all or none of " + return fmt.Errorf("please set all or none of " +
"bitcoind.rpcuser, bitcoind.rpcpass, and " + "%[1]v.rpcuser, %[1]v.rpcpass, " +
"bitcoind.zmqpath") "and %[1]v.zmqpath", daemonName)
} }
switch net { switch net {
case bitcoinChain: case bitcoinChain:
daemonName = "bitcoind"
confDir = conf.Dir confDir = conf.Dir
confFile = "bitcoin" confFile = "bitcoin"
case litecoinChain: case litecoinChain:
daemonName = "litecoind"
confDir = conf.Dir confDir = conf.Dir
confFile = "litecoin" confFile = "litecoin"
} }