Skip to content

Commit

Permalink
Merge pull request #4978 from bhandras/addinvoice_crash
Browse files Browse the repository at this point in the history
invoices+rpc: add missing channel graph to the AddInvoiceConfig
  • Loading branch information
halseth authored Feb 3, 2021
2 parents 814b81b + dde5750 commit 1a9fd09
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
8 changes: 6 additions & 2 deletions lnrpc/invoicesrpc/config_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ type Config struct {
// specified.
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.
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
// should be advertised on freshly generated invoices.
Expand Down
3 changes: 2 additions & 1 deletion lnrpc/invoicesrpc/invoices_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ func (s *Server) AddHoldInvoice(ctx context.Context,
ChainParams: s.cfg.ChainParams,
NodeSigner: s.cfg.NodeSigner,
DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry,
ChanDB: s.cfg.ChanDB,
ChanDB: s.cfg.RemoteChanDB,
Graph: s.cfg.LocalChanDB.ChannelGraph(),
GenInvoiceFeatures: s.cfg.GenInvoiceFeatures,
}

Expand Down
6 changes: 3 additions & 3 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ func newRPCServer(cfg *Config, s *server, macService *macaroons.Service,
err = subServerCgs.PopulateDependencies(
cfg, s.cc, cfg.networkDir, macService, atpl, invoiceRegistry,
s.htlcSwitch, cfg.ActiveNetParams.Params, s.chanRouter,
routerBackend, s.nodeSigner, s.remoteChanDB, s.sweeper, tower,
s.towerClient, s.anchorTowerClient, cfg.net.ResolveTCPAddr,
genInvoiceFeatures, rpcsLog,
routerBackend, s.nodeSigner, s.localChanDB, s.remoteChanDB,
s.sweeper, tower, s.towerClient, s.anchorTowerClient,
cfg.net.ResolveTCPAddr, genInvoiceFeatures, rpcsLog,
)
if err != nil {
return nil, err
Expand Down
10 changes: 7 additions & 3 deletions subrpcserver_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
chanRouter *routing.ChannelRouter,
routerBackend *routerrpc.RouterBackend,
nodeSigner *netann.NodeSigner,
chanDB *channeldb.DB,
localChanDB *channeldb.DB,
remoteChanDB *channeldb.DB,
sweeper *sweep.UtxoSweeper,
tower *watchtower.Standalone,
towerClient wtclient.Client,
Expand Down Expand Up @@ -220,8 +221,11 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
subCfgValue.FieldByName("DefaultCLTVExpiry").Set(
reflect.ValueOf(defaultDelta),
)
subCfgValue.FieldByName("ChanDB").Set(
reflect.ValueOf(chanDB),
subCfgValue.FieldByName("LocalChanDB").Set(
reflect.ValueOf(localChanDB),
)
subCfgValue.FieldByName("RemoteChanDB").Set(
reflect.ValueOf(remoteChanDB),
)
subCfgValue.FieldByName("GenInvoiceFeatures").Set(
reflect.ValueOf(genInvoiceFeatures),
Expand Down

0 comments on commit 1a9fd09

Please sign in to comment.