invoices+rpc: add missing channel graph to the AddInvoiceConfig

The Graph which is referenced later in the AddInvoice call graph is
unset when adding a hodl invoice. This resulted in a crash.
This commit is contained in:
Andras Banki-Horvath 2021-02-03 11:02:29 +01:00
parent 814b81bd25
commit dde5750160
No known key found for this signature in database
GPG Key ID: 80E5375C094198D8
4 changed files with 18 additions and 9 deletions

@ -44,9 +44,13 @@ type Config struct {
// specified. // specified.
DefaultCLTVExpiry uint32 DefaultCLTVExpiry uint32
// ChanDB is a global boltdb instance which is needed to access the // LocalChanDB is a global boltdb instance which is needed to access the
// channel graph. // channel graph.
ChanDB *channeldb.DB LocalChanDB *channeldb.DB
// RemoteChanDB is a replicatd db instance which is the same as the
// localdb when running without remote db.
RemoteChanDB *channeldb.DB
// GenInvoiceFeatures returns a feature containing feature bits that // GenInvoiceFeatures returns a feature containing feature bits that
// should be advertised on freshly generated invoices. // should be advertised on freshly generated invoices.

@ -278,7 +278,8 @@ func (s *Server) AddHoldInvoice(ctx context.Context,
ChainParams: s.cfg.ChainParams, ChainParams: s.cfg.ChainParams,
NodeSigner: s.cfg.NodeSigner, NodeSigner: s.cfg.NodeSigner,
DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry, DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry,
ChanDB: s.cfg.ChanDB, ChanDB: s.cfg.RemoteChanDB,
Graph: s.cfg.LocalChanDB.ChannelGraph(),
GenInvoiceFeatures: s.cfg.GenInvoiceFeatures, GenInvoiceFeatures: s.cfg.GenInvoiceFeatures,
} }

@ -621,9 +621,9 @@ func newRPCServer(cfg *Config, s *server, macService *macaroons.Service,
err = subServerCgs.PopulateDependencies( err = subServerCgs.PopulateDependencies(
cfg, s.cc, cfg.networkDir, macService, atpl, invoiceRegistry, cfg, s.cc, cfg.networkDir, macService, atpl, invoiceRegistry,
s.htlcSwitch, cfg.ActiveNetParams.Params, s.chanRouter, s.htlcSwitch, cfg.ActiveNetParams.Params, s.chanRouter,
routerBackend, s.nodeSigner, s.remoteChanDB, s.sweeper, tower, routerBackend, s.nodeSigner, s.localChanDB, s.remoteChanDB,
s.towerClient, s.anchorTowerClient, cfg.net.ResolveTCPAddr, s.sweeper, tower, s.towerClient, s.anchorTowerClient,
genInvoiceFeatures, rpcsLog, cfg.net.ResolveTCPAddr, genInvoiceFeatures, rpcsLog,
) )
if err != nil { if err != nil {
return nil, err return nil, err

@ -92,7 +92,8 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
chanRouter *routing.ChannelRouter, chanRouter *routing.ChannelRouter,
routerBackend *routerrpc.RouterBackend, routerBackend *routerrpc.RouterBackend,
nodeSigner *netann.NodeSigner, nodeSigner *netann.NodeSigner,
chanDB *channeldb.DB, localChanDB *channeldb.DB,
remoteChanDB *channeldb.DB,
sweeper *sweep.UtxoSweeper, sweeper *sweep.UtxoSweeper,
tower *watchtower.Standalone, tower *watchtower.Standalone,
towerClient wtclient.Client, towerClient wtclient.Client,
@ -220,8 +221,11 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
subCfgValue.FieldByName("DefaultCLTVExpiry").Set( subCfgValue.FieldByName("DefaultCLTVExpiry").Set(
reflect.ValueOf(defaultDelta), reflect.ValueOf(defaultDelta),
) )
subCfgValue.FieldByName("ChanDB").Set( subCfgValue.FieldByName("LocalChanDB").Set(
reflect.ValueOf(chanDB), reflect.ValueOf(localChanDB),
)
subCfgValue.FieldByName("RemoteChanDB").Set(
reflect.ValueOf(remoteChanDB),
) )
subCfgValue.FieldByName("GenInvoiceFeatures").Set( subCfgValue.FieldByName("GenInvoiceFeatures").Set(
reflect.ValueOf(genInvoiceFeatures), reflect.ValueOf(genInvoiceFeatures),