multi: thread anchor client down to wtclient subserver

This commit is contained in:
Conner Fromknecht 2020-11-25 15:08:05 -08:00
parent a5c40858c9
commit 5b3a08a1cd
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
3 changed files with 11 additions and 3 deletions

@ -19,6 +19,10 @@ type Config struct {
// through the watchtower RPC subserver. // through the watchtower RPC subserver.
Client wtclient.Client Client wtclient.Client
// AnchorClient is the backing watchtower client for anchor channels that
// we'll interact through the watchtower RPC subserver.
AnchorClient wtclient.Client
// Resolver is a custom resolver that will be used to resolve watchtower // Resolver is a custom resolver that will be used to resolve watchtower
// addresses to ensure we don't leak any information when running over // addresses to ensure we don't leak any information when running over
// non-clear networks, e.g. Tor, etc. // non-clear networks, e.g. Tor, etc.

@ -619,8 +619,8 @@ func newRPCServer(cfg *Config, s *server, macService *macaroons.Service,
cfg, s.cc, cfg.networkDir, macService, atpl, invoiceRegistry, cfg, s.cc, cfg.networkDir, macService, atpl, invoiceRegistry,
s.htlcSwitch, cfg.ActiveNetParams.Params, s.chanRouter, s.htlcSwitch, cfg.ActiveNetParams.Params, s.chanRouter,
routerBackend, s.nodeSigner, s.remoteChanDB, s.sweeper, tower, routerBackend, s.nodeSigner, s.remoteChanDB, s.sweeper, tower,
s.towerClient, cfg.net.ResolveTCPAddr, genInvoiceFeatures, s.towerClient, s.anchorTowerClient, cfg.net.ResolveTCPAddr,
rpcsLog, genInvoiceFeatures, rpcsLog,
) )
if err != nil { if err != nil {
return nil, err return nil, err

@ -96,6 +96,7 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
sweeper *sweep.UtxoSweeper, sweeper *sweep.UtxoSweeper,
tower *watchtower.Standalone, tower *watchtower.Standalone,
towerClient wtclient.Client, towerClient wtclient.Client,
anchorTowerClient wtclient.Client,
tcpResolver lncfg.TCPResolver, tcpResolver lncfg.TCPResolver,
genInvoiceFeatures func() *lnwire.FeatureVector, genInvoiceFeatures func() *lnwire.FeatureVector,
rpcLogger btclog.Logger) error { rpcLogger btclog.Logger) error {
@ -243,13 +244,16 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
case *wtclientrpc.Config: case *wtclientrpc.Config:
subCfgValue := extractReflectValue(subCfg) subCfgValue := extractReflectValue(subCfg)
if towerClient != nil { if towerClient != nil && anchorTowerClient != nil {
subCfgValue.FieldByName("Active").Set( subCfgValue.FieldByName("Active").Set(
reflect.ValueOf(towerClient != nil), reflect.ValueOf(towerClient != nil),
) )
subCfgValue.FieldByName("Client").Set( subCfgValue.FieldByName("Client").Set(
reflect.ValueOf(towerClient), reflect.ValueOf(towerClient),
) )
subCfgValue.FieldByName("AnchorClient").Set(
reflect.ValueOf(anchorTowerClient),
)
} }
subCfgValue.FieldByName("Resolver").Set( subCfgValue.FieldByName("Resolver").Set(
reflect.ValueOf(tcpResolver), reflect.ValueOf(tcpResolver),