What changed, and why it matters
This change is a performance and reliability improvement, not a security fix. LND previously checked how many outbound peers its bitcoind backend had by calling getpeerinfo, which returns detailed information about every single peer and can be slow. The patch switches to using getnetworkinfo.connections_out, a lighter-weight RPC call that just reports the outbound peer count. The old getpeerinfo-based helper is kept for btcd because btcd does not support getnetworkinfo. There is no indication this change addresses a vulnerability or security incident.
No security action required. Treat as a normal code-quality/performance improvement. Reviewers may verify that GetNetworkInfo().ConnectionsOut semantics match the prior getpeerinfo-based count for the bitcoind versions LND supports.
Security signals we found
No security-relevant signal: change is a performance optimization of a health-check helper.
No change to authentication, authorization, cryptography, network exposure, or consensus logic.
No removal of safety checks; the same minimum-outbound-peers warning threshold is retained.
Evidence from the diff
The commit refactors the outbound-peer health check in chainreg/chainregistry.go. It introduces checkOutboundPeersBitcoind, which uses rpcclient.Client.GetNetworkInfo().ConnectionsOut, and wires the bitcoind backend path to use it. The existing checkOutboundPeers (which iterates getpeerinfo and counts NetworkInbound==false peers) remains for btcd. The warning logic is extracted into logOutboundPeerCount. The isolation-safety signal is preserved while reducing RPC load.
Changed components
chainreg/chainregistry.gobitcoind chain backend outbound peer health checkInspect captured patch +27 / −3
diff --git a/chainreg/chainregistry.go b/chainreg/chainregistry.go
index f3c8d39..55f9244 100644
--- a/chainreg/chainregistry.go
+++ b/chainreg/chainregistry.go
@@ -521,7 +521,7 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
// Make sure the bitcoind chain backend maintains a
// healthy connection to the network by checking the
// number of outbound peers.
- return checkOutboundPeers(chainConn)
+ return checkOutboundPeersBitcoind(chainConn)
}
case "btcd":
@@ -887,6 +887,24 @@ var (
}
)
+// checkOutboundPeersBitcoind checks the number of outbound peers connected to
+// a bitcoind backend. If the number of outbound peers is below 6, a warning is
+// logged. This function is intended to ensure that the chain backend maintains
+// a healthy connection to the network.
+//
+// This helper is bitcoind-specific because btcd does not currently implement
+// getnetworkinfo.
+func checkOutboundPeersBitcoind(client *rpcclient.Client) error {
+ info, err := client.GetNetworkInfo()
+ if err != nil {
+ return err
+ }
+
+ logOutboundPeerCount(int(info.ConnectionsOut))
+
+ return nil
+}
+
// checkOutboundPeers checks the number of outbound peers connected to the
// provided RPC client. If the number of outbound peers is below 6, a warning
// is logged. This function is intended to ensure that the chain backend
@@ -904,6 +922,14 @@ func checkOutboundPeers(client *rpcclient.Client) error {
}
}
+ logOutboundPeerCount(outboundPeers)
+
+ return nil
+}
+
+// logOutboundPeerCount logs a warning when the number of outbound peers is
+// below the minimum threshold.
+func logOutboundPeerCount(outboundPeers int) {
if outboundPeers < DefaultMinOutboundPeers {
log.Warnf("The chain backend has an insufficient number "+
"of connected outbound peers (%d connected, expected "+
@@ -911,6 +937,4 @@ func checkOutboundPeers(client *rpcclient.Client) error {
"Connect to more trusted nodes manually if necessary.",
outboundPeers, DefaultMinOutboundPeers)
}
-
- return nil
}
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.