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:
5 files changed
+28
-5
No files matched your search
@@ -101,6 +101,9 @@ func (m *ClientDB) RemoveTower(pubKey *btcec.PublicKey, addr net.Addr) error {
|
||||
|
||||
if addr != nil {
|
||||
tower.RemoveAddress(addr)
|
||||
if len(tower.Addresses) == 0 {
|
||||
return wtdb.ErrLastTowerAddr
|
||||
}
|
||||
m.towers[tower.ID] = tower
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user