diff --git a/lnd.go b/lnd.go index 28b3d511..eaf8f877 100644 --- a/lnd.go +++ b/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) diff --git a/rpcserver.go b/rpcserver.go index 604dbc55..88c30aeb 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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 diff --git a/subrpcserver_config.go b/subrpcserver_config.go index cb9b2076..600f2d02 100644 --- a/subrpcserver_config.go +++ b/subrpcserver_config.go @@ -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)