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