watchtowers: handle closable sessions

Add a routine to the tower client that informs towers of sessions they
can delete and also deletes any info about the session from the client
DB.
This commit is contained in:
Elle Mouton
2023-03-20 11:07:31 +02:00
parent 8478b56ce6
commit 26e628c0fe
5 changed files with 331 additions and 7 deletions

View File

@ -1497,6 +1497,11 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
policy.SweepFeeRate = sweepRateSatPerVByte.FeePerKWeight()
}
sessionCloseRange := uint32(wtclient.DefaultSessionCloseRange)
if cfg.WtClient.SessionCloseRange != 0 {
sessionCloseRange = cfg.WtClient.SessionCloseRange
}
if err := policy.Validate(); err != nil {
return nil, err
}
@ -1516,6 +1521,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
s.towerClient, err = wtclient.New(&wtclient.Config{
FetchClosedChannel: fetchClosedChannel,
SessionCloseRange: sessionCloseRange,
ChainNotifier: s.cc.ChainNotifier,
SubscribeChannelEvents: func() (subscribe.Subscription,
error) {
@ -1546,6 +1553,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
s.anchorTowerClient, err = wtclient.New(&wtclient.Config{
FetchClosedChannel: fetchClosedChannel,
SessionCloseRange: sessionCloseRange,
ChainNotifier: s.cc.ChainNotifier,
SubscribeChannelEvents: func() (subscribe.Subscription,
error) {