diff --git a/lnd.go b/lnd.go index 91d1832e0..f62198110 100644 --- a/lnd.go +++ b/lnd.go @@ -332,7 +332,7 @@ func lndMain() error { // exported by the rpcServer. rpcServer, err := newRPCServer( server, macaroonService, cfg.SubRPCServers, serverOpts, - proxyOpts, tlsConf, + proxyOpts, atplManager, tlsConf, ) if err != nil { srvrLog.Errorf("unable to start RPC server: %v", err) diff --git a/rpcserver.go b/rpcserver.go index f8ffbbdfe..d53975694 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -27,6 +27,7 @@ import ( "github.com/coreos/bbolt" "github.com/davecgh/go-spew/spew" proxy "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/lightningnetwork/lnd/autopilot" "github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/htlcswitch" @@ -392,7 +393,7 @@ var _ lnrpc.LightningServer = (*rpcServer)(nil) // like requiring TLS, etc. func newRPCServer(s *server, macService *macaroons.Service, subServerCgs *subRPCServerConfigs, serverOpts []grpc.ServerOption, - restServerOpts []grpc.DialOption, + restServerOpts []grpc.DialOption, atpl *autopilot.Manager, tlsCfg *tls.Config) (*rpcServer, error) { var ( @@ -404,7 +405,7 @@ func newRPCServer(s *server, macService *macaroons.Service, // the dependencies they need are properly populated within each sub // server configuration struct. err := subServerCgs.PopulateDependencies( - s.cc, networkDir, macService, + s.cc, networkDir, macService, atpl, ) if err != nil { return nil, err diff --git a/subrpcserver_config.go b/subrpcserver_config.go index de4c3b6e4..a60790ad5 100644 --- a/subrpcserver_config.go +++ b/subrpcserver_config.go @@ -4,6 +4,7 @@ import ( "fmt" "reflect" + "github.com/lightningnetwork/lnd/autopilot" "github.com/lightningnetwork/lnd/lnrpc/autopilotrpc" "github.com/lightningnetwork/lnd/lnrpc/signrpc" "github.com/lightningnetwork/lnd/lnrpc/walletrpc" @@ -39,7 +40,8 @@ type subRPCServerConfigs struct { // NOTE: This MUST be called before any callers are permitted to execute the // FetchConfig method. func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl, - networkDir string, macService *macaroons.Service) error { + networkDir string, macService *macaroons.Service, + atpl *autopilot.Manager) error { // First, we'll use reflect to obtain a version of the config struct // that allows us to programmatically inspect its fields. @@ -97,6 +99,13 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl, reflect.ValueOf(cc.keyRing), ) + case *autopilotrpc.Config: + subCfgValue := extractReflectValue(cfg) + + subCfgValue.FieldByName("Manager").Set( + reflect.ValueOf(atpl), + ) + default: return fmt.Errorf("unknown field: %v, %T", fieldName, cfg)