From 6972e5401db60604cbfb4ea65b805c69e61f2aa3 Mon Sep 17 00:00:00 2001 From: DarthBenro008 Date: Mon, 2 Aug 2021 23:41:03 +0530 Subject: [PATCH] feat: argument to disable automatic enable of wtclient Initially, the `--wtclient.active` had to be passed alongside `--watchtower.active` for lncli to be able to connect to the watchtower This commit inverts the functionality, now `wtclient` is automatically created, however if you do not want it it to create automatically, you can pass `--watchtower.deactivate` now instead. Signed-off-by: DarthBenro008 --- lncfg/wtclient.go | 4 ++-- lnd.go | 25 ++++++++++++++----------- server.go | 3 ++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lncfg/wtclient.go b/lncfg/wtclient.go index e755967813..ca00b60404 100644 --- a/lncfg/wtclient.go +++ b/lncfg/wtclient.go @@ -4,9 +4,9 @@ import "fmt" // WtClient holds the configuration options for the daemon's watchtower client. type WtClient struct { - // Active determines whether a watchtower client should be created to + // Deactivate determines whether a watchtower client should not be created to // back up channel states with registered watchtowers. - Active bool `long:"active" description:"Whether the daemon should use private watchtowers to back up revoked channel states."` + Deactivate bool `long:"deactivate" description:"Whether the daemon should not use private watchtowers to back up revoked channel states."` // PrivateTowerURIs specifies the lightning URIs of the towers the // watchtower client should send new backups to. diff --git a/lnd.go b/lnd.go index 1d0e67cade..80d5337eec 100644 --- a/lnd.go +++ b/lnd.go @@ -807,18 +807,21 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error lncfg.NormalizeNetwork(cfg.ActiveNetParams.Name), ) - // Initialise watchtower to be active, open the client database. - // This is done here so that Close always executes when lndMain returns. - towerClientDB, err = wtdb.OpenClientDB( - cfg.localDatabaseDir(), cfg.DB.Bolt.DBTimeout, - ) - if err != nil { - err := fmt.Errorf("unable to open watchtower client "+ - "database: %v", err) - ltndLog.Error(err) - return err + // Checking if we need watchtower client to be active + if !cfg.WtClient.Deactivate { + // Initialise watchtower client to be active, open the client database. + // This is done here so that Close always executes when lndMain returns. + towerClientDB, err = wtdb.OpenClientDB( + cfg.localDatabaseDir(), cfg.DB.Bolt.DBTimeout, + ) + if err != nil { + err := fmt.Errorf("unable to open watchtower client "+ + "database: %v", err) + ltndLog.Error(err) + return err + } + defer towerClientDB.Close() } - defer towerClientDB.Close() towerDB, err := wtdb.OpenTowerDB( towerDBDir, cfg.DB.Bolt.DBTimeout, diff --git a/server.go b/server.go index a2a993accb..7b022de5c9 100644 --- a/server.go +++ b/server.go @@ -1274,7 +1274,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr, FlapCountTicker: ticker.New(chanfitness.FlapCountFlushRate), }) - if cfg.Watchtower.Active { + // Checking if the watchtower client server needs to be created + if !cfg.WtClient.Deactivate { policy := wtpolicy.DefaultPolicy() if cfg.WtClient.SweepFeeRate != 0 {