diff --git a/lnd.go b/lnd.go index 9f628ff81..56db5bf82 100644 --- a/lnd.go +++ b/lnd.go @@ -618,6 +618,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg, err = rpcServer.addDeps( server, interceptorChain.MacaroonService(), cfg.SubRPCServers, atplManager, server.invoices, tower, multiAcceptor, + server.invoiceHtlcModifier, ) 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..b781be875 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 + // HtlcModifier is a service which intercepts invoice HTLCs during the + // settlement phase, enabling a subscribed client to modify certain + // aspects of those HTLCs. + HtlcModifier invoices.HtlcModifier + // IsChannelActive is used to generate valid hop hints. IsChannelActive func(chanID lnwire.ChannelID) bool diff --git a/rpcserver.go b/rpcserver.go index 344250501..73e6386f2 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -673,7 +673,8 @@ func newRPCServer(cfg *Config, interceptorChain *rpcperms.InterceptorChain, func (r *rpcServer) addDeps(s *server, macService *macaroons.Service, subServerCgs *subRPCServerConfigs, atpl *autopilot.Manager, invoiceRegistry *invoices.InvoiceRegistry, tower *watchtower.Standalone, - chanPredicate chanacceptor.MultiplexAcceptor) error { + chanPredicate chanacceptor.MultiplexAcceptor, + invoiceHtlcModifier *invoices.HtlcModificationInterceptor) error { // Set up router rpc backend. selfNode, err := s.graphDB.SourceNode() @@ -776,7 +777,7 @@ func (r *rpcServer) addDeps(s *server, macService *macaroons.Service, s.sweeper, tower, s.towerClientMgr, r.cfg.net.ResolveTCPAddr, genInvoiceFeatures, genAmpInvoiceFeatures, s.getNodeAnnouncement, s.updateAndBrodcastSelfNode, parseAddr, - rpcsLog, s.aliasMgr, + rpcsLog, s.aliasMgr, invoiceHtlcModifier, ) if err != nil { return err diff --git a/subrpcserver_config.go b/subrpcserver_config.go index 1c6d8d196..6f4c81336 100644 --- a/subrpcserver_config.go +++ b/subrpcserver_config.go @@ -122,8 +122,8 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, updateNodeAnnouncement func(features *lnwire.RawFeatureVector, modifiers ...netann.NodeAnnModifier) error, parseAddr func(addr string) (net.Addr, error), - rpcLogger btclog.Logger, - aliasMgr *aliasmgr.Manager) error { + rpcLogger btclog.Logger, aliasMgr *aliasmgr.Manager, + invoiceHtlcModifier *invoices.HtlcModificationInterceptor) error { // First, we'll use reflect to obtain a version of the config struct // that allows us to programmatically inspect its fields. @@ -239,6 +239,9 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, subCfgValue.FieldByName("InvoiceRegistry").Set( reflect.ValueOf(invoiceRegistry), ) + subCfgValue.FieldByName("HtlcModifier").Set( + reflect.ValueOf(invoiceHtlcModifier), + ) subCfgValue.FieldByName("IsChannelActive").Set( reflect.ValueOf(htlcSwitch.HasActiveLink), )