config: update to satisfy linter

This commit is contained in:
Elle Mouton 2023-08-03 19:08:14 +02:00 committed by Olaoluwa Osuntokun
parent a7e723e570
commit 23a63ef328

View File

@ -228,6 +228,10 @@ const (
// BitcoinChainName is a string that represents the Bitcoin blockchain.
BitcoinChainName = "bitcoin"
bitcoindBackendName = "bitcoind"
btcdBackendName = "btcd"
neutrinoBackendName = "neutrino"
)
var (
@ -252,7 +256,7 @@ var (
defaultTLSKeyPath = filepath.Join(DefaultLndDir, defaultTLSKeyFilename)
defaultLetsEncryptDir = filepath.Join(DefaultLndDir, defaultLetsEncryptDirname)
defaultBtcdDir = btcutil.AppDataDir("btcd", false)
defaultBtcdDir = btcutil.AppDataDir(btcdBackendName, false)
defaultBtcdRPCCertFile = filepath.Join(defaultBtcdDir, "rpc.cert")
defaultBitcoindDir = btcutil.AppDataDir("bitcoin", false)
@ -546,7 +550,7 @@ func DefaultConfig() Config {
FeeRate: chainreg.DefaultBitcoinFeeRate,
TimeLockDelta: chainreg.DefaultBitcoinTimeLockDelta,
MaxLocalDelay: defaultMaxLocalCSVDelay,
Node: "btcd",
Node: btcdBackendName,
},
BtcdMode: &lncfg.Btcd{
Dir: defaultBtcdDir,
@ -936,26 +940,32 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
// any of the autopilot params.
if cfg.Autopilot.MaxChannels < 0 {
str := "autopilot.maxchannels must be non-negative"
return nil, mkErr(str)
}
if cfg.Autopilot.Allocation < 0 {
str := "autopilot.allocation must be non-negative"
return nil, mkErr(str)
}
if cfg.Autopilot.MinChannelSize < 0 {
str := "autopilot.minchansize must be non-negative"
return nil, mkErr(str)
}
if cfg.Autopilot.MaxChannelSize < 0 {
str := "autopilot.maxchansize must be non-negative"
return nil, mkErr(str)
}
if cfg.Autopilot.MinConfs < 0 {
str := "autopilot.minconfs must be non-negative"
return nil, mkErr(str)
}
if cfg.Autopilot.ConfTarget < 1 {
str := "autopilot.conftarget must be positive"
return nil, mkErr(str)
}
@ -1061,6 +1071,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
// host:port. This would lead to lnd not starting up properly.
if cfg.Tor.SOCKS == cfg.Tor.Control {
str := "tor.socks and tor.control can not us the same host:port"
return nil, mkErr(str)
}
@ -1196,6 +1207,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
str := "The mainnet, testnet, regtest, and simnet " +
"params can't be used together -- choose one " +
"of the four"
return nil, mkErr(str)
}
@ -1205,6 +1217,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
str := "either --bitcoin.mainnet, or bitcoin.testnet," +
"bitcoin.simnet, or bitcoin.regtest " +
"must be specified"
return nil, mkErr(str)
}
@ -1214,7 +1227,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
}
switch cfg.Bitcoin.Node {
case "btcd":
case btcdBackendName:
err := parseRPCParams(
cfg.Bitcoin, cfg.BtcdMode, cfg.ActiveNetParams,
)
@ -1222,7 +1235,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
return nil, mkErr("unable to load RPC "+
"credentials for btcd: %v", err)
}
case "bitcoind":
case bitcoindBackendName:
if cfg.Bitcoin.SimNet {
return nil, mkErr("bitcoind does not " +
"support simnet")
@ -1235,7 +1248,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
return nil, mkErr("unable to load RPC "+
"credentials for bitcoind: %v", err)
}
case "neutrino":
case neutrinoBackendName:
// No need to get RPC parameters.
case "nochainbackend":
@ -1245,6 +1258,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
default:
str := "only btcd, bitcoind, and neutrino mode " +
"supported for bitcoin at this time"
return nil, mkErr(str)
}
@ -1256,18 +1270,22 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
// any of the autopilot params.
if cfg.Autopilot.MaxChannels < 0 {
str := "autopilot.maxchannels must be non-negative"
return nil, mkErr(str)
}
if cfg.Autopilot.Allocation < 0 {
str := "autopilot.allocation must be non-negative"
return nil, mkErr(str)
}
if cfg.Autopilot.MinChannelSize < 0 {
str := "autopilot.minchansize must be non-negative"
return nil, mkErr(str)
}
if cfg.Autopilot.MaxChannelSize < 0 {
str := "autopilot.maxchansize must be non-negative"
return nil, mkErr(str)
}
@ -1757,9 +1775,9 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
}
// Set the daemon name for displaying proper errors.
daemonName = "btcd"
daemonName = btcdBackendName
confDir = conf.Dir
confFileBase = "btcd"
confFileBase = btcdBackendName
// If only ONE of RPCUser or RPCPass is set, we assume the
// user did that unintentionally.
@ -1790,7 +1808,7 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
}
// Set the daemon name for displaying proper errors.
daemonName = "bitcoind"
daemonName = bitcoindBackendName
confDir = conf.Dir
confFile = conf.ConfigPath
confFileBase = "bitcoin"
@ -1864,7 +1882,7 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
confFileBase))
}
switch cConfig.Node {
case "btcd":
case btcdBackendName:
nConf := nodeConfig.(*lncfg.Btcd)
rpcUser, rpcPass, err := extractBtcdRPCParams(confFile)
if err != nil {
@ -1873,7 +1891,7 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
}
nConf.RPCUser, nConf.RPCPass = rpcUser, rpcPass
case "bitcoind":
case bitcoindBackendName:
nConf := nodeConfig.(*lncfg.Bitcoind)
rpcUser, rpcPass, zmqBlockHost, zmqTxHost, err :=
extractBitcoindRPCParams(netParams.Params.Name,