rpcserver: fix stats undercount in GetNetworkInfo
What changed, and why it matters
This commit fixes a simple coding mistake in LND's GetNetworkInfo RPC. When building network statistics, if the code encountered a channel it had already counted, it accidentally stopped processing that node's remaining channels instead of just skipping the duplicate. This caused reported totals like network capacity and channel count to be too low. The fix changes 'return' to 'continue' so the loop keeps going. It is a correctness bug, not a security vulnerability.
Treat as a routine bug fix. No security response required. Users relying on GetNetworkInfo for analytics should upgrade to obtain accurate network statistics.
Security signals we found
No security framing in commit message or release notes
Bug is a logic/correctness error causing under-reported statistics
No input validation, authorization, memory safety, or cryptographic issues evident
No attacker-controlled behavior or privilege boundary crossed
Evidence from the diff
In rpcserver.go’s GetNetworkInfo implementation, the per-node graph traversal callback used ‘return nil’ inside a loop when an edge’s ChannelID was already present in seenChans. Because the callback is invoked for each edge of a node, returning early aborted iteration over that node’s remaining edges, undercounting outDegree, total network capacity, channel count, and max out degree. The patch replaces the early return with ‘continue’, so only the duplicate edge is skipped. The release notes explicitly frame this as a bug fix for undercounted network statistics.
Changed components
rpcserver.go GetNetworkInfo RPCInspect captured patch +9 / −4
diff --git a/docs/release-notes/release-notes-0.22.0.md b/docs/release-notes/release-notes-0.22.0.md
index e6e3df8..85626b6 100644
--- a/docs/release-notes/release-notes-0.22.0.md
+++ b/docs/release-notes/release-notes-0.22.0.md
@@ -49,6 +49,12 @@
exclude such inputs from sweeping even though their input set could
comfortably pay its fees.
+* [Fixed a bug](https://github.com/lightningnetwork/lnd/pull/10963) in
+ `GetNetworkInfo` where encountering an already-seen channel skipped the
+ rest of that node's channels instead of just that channel, undercounting
+ the reported network statistics such as total network capacity, channel
+ count and max out degree.
+
# New Features
## Functional Enhancements
diff --git a/rpcserver.go b/rpcserver.go
index 52b682f..bfedfbf 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -6681,11 +6681,10 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context,
// channel encountered.
outDegree++
- // If we've already seen this channel, then we'll
- // return early to ensure that we don't double-count
- // stats.
+ // If we've already seen this channel, skip it to
+ // ensure that we don't double-count stats.
if _, ok := seenChans[edge.ChannelID]; ok {
- return nil
+ continue
}
// Compare the capacity of this channel against the
Why this scored 25/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.