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 2024-04-23 14:48:42 +01:00 committed by Oliver Gugger
parent 7e8a3b0df7
commit 73f52c8b11
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
4 changed files with 14 additions and 4 deletions

1
lnd.go
View File

@ -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)

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

View File

@ -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

View File

@ -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),
)