From c1f24feb8be5bfd3d4de302309b9450bf624f7d5 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 13 Jun 2019 17:31:35 -0700 Subject: [PATCH] config: expose watchtower conf --- config.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config.go b/config.go index 2a775072..27a59988 100644 --- a/config.go +++ b/config.go @@ -40,6 +40,7 @@ const ( defaultDataDirname = "data" defaultChainSubDirname = "chain" defaultGraphSubDirname = "graph" + defaultTowerSubDirname = "watchtower" defaultTLSCertFilename = "tls.cert" defaultTLSKeyFilename = "tls.key" defaultAdminMacFilename = "admin.macaroon" @@ -133,6 +134,8 @@ var ( defaultDataDir = filepath.Join(defaultLndDir, defaultDataDirname) defaultLogDir = filepath.Join(defaultLndDir, defaultLogDirname) + defaultTowerDir = filepath.Join(defaultDataDir, defaultTowerSubDirname) + defaultTLSCertPath = filepath.Join(defaultLndDir, defaultTLSCertFilename) defaultTLSKeyPath = filepath.Join(defaultLndDir, defaultTLSKeyFilename) @@ -318,6 +321,8 @@ type config struct { Prometheus lncfg.Prometheus `group:"prometheus" namespace:"prometheus"` WtClient *lncfg.WtClient `group:"wtclient" namespace:"wtclient"` + + Watchtower *lncfg.Watchtower `group:"watchtower" namespace:"watchtower"` } // loadConfig initializes and parses the config using a config file and command @@ -413,6 +418,9 @@ func loadConfig() (*config, error) { ChannelCacheSize: channeldb.DefaultChannelCacheSize, }, Prometheus: lncfg.DefaultPrometheus(), + Watchtower: &lncfg.Watchtower{ + TowerDir: defaultTowerDir, + }, } // Pre-parse the command line options to pick up an alternative config @@ -473,6 +481,14 @@ func loadConfig() (*config, error) { cfg.TLSCertPath = filepath.Join(lndDir, defaultTLSCertFilename) cfg.TLSKeyPath = filepath.Join(lndDir, defaultTLSKeyFilename) cfg.LogDir = filepath.Join(lndDir, defaultLogDirname) + + // If the watchtower's directory is set to the default, i.e. the + // user has not requested a different location, we'll move the + // location to be relative to the specified lnd directory. + if cfg.Watchtower.TowerDir == defaultTowerDir { + cfg.Watchtower.TowerDir = + filepath.Join(cfg.DataDir, defaultTowerSubDirname) + } } // Create the lnd directory if it doesn't already exist. @@ -509,6 +525,7 @@ func loadConfig() (*config, error) { cfg.BitcoindMode.Dir = cleanAndExpandPath(cfg.BitcoindMode.Dir) cfg.LitecoindMode.Dir = cleanAndExpandPath(cfg.LitecoindMode.Dir) cfg.Tor.PrivateKeyPath = cleanAndExpandPath(cfg.Tor.PrivateKeyPath) + cfg.Watchtower.TowerDir = cleanAndExpandPath(cfg.Watchtower.TowerDir) // Ensure that the user didn't attempt to specify negative values for // any of the autopilot params.