mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 17:47:01 +02:00
watchtower: make use of the new AddressIterator
This commit upgrades the wtclient package to make use of the new `AddressIterator`. It does so by first creating new `Tower` and `ClientSession` types. The new `Tower` type has an `AddressIterator` instead of a list of addresses. The `ClientSession` type contains a `Tower`.
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"net"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
// TowerID is a unique 64-bit identifier allocated to each unique watchtower.
|
||||
@@ -77,23 +76,6 @@ func (t *Tower) RemoveAddress(addr net.Addr) {
|
||||
}
|
||||
}
|
||||
|
||||
// LNAddrs generates a list of lnwire.NetAddress from a Tower instance's
|
||||
// addresses. This can be used to have a client try multiple addresses for the
|
||||
// same Tower.
|
||||
//
|
||||
// NOTE: This method is NOT safe for concurrent use.
|
||||
func (t *Tower) LNAddrs() []*lnwire.NetAddress {
|
||||
addrs := make([]*lnwire.NetAddress, 0, len(t.Addresses))
|
||||
for _, addr := range t.Addresses {
|
||||
addrs = append(addrs, &lnwire.NetAddress{
|
||||
IdentityKey: t.IdentityKey,
|
||||
Address: addr,
|
||||
})
|
||||
}
|
||||
|
||||
return addrs
|
||||
}
|
||||
|
||||
// String returns a user-friendly identifier of the tower.
|
||||
func (t *Tower) String() string {
|
||||
pubKey := hex.EncodeToString(t.IdentityKey.SerializeCompressed())
|
||||
|
Reference in New Issue
Block a user