multi: only allow specifying towers to TowerClient through RPC
With the introduction of the WatchtowerClient RPC subserver, the lnd configuration flag to specify private watchtowers for the client is no longer needed and can lead to confusion upon users. Therefore, we remove the flag completely, and only rely on the watchtower client being active through a new --wtclient.active flag.
This commit is contained in:
7 files changed
+49
-76
No files matched your search
@@ -141,10 +141,6 @@ type Config struct {
|
||||
// new sessions will be requested immediately.
|
||||
Policy wtpolicy.Policy
|
||||
|
||||
// PrivateTower is the net address of a private tower. The client will
|
||||
// try to create all sessions with this tower.
|
||||
PrivateTower *lnwire.NetAddress
|
||||
|
||||
// ChainHash identifies the chain that the client is on and for which
|
||||
// the tower must be watching to monitor for breaches.
|
||||
ChainHash chainhash.Hash
|
||||
@@ -266,13 +262,6 @@ func New(config *Config) (*TowerClient, error) {
|
||||
cfg.WriteTimeout = DefaultWriteTimeout
|
||||
}
|
||||
|
||||
// Record the tower in our database, also loading any addresses
|
||||
// previously associated with its public key.
|
||||
tower, err := cfg.DB.CreateTower(cfg.PrivateTower)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Next, load all candidate sessions and towers from the database into
|
||||
// the client. We will use any of these session if their policies match
|
||||
// the current policy of the client, otherwise they will be ignored and
|
||||
|
||||
@@ -26,7 +26,11 @@ import (
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtserver"
|
||||
)
|
||||
|
||||
const csvDelay uint32 = 144
|
||||
const (
|
||||
csvDelay uint32 = 144
|
||||
|
||||
towerAddrStr = "18.28.243.2:9911"
|
||||
)
|
||||
|
||||
var (
|
||||
revPrivBytes = []byte{
|
||||
@@ -387,7 +391,6 @@ type harnessCfg struct {
|
||||
}
|
||||
|
||||
func newHarness(t *testing.T, cfg harnessCfg) *testHarness {
|
||||
towerAddrStr := "18.28.243.2:9911"
|
||||
towerTCPAddr, err := net.ResolveTCPAddr("tcp", towerAddrStr)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to resolve tower TCP addr: %v", err)
|
||||
@@ -412,6 +415,7 @@ func newHarness(t *testing.T, cfg harnessCfg) *testHarness {
|
||||
DB: serverDB,
|
||||
ReadTimeout: timeout,
|
||||
WriteTimeout: timeout,
|
||||
NodePrivKey: privKey,
|
||||
NewAddress: func() (btcutil.Address, error) {
|
||||
return addr, nil
|
||||
},
|
||||
@@ -435,7 +439,6 @@ func newHarness(t *testing.T, cfg harnessCfg) *testHarness {
|
||||
DB: clientDB,
|
||||
AuthDial: mockNet.AuthDial,
|
||||
SecretKeyRing: wtmock.NewSecretKeyRing(),
|
||||
PrivateTower: towerAddr,
|
||||
Policy: cfg.policy,
|
||||
NewAddress: func() ([]byte, error) {
|
||||
return addrScript, nil
|
||||
@@ -458,6 +461,10 @@ func newHarness(t *testing.T, cfg harnessCfg) *testHarness {
|
||||
server.Stop()
|
||||
t.Fatalf("Unable to start wtclient: %v", err)
|
||||
}
|
||||
if err := client.AddTower(towerAddr); err != nil {
|
||||
server.Stop()
|
||||
t.Fatalf("Unable to add tower to wtclient: %v", err)
|
||||
}
|
||||
|
||||
h := &testHarness{
|
||||
t: t,
|
||||
@@ -505,7 +512,15 @@ func (h *testHarness) startServer() {
|
||||
func (h *testHarness) startClient() {
|
||||
h.t.Helper()
|
||||
|
||||
var err error
|
||||
towerTCPAddr, err := net.ResolveTCPAddr("tcp", towerAddrStr)
|
||||
if err != nil {
|
||||
h.t.Fatalf("Unable to resolve tower TCP addr: %v", err)
|
||||
}
|
||||
towerAddr := &lnwire.NetAddress{
|
||||
IdentityKey: h.serverCfg.NodePrivKey.PubKey(),
|
||||
Address: towerTCPAddr,
|
||||
}
|
||||
|
||||
h.client, err = wtclient.New(h.clientCfg)
|
||||
if err != nil {
|
||||
h.t.Fatalf("unable to create wtclient: %v", err)
|
||||
@@ -513,6 +528,9 @@ func (h *testHarness) startClient() {
|
||||
if err := h.client.Start(); err != nil {
|
||||
h.t.Fatalf("unable to start wtclient: %v", err)
|
||||
}
|
||||
if err := h.client.AddTower(towerAddr); err != nil {
|
||||
h.t.Fatalf("unable to add tower to wtclient: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// chanIDFromInt creates a unique channel id given a unique integral id.
|
||||
|
||||
Reference in new issue
Block a user