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
481dfe21bc
commit
008d265cdb
1
lnd.go
1
lnd.go
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user