Skip to content

Commit

Permalink
feat: argument to disable automatic enable of wtclient
Browse files Browse the repository at this point in the history
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 <hkpdev008@gmail.com>
  • Loading branch information
DarthBenro008 committed Aug 2, 2021
1 parent 4e60b8b commit 6972e54
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lncfg/wtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 14 additions & 11 deletions lnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6972e54

Please sign in to comment.