routerrpc: add HasNode backend function for LSP heuristic
What changed, and why it matters
This commit adds a simple internal helper function called HasNode that lets other parts of the Lightning Network Daemon (LND) ask whether a given node is publicly known in the network graph. It is purely a read-only lookup and does not change any behavior, access controls, or data. There is no indication this fixes or introduces a security issue.
No security action required. Review as normal code change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change introduces a HasNode closure on the RouterBackend struct in lnrpc/routerrpc/router_backend.go and wires it to graph.HasNode(…) in rpcserver.go. It returns whether a node exists in the channel graph (i.e., has public channels). The only other change is a //nolint:funlen annotation on addDeps, which is a linting suppression and has no runtime effect. No RPC endpoints, permissions, or validation logic are modified.
Changed components
lnrpc/routerrpc/router_backend.gorpcserver.goInspect captured patch +12 / −0
diff --git a/lnrpc/routerrpc/router_backend.go b/lnrpc/routerrpc/router_backend.go
index d19127f..f8a3c56 100644
--- a/lnrpc/routerrpc/router_backend.go
+++ b/lnrpc/routerrpc/router_backend.go
@@ -64,6 +64,11 @@ type RouterBackend struct {
FetchChannelEndpoints func(chanID uint64) (route.Vertex,
route.Vertex, error)
+ // HasNode returns true if the node exists in the graph (i.e., has
+ // public channels), false otherwise. This means the node is a public
+ // node and should be reachable.
+ HasNode func(nodePub route.Vertex) (bool, error)
+
// FindRoute is a closure that abstracts away how we locate/query for
// routes.
FindRoute func(*routing.RouteRequest) (*route.Route, float64, error)
diff --git a/rpcserver.go b/rpcserver.go
index ee810d1..5d2c4d2 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -695,6 +695,8 @@ func newRPCServer(cfg *Config, interceptorChain *rpcperms.InterceptorChain,
// addDeps populates all dependencies needed by the RPC server, and any
// of the sub-servers that it maintains. When this is done, the RPC server can
// be started, and start accepting RPC calls.
+//
+//nolint:funlen
func (r *rpcServer) addDeps(ctx context.Context, s *server,
macService *macaroons.Service,
subServerCgs *subRPCServerConfigs, atpl *autopilot.Manager,
@@ -744,6 +746,11 @@ func (r *rpcServer) addDeps(ctx context.Context, s *server,
return info.NodeKey1Bytes, info.NodeKey2Bytes, nil
},
+ HasNode: func(nodePub route.Vertex) (bool, error) {
+ _, exists, err := graph.HasNode(ctx, nodePub)
+
+ return exists, err
+ },
FindRoute: s.chanRouter.FindRoute,
MissionControl: s.defaultMC,
ActiveNetParams: r.cfg.ActiveNetParams.Params,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.