invoicesrpc: add HTLC modifier to invoices RPC server

This commit integrates the HTLC modifier service into the
invoices RPC server.
This commit is contained in:
ffranr authored and Oliver Gugger committed 2024-09-19 09:21:37 +02:00
1 parent 481dfe21bc
commit 008d265cdb
4 files changed
+14 -3

No files matched your search

+1
View File
@@ -638,6 +638,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)
+5
View File
@@ -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
+3 -2
View File
@@ -684,7 +684,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()
@@ -787,7 +788,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
+5 -1
View File
@@ -122,7 +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.
@@ -241,6 +242,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),
)