Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wtclient: automatically initialise while creating a watchtower server #5596

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ const (
// defaultCoinSelectionStrategy is the coin selection strategy that is
// used by default to fund transactions.
defaultCoinSelectionStrategy = "largest"

// defaultWatchTowerClientStartup sets the watchTower client to start
// automatically along with lnd
defaultWatchTowerClientStartup = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultWatchTowerClientStartup -> deafultWtClientActive?

)

var (
Expand Down Expand Up @@ -555,6 +559,9 @@ func DefaultConfig() Config {
ChannelCommitInterval: defaultChannelCommitInterval,
ChannelCommitBatchSize: defaultChannelCommitBatchSize,
CoinSelectionStrategy: defaultCoinSelectionStrategy,
WtClient: &lncfg.WtClient{
Active: defaultWatchTowerClientStartup,
},
}
}

Expand Down
33 changes: 18 additions & 15 deletions lnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ func initializeDatabases(ctx context.Context,
cfg.Watchtower.TowerDir,
cfg.registeredChains.PrimaryChain().String(),
lncfg.NormalizeNetwork(cfg.ActiveNetParams.Name),
), cfg.WtClient.Active, cfg.Watchtower.Active,
), !cfg.WtClient.Deactivate, cfg.Watchtower.Active,
)
if err != nil {
return nil, nil, fmt.Errorf("unable to obtain database "+
Expand Down Expand Up @@ -1662,23 +1662,26 @@ func initializeDatabases(ctx context.Context,
// using the same struct (and DB backend) instance.
dbs.chanStateDB = dbs.graphDB

// Wrap the watchtower client DB and make sure we clean up.
if cfg.WtClient.Active {
dbs.towerClientDB, err = wtdb.OpenClientDB(
databaseBackends.TowerClientDB,
)
if err != nil {
cleanUp()
// Wrap the watchtower server DB and make sure we clean up.
if cfg.Watchtower.Active {

err := fmt.Errorf("unable to open %s database: %v",
lncfg.NSTowerClientDB, err)
ltndLog.Error(err)
return nil, nil, err
// Checking if we need watchtower client to be active or has deactivate been passed
if !cfg.WtClient.Deactivate {
// Initialise watchtower client to be active, open the client database.
// Wrap the watchtower client DB and make sure we clean up.
dbs.towerClientDB, err = wtdb.OpenClientDB(
databaseBackends.TowerClientDB,
)
if err != nil {
cleanUp()

err := fmt.Errorf("unable to open %s database: %v",
lncfg.NSTowerClientDB, err)
ltndLog.Error(err)
return nil, nil, err
}
}
}

// Wrap the watchtower server DB and make sure we clean up.
if cfg.Watchtower.Active {
dbs.towerServerDB, err = wtdb.OpenTowerDB(
databaseBackends.TowerServerDB,
)
Expand Down
3 changes: 2 additions & 1 deletion sample-lnd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,8 @@ litecoin.node=ltcd
; specified in sat/byte, the default is 10 sat/byte.
; wtclient.sweep-fee-rate=10

; (Deprecated) Activate Watchtower Client. To get more information or configure watchtowers
; (Deprecated) Activate Watchtower Client. To get more information or configure
; watchtowers
; run `lncli wtclient -h`.
; wtclient.active=true

Expand Down
3 changes: 2 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
FlapCountTicker: ticker.New(chanfitness.FlapCountFlushRate),
})

if cfg.WtClient.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