config: expose+validate private tower addr

This commit is contained in:
Conner Fromknecht 2019-06-13 17:29:28 -07:00
parent 5266f597fd
commit fb8214b808
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -32,6 +32,7 @@ import (
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing" "github.com/lightningnetwork/lnd/routing"
"github.com/lightningnetwork/lnd/tor" "github.com/lightningnetwork/lnd/tor"
"github.com/lightningnetwork/lnd/watchtower"
) )
const ( const (
@ -315,6 +316,8 @@ type config struct {
Caches *lncfg.Caches `group:"caches" namespace:"caches"` Caches *lncfg.Caches `group:"caches" namespace:"caches"`
Prometheus lncfg.Prometheus `group:"prometheus" namespace:"prometheus"` Prometheus lncfg.Prometheus `group:"prometheus" namespace:"prometheus"`
WtClient *lncfg.WtClient `group:"wtclient" namespace:"wtclient"`
} }
// loadConfig initializes and parses the config using a config file and command // loadConfig initializes and parses the config using a config file and command
@ -1051,15 +1054,27 @@ func loadConfig() (*config, error) {
"minbackoff") "minbackoff")
} }
// Validate the subconfigs for workers and caches. // Validate the subconfigs for workers, caches, and the tower client.
err = lncfg.Validate( err = lncfg.Validate(
cfg.Workers, cfg.Workers,
cfg.Caches, cfg.Caches,
cfg.WtClient,
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
// If the user provided private watchtower addresses, parse them to
// obtain the LN addresses.
if cfg.WtClient.IsActive() {
err := cfg.WtClient.ParsePrivateTowers(
watchtower.DefaultPeerPort, cfg.net.ResolveTCPAddr,
)
if err != nil {
return nil, err
}
}
// Finally, ensure that the user's color is correctly formatted, // Finally, ensure that the user's color is correctly formatted,
// otherwise the server will not be able to start after the unlocking // otherwise the server will not be able to start after the unlocking
// the wallet. // the wallet.