mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 22:50:58 +02:00
invoicesrpc: remove direct access to ChannelGraph pointer
This commit is contained in:
@@ -245,8 +245,9 @@ config option](https://github.com/lightningnetwork/lnd/pull/9182) and introduce
|
|||||||
a new option `channel-max-fee-exposure` which is unambiguous in its description.
|
a new option `channel-max-fee-exposure` which is unambiguous in its description.
|
||||||
The underlying functionality between those two options remain the same.
|
The underlying functionality between those two options remain the same.
|
||||||
|
|
||||||
* [Abstraction of graph](https://github.com/lightningnetwork/lnd/pull/9480)
|
* Graph abstraction work:
|
||||||
access for autopilot.
|
- [Abstract autopilot access](https://github.com/lightningnetwork/lnd/pull/9480)
|
||||||
|
- [Abstract invoicerpc server access](https://github.com/lightningnetwork/lnd/pull/9516)
|
||||||
|
|
||||||
* [Golang was updated to
|
* [Golang was updated to
|
||||||
`v1.22.11`](https://github.com/lightningnetwork/lnd/pull/9462).
|
`v1.22.11`](https://github.com/lightningnetwork/lnd/pull/9462).
|
||||||
|
@@ -18,7 +18,6 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
|
||||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||||
"github.com/lightningnetwork/lnd/invoices"
|
"github.com/lightningnetwork/lnd/invoices"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
@@ -75,8 +74,9 @@ type AddInvoiceConfig struct {
|
|||||||
// channel graph.
|
// channel graph.
|
||||||
ChanDB *channeldb.ChannelStateDB
|
ChanDB *channeldb.ChannelStateDB
|
||||||
|
|
||||||
// Graph holds a reference to the ChannelGraph database.
|
// Graph gives the invoice server access to various graph related
|
||||||
Graph *graphdb.ChannelGraph
|
// queries.
|
||||||
|
Graph GraphSource
|
||||||
|
|
||||||
// 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.
|
||||||
|
@@ -6,7 +6,6 @@ package invoicesrpc
|
|||||||
import (
|
import (
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
|
||||||
"github.com/lightningnetwork/lnd/invoices"
|
"github.com/lightningnetwork/lnd/invoices"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/lightningnetwork/lnd/macaroons"
|
"github.com/lightningnetwork/lnd/macaroons"
|
||||||
@@ -52,9 +51,9 @@ type Config struct {
|
|||||||
// specified.
|
// specified.
|
||||||
DefaultCLTVExpiry uint32
|
DefaultCLTVExpiry uint32
|
||||||
|
|
||||||
// GraphDB is a global database instance which is needed to access the
|
// Graph provides the invoices with information about the current LN
|
||||||
// channel graph.
|
// graph.
|
||||||
GraphDB *graphdb.ChannelGraph
|
Graph GraphSource
|
||||||
|
|
||||||
// ChanStateDB is a possibly replicated db instance which contains the
|
// ChanStateDB is a possibly replicated db instance which contains the
|
||||||
// channel state
|
// channel state
|
||||||
|
19
lnrpc/invoicesrpc/interfaces.go
Normal file
19
lnrpc/invoicesrpc/interfaces.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package invoicesrpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GraphSource defines the graph interface required by the invoice rpc server.
|
||||||
|
type GraphSource interface {
|
||||||
|
// FetchChannelEdgesByID attempts to look up the two directed edges for
|
||||||
|
// the channel identified by the channel ID. If the channel can't be
|
||||||
|
// found, then graphdb.ErrEdgeNotFound is returned.
|
||||||
|
FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo,
|
||||||
|
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)
|
||||||
|
|
||||||
|
// IsPublicNode is a helper method that determines whether the node with
|
||||||
|
// the given public key is seen as a public node in the graph from the
|
||||||
|
// graph's source node's point of view.
|
||||||
|
IsPublicNode(pubKey [33]byte) (bool, error)
|
||||||
|
}
|
@@ -346,7 +346,7 @@ func (s *Server) AddHoldInvoice(ctx context.Context,
|
|||||||
NodeSigner: s.cfg.NodeSigner,
|
NodeSigner: s.cfg.NodeSigner,
|
||||||
DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry,
|
DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry,
|
||||||
ChanDB: s.cfg.ChanStateDB,
|
ChanDB: s.cfg.ChanStateDB,
|
||||||
Graph: s.cfg.GraphDB,
|
Graph: s.cfg.Graph,
|
||||||
GenInvoiceFeatures: s.cfg.GenInvoiceFeatures,
|
GenInvoiceFeatures: s.cfg.GenInvoiceFeatures,
|
||||||
GenAmpInvoiceFeatures: s.cfg.GenAmpInvoiceFeatures,
|
GenAmpInvoiceFeatures: s.cfg.GenAmpInvoiceFeatures,
|
||||||
GetAlias: s.cfg.GetAlias,
|
GetAlias: s.cfg.GetAlias,
|
||||||
|
@@ -262,7 +262,7 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
|
|||||||
subCfgValue.FieldByName("DefaultCLTVExpiry").Set(
|
subCfgValue.FieldByName("DefaultCLTVExpiry").Set(
|
||||||
reflect.ValueOf(defaultDelta),
|
reflect.ValueOf(defaultDelta),
|
||||||
)
|
)
|
||||||
subCfgValue.FieldByName("GraphDB").Set(
|
subCfgValue.FieldByName("Graph").Set(
|
||||||
reflect.ValueOf(graphDB),
|
reflect.ValueOf(graphDB),
|
||||||
)
|
)
|
||||||
subCfgValue.FieldByName("ChanStateDB").Set(
|
subCfgValue.FieldByName("ChanStateDB").Set(
|
||||||
|
Reference in New Issue
Block a user