watchtower: handle channel closures

Add a channel-close handler that waits for channel close events and
marks channels as closed in the tower client DB.
This commit is contained in:
Elle Mouton committed 2023-03-20 16:51:25 +02:00
1 parent 41e36c7ec7
commit 16008c0032
3 files changed
+483 -86

No files matched your search

+16
View File
@@ -1512,7 +1512,16 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
)
}
fetchClosedChannel := s.chanStateDB.FetchClosedChannelForID
s.towerClient, err = wtclient.New(&wtclient.Config{
FetchClosedChannel: fetchClosedChannel,
SubscribeChannelEvents: func() (subscribe.Subscription,
error) {
return s.channelNotifier.
SubscribeChannelEvents()
},
Signer: cc.Wallet.Cfg.Signer,
NewAddress: newSweepPkScriptGen(cc.Wallet),
SecretKeyRing: s.cc.KeyRing,
@@ -1536,6 +1545,13 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
blob.Type(blob.FlagAnchorChannel)
s.anchorTowerClient, err = wtclient.New(&wtclient.Config{
FetchClosedChannel: fetchClosedChannel,
SubscribeChannelEvents: func() (subscribe.Subscription,
error) {
return s.channelNotifier.
SubscribeChannelEvents()
},
Signer: cc.Wallet.Cfg.Signer,
NewAddress: newSweepPkScriptGen(cc.Wallet),
SecretKeyRing: s.cc.KeyRing,