watchtower: prevent removal of last tower addr

This addresses a potential panic when a tower has one of its candidate
sessions chosen, but its only reachable address was removed by a
user-initiated RPC before the fact.
This commit is contained in:
Wilmer Paulino committed 2020-11-04 15:43:18 -08:00
1 parent 3ae46d81f4
commit d3157bcaf8
5 files changed
+28 -5

No files matched your search

+4 -1
View File
@@ -1124,7 +1124,10 @@ func (c *TowerClient) handleStaleTower(msg *staleTowerMsg) error {
if err := c.cfg.DB.RemoveTower(msg.pubKey, msg.addr); err != nil {
return err
}
c.candidateTowers.RemoveCandidate(tower.ID, msg.addr)
err = c.candidateTowers.RemoveCandidate(tower.ID, msg.addr)
if err != nil {
return err
}
// If an address was provided, then we're only meant to remove the
// address from the tower, so there's nothing left for us to do.