diff --git a/lnd.go b/lnd.go index fb7e2c591..f41669a86 100644 --- a/lnd.go +++ b/lnd.go @@ -630,7 +630,8 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg, // RPC server as well. err = rpcServer.addDeps( server, interceptorChain.MacaroonService(), cfg.SubRPCServers, - atplManager, server.invoices, tower, multiAcceptor, + atplManager, server.invoices, + server.invoiceSettlementInterceptor, tower, multiAcceptor, ) if err != nil { return mkErr("unable to add deps to RPC server: %v", err) diff --git a/lnrpc/invoicesrpc/config_active.go b/lnrpc/invoicesrpc/config_active.go index a5b29c32a..3324c6f82 100644 --- a/lnrpc/invoicesrpc/config_active.go +++ b/lnrpc/invoicesrpc/config_active.go @@ -30,6 +30,11 @@ type Config struct { // created by the daemon. InvoiceRegistry *invoices.InvoiceRegistry + // InvoiceSettlementInterceptor is a service which intercepts invoices + // during the settlement phase, enabling a subscribed client to + // determine the settlement outcome. + InvoiceSettlementInterceptor invoices.SettlementInterceptorInterface + // IsChannelActive is used to generate valid hop hints. IsChannelActive func(chanID lnwire.ChannelID) bool diff --git a/rpcserver.go b/rpcserver.go index 2c3d481a2..8af976e65 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -672,7 +672,9 @@ func newRPCServer(cfg *Config, interceptorChain *rpcperms.InterceptorChain, // be started, and start accepting RPC calls. func (r *rpcServer) addDeps(s *server, macService *macaroons.Service, subServerCgs *subRPCServerConfigs, atpl *autopilot.Manager, - invoiceRegistry *invoices.InvoiceRegistry, tower *watchtower.Standalone, + invoiceRegistry *invoices.InvoiceRegistry, + invoiceSettlementInterceptor *invoices.SettlementInterceptor, + tower *watchtower.Standalone, chanPredicate chanacceptor.MultiplexAcceptor) error { // Set up router rpc backend. @@ -771,12 +773,13 @@ func (r *rpcServer) addDeps(s *server, macService *macaroons.Service, // TODO(roasbeef): extend sub-sever config to have both (local vs remote) DB err = subServerCgs.PopulateDependencies( r.cfg, s.cc, r.cfg.networkDir, macService, atpl, invoiceRegistry, - s.htlcSwitch, r.cfg.ActiveNetParams.Params, s.chanRouter, - routerBackend, s.nodeSigner, s.graphDB, s.chanStateDB, - s.sweeper, tower, s.towerClientMgr, r.cfg.net.ResolveTCPAddr, - genInvoiceFeatures, genAmpInvoiceFeatures, - s.getNodeAnnouncement, s.updateAndBrodcastSelfNode, parseAddr, - rpcsLog, s.aliasMgr.GetPeerAlias, + invoiceSettlementInterceptor, s.htlcSwitch, + r.cfg.ActiveNetParams.Params, s.chanRouter, routerBackend, + s.nodeSigner, s.graphDB, s.chanStateDB, s.sweeper, tower, + s.towerClientMgr, r.cfg.net.ResolveTCPAddr, genInvoiceFeatures, + genAmpInvoiceFeatures, s.getNodeAnnouncement, + s.updateAndBrodcastSelfNode, parseAddr, rpcsLog, + s.aliasMgr.GetPeerAlias, ) if err != nil { return err diff --git a/subrpcserver_config.go b/subrpcserver_config.go index 6687f71a7..d15846610 100644 --- a/subrpcserver_config.go +++ b/subrpcserver_config.go @@ -104,6 +104,7 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, networkDir string, macService *macaroons.Service, atpl *autopilot.Manager, invoiceRegistry *invoices.InvoiceRegistry, + invoiceSettlementInterceptor *invoices.SettlementInterceptor, htlcSwitch *htlcswitch.Switch, activeNetParams *chaincfg.Params, chanRouter *routing.ChannelRouter, @@ -238,6 +239,10 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, subCfgValue.FieldByName("InvoiceRegistry").Set( reflect.ValueOf(invoiceRegistry), ) + //nolint:lll + subCfgValue.FieldByName("InvoiceSettlementInterceptor").Set( + reflect.ValueOf(invoiceSettlementInterceptor), + ) subCfgValue.FieldByName("IsChannelActive").Set( reflect.ValueOf(htlcSwitch.HasActiveLink), )