Merge pull request #2094 from cfromknecht/validate-color

config: validate node color after reading config
This commit is contained in:
Conner Fromknecht 2018-11-29 16:18:44 -08:00 committed by GitHub
commit 668bd4db33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -942,8 +942,8 @@ func loadConfig() (*config, error) {
}
}
// Finally, ensure that we are only listening on localhost if Tor
// inbound support is enabled.
// Ensure that we are only listening on localhost if Tor inbound support
// is enabled.
if cfg.Tor.V2 || cfg.Tor.V3 {
for _, addr := range cfg.Listeners {
if lncfg.IsLoopback(addr.String()) {
@ -956,6 +956,14 @@ func loadConfig() (*config, error) {
}
}
// Finally, ensure that the user's color is correctly formatted,
// otherwise the server will not be able to start after the unlocking
// the wallet.
_, err = parseHexColor(cfg.Color)
if err != nil {
return nil, fmt.Errorf("Unable to parse node color: %v", err)
}
// Warn about missing config file only after all other configuration is
// done. This prevents the warning on help messages and invalid
// options. Note this should go directly before the return.