lnd+rpcserver: thread watchtower into subserver configs
This commit is contained in:
parent
c06d71530a
commit
59c9418eca
2
lnd.go
2
lnd.go
@ -406,7 +406,7 @@ func Main() error {
|
||||
rpcServer, err := newRPCServer(
|
||||
server, macaroonService, cfg.SubRPCServers, serverOpts,
|
||||
restDialOpts, restProxyDest, atplManager, server.invoices,
|
||||
tlsCfg,
|
||||
tower, tlsCfg,
|
||||
)
|
||||
if err != nil {
|
||||
srvrLog.Errorf("unable to start RPC server: %v", err)
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
|
||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"github.com/lightningnetwork/lnd/watchtower"
|
||||
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
@ -440,7 +441,7 @@ func newRPCServer(s *server, macService *macaroons.Service,
|
||||
subServerCgs *subRPCServerConfigs, serverOpts []grpc.ServerOption,
|
||||
restDialOpts []grpc.DialOption, restProxyDest string,
|
||||
atpl *autopilot.Manager, invoiceRegistry *invoices.InvoiceRegistry,
|
||||
tlsCfg *tls.Config) (*rpcServer, error) {
|
||||
tower *watchtower.Standalone, tlsCfg *tls.Config) (*rpcServer, error) {
|
||||
|
||||
// Set up router rpc backend.
|
||||
channelGraph := s.chanDB.ChannelGraph()
|
||||
@ -494,6 +495,7 @@ func newRPCServer(s *server, macService *macaroons.Service,
|
||||
s.cc, networkDir, macService, atpl, invoiceRegistry,
|
||||
s.htlcSwitch, activeNetParams.Params, s.chanRouter,
|
||||
routerBackend, s.nodeSigner, s.chanDB, s.sweeper,
|
||||
tower,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -15,10 +15,12 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/watchtowerrpc"
|
||||
"github.com/lightningnetwork/lnd/macaroons"
|
||||
"github.com/lightningnetwork/lnd/netann"
|
||||
"github.com/lightningnetwork/lnd/routing"
|
||||
"github.com/lightningnetwork/lnd/sweep"
|
||||
"github.com/lightningnetwork/lnd/watchtower"
|
||||
)
|
||||
|
||||
// subRPCServerConfigs is special sub-config in the main configuration that
|
||||
@ -56,6 +58,10 @@ type subRPCServerConfigs struct {
|
||||
// payment related queries such as requests for estimates of off-chain
|
||||
// fees.
|
||||
RouterRPC *routerrpc.Config `group:"routerrpc" namespace:"routerrpc"`
|
||||
|
||||
// WatchtowerRPC is a sub-RPC server that exposes functionality allowing
|
||||
// clients to monitor and control their embedded watchtower.
|
||||
WatchtowerRPC *watchtowerrpc.Config `group:"watchtowerrpc" namespace:"watchtowerrpc"`
|
||||
}
|
||||
|
||||
// PopulateDependencies attempts to iterate through all the sub-server configs
|
||||
@ -74,7 +80,8 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
|
||||
routerBackend *routerrpc.RouterBackend,
|
||||
nodeSigner *netann.NodeSigner,
|
||||
chanDB *channeldb.DB,
|
||||
sweeper *sweep.UtxoSweeper) error {
|
||||
sweeper *sweep.UtxoSweeper,
|
||||
tower *watchtower.Standalone) error {
|
||||
|
||||
// First, we'll use reflect to obtain a version of the config struct
|
||||
// that allows us to programmatically inspect its fields.
|
||||
@ -206,6 +213,13 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
|
||||
reflect.ValueOf(routerBackend),
|
||||
)
|
||||
|
||||
case *watchtowerrpc.Config:
|
||||
subCfgValue := extractReflectValue(subCfg)
|
||||
|
||||
subCfgValue.FieldByName("Tower").Set(
|
||||
reflect.ValueOf(tower),
|
||||
)
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unknown field: %v, %T", fieldName,
|
||||
cfg)
|
||||
|
Loading…
Reference in New Issue
Block a user