watchtowerrpc/standalone: implement watchtowerrpc.WatchtowerBackend iface
This commit is contained in:
parent
fa966a4901
commit
c06d71530a
@ -4,6 +4,7 @@ import (
|
||||
"net"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/lightningnetwork/lnd/brontide"
|
||||
"github.com/lightningnetwork/lnd/watchtower/lookout"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtserver"
|
||||
@ -20,6 +21,9 @@ type Standalone struct {
|
||||
|
||||
cfg *Config
|
||||
|
||||
// listeners is a reference to the wtserver's listeners.
|
||||
listeners []net.Listener
|
||||
|
||||
// server is the client endpoint, used for negotiating sessions and
|
||||
// uploading state updates.
|
||||
server wtserver.Interface
|
||||
@ -92,9 +96,10 @@ func New(cfg *Config) (*Standalone, error) {
|
||||
}
|
||||
|
||||
return &Standalone{
|
||||
cfg: cfg,
|
||||
server: server,
|
||||
lookout: lookout,
|
||||
cfg: cfg,
|
||||
listeners: listeners,
|
||||
server: server,
|
||||
lookout: lookout,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -136,3 +141,37 @@ func (w *Standalone) Stop() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// PubKey returns the public key for the watchtower used to authentication and
|
||||
// encrypt traffic with clients.
|
||||
//
|
||||
// NOTE: Part of the watchtowerrpc.WatchtowerBackend interface.
|
||||
func (w *Standalone) PubKey() *btcec.PublicKey {
|
||||
return w.cfg.NodePrivKey.PubKey()
|
||||
}
|
||||
|
||||
// ListeningAddrs returns the listening addresses where the watchtower server
|
||||
// can accept client connections.
|
||||
//
|
||||
// NOTE: Part of the watchtowerrpc.WatchtowerBackend interface.
|
||||
func (w *Standalone) ListeningAddrs() []net.Addr {
|
||||
addrs := make([]net.Addr, 0, len(w.listeners))
|
||||
for _, listener := range w.listeners {
|
||||
addrs = append(addrs, listener.Addr())
|
||||
}
|
||||
|
||||
return addrs
|
||||
}
|
||||
|
||||
// ExternalIPs returns the addresses where the watchtower can be reached by
|
||||
// clients externally.
|
||||
//
|
||||
// NOTE: Part of the watchtowerrpc.WatchtowerBackend interface.
|
||||
func (w *Standalone) ExternalIPs() []net.Addr {
|
||||
addrs := make([]net.Addr, 0, len(w.cfg.ExternalIPs))
|
||||
for _, addr := range w.cfg.ExternalIPs {
|
||||
addrs = append(addrs, addr)
|
||||
}
|
||||
|
||||
return addrs
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user