lntest+rpcserver: ignore `chanfitness.ErrPeerNotFound` in rpc
What changed, and why it matters
This change is a small hardening fix in LND's RPC server. It makes the code gracefully handle a newly introduced error case—when a peer is not yet known to the channel event store—instead of potentially failing or returning unexpected behavior. It is not a fix for an active exploit, but it prevents a class of operational/logic errors from surfacing to users.
Treat as a routine maintenance/defensive patch. No urgent security action required. Reviewers may want to confirm that no other callers of GetChanInfo need similar handling and that the log level change from Infof to Warnf for ErrChannelNotFound is intentional.
Security signals we found
Defensive error handling for newly possible ErrPeerNotFound condition
Prevents RPC channel info population from failing due to missing peer entry
Uses errors.Is() for robust wrapped-error matching
No authentication, authorization, cryptographic, or network-boundary changes
Evidence from the diff
The patch updates rpcserver.go so that createRPCOpenChannel treats chanfitness.ErrPeerNotFound the same way it already treats chanfitness.ErrChannelNotFound: it logs a warning and continues rather than falling through to the default error handling. The change also switches from a direct equality switch to errors.Is() checks, which is more robust for wrapped errors. The underlying behavior change is that chanEventStore no longer adds peers on connection; it only adds them when a channel is added, so ErrPeerNotFound can now occur legitimately.
Changed components
lnd/rpcserver.gocreateRPCOpenChannel functionchanfitness channel event store integrationInspect captured patch +9 / −4
diff --git a/rpcserver.go b/rpcserver.go
index 96dee31..6fb0507 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -5080,14 +5080,19 @@ func createRPCOpenChannel(ctx context.Context, r *rpcServer,
// being notified of it.
outpoint := dbChannel.FundingOutpoint
info, err := r.server.chanEventStore.GetChanInfo(outpoint, peer)
- switch err {
+ switch {
+ // If the store does not know about the peer, we just log it.
+ case errors.Is(err, chanfitness.ErrPeerNotFound):
+ rpcsLog.Warnf("peer: %v not found by channel event store",
+ peer)
+
// If the store does not know about the channel, we just log it.
- case chanfitness.ErrChannelNotFound:
- rpcsLog.Infof("channel: %v not found by channel event store",
+ case errors.Is(err, chanfitness.ErrChannelNotFound):
+ rpcsLog.Warnf("channel: %v not found by channel event store",
outpoint)
// If we got our channel info, we further populate the channel.
- case nil:
+ case err == nil:
channel.Uptime = int64(info.Uptime.Seconds())
channel.Lifetime = int64(info.Lifetime.Seconds())
Why this scored 19/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.