mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
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:
parent
7e8a3b0df7
commit
73f52c8b11
1
lnd.go
1
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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user