What changed, and why it matters
This is a routine code cleanup in LND's chain setup code. It replaces a hand-rolled JSON call to Bitcoin's getzmqnotifications RPC with a typed library method. There is no security-relevant change visible in the diff: the same ZMQ notification checks are still performed, just with less manual parsing.
No security action required. Treat as normal refactoring/reliability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors chainregistry.go to use btcwallet/rpcclient’s GetZmqNotifications() instead of RawRequest(‘getzmqnotifications’, …) plus json.Unmarshal into an anonymous struct and per-entry url.Parse. The typed result already exposes a parsed *url.URL Address, so the manual JSON and URL parsing loops are removed. The validation logic (compare ports for pubrawblock and pubrawtx, warn if mismatched, set active flags) is preserved unchanged.
Changed components
chainreg/chainregistry.goInspect captured patch +10 / −24
diff --git a/chainreg/chainregistry.go b/chainreg/chainregistry.go
index ee23885..f3c8d39 100644
--- a/chainreg/chainregistry.go
+++ b/chainreg/chainregistry.go
@@ -2,7 +2,6 @@ package chainreg
import (
"encoding/hex"
- "encoding/json"
"errors"
"fmt"
"io"
@@ -452,51 +451,38 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
return nil, nil, err
}
- // Fetch all active zmq notifications from the bitcoind client.
- resp, err := chainConn.RawRequest("getzmqnotifications", nil)
+ // Fetch all active ZMQ notifications from bitcoind.
+ zmq, err := chainConn.GetZmqNotifications()
if err != nil {
return nil, nil, err
}
- zmq := []struct {
- Type string `json:"type"`
- Address string `json:"address"`
- }{}
-
- if err = json.Unmarshal([]byte(resp), &zmq); err != nil {
- return nil, nil, err
- }
-
pubRawBlockActive := false
pubRawTxActive := false
for i := range zmq {
if zmq[i].Type == "pubrawblock" {
- url, err := url.Parse(zmq[i].Address)
- if err != nil {
- return nil, nil, err
- }
- if url.Port() != zmqPubRawBlockURL.Port() {
+ if zmq[i].Address.Port() !=
+ zmqPubRawBlockURL.Port() {
+
log.Warnf(
"unable to subscribe to zmq block events on "+
"%s (bitcoind is running on %s)",
zmqPubRawBlockURL.Host,
- url.Host,
+ zmq[i].Address.Host,
)
}
pubRawBlockActive = true
}
if zmq[i].Type == "pubrawtx" {
- url, err := url.Parse(zmq[i].Address)
- if err != nil {
- return nil, nil, err
- }
- if url.Port() != zmqPubRawTxURL.Port() {
+ if zmq[i].Address.Port() !=
+ zmqPubRawTxURL.Port() {
+
log.Warnf(
"unable to subscribe to zmq tx events on "+
"%s (bitcoind is running on %s)",
zmqPubRawTxURL.Host,
- url.Host,
+ zmq[i].Address.Host,
)
}
pubRawTxActive = true
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.