What changed, and why it matters
This is a routine internal code cleanup. It changes how one part of the Lightning Network Daemon (LND) refers to its channel-state database, using a narrower interface instead of a concrete type, and separates link-node database access into its own field. There is no security-relevant change visible in the diff.
No security action required. Treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors server.go so that the server struct’s chanStateDB field is typed as the chanstate.Store interface rather than the concrete *channeldb.ChannelStateDB. It introduces a separate linkNodeDB *channeldb.LinkNodeDB field and populates it from the underlying ChannelStateDB. Call sites that previously accessed s.chanStateDB.LinkNodeDB() now use s.linkNodeDB directly. This is an abstraction-boundary refactor to keep LinkNodeDB out of the channel-state store contract.
Changed components
server.gochanstate.Store interface usageLinkNodeDB access in serverInspect captured patch +8 / −6
diff --git a/server.go b/server.go
index c2b7ea6..45992c4 100644
--- a/server.go
+++ b/server.go
@@ -38,6 +38,7 @@ import (
"github.com/lightningnetwork/lnd/chanfitness"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channelnotifier"
+ "github.com/lightningnetwork/lnd/chanstate"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/cluster"
"github.com/lightningnetwork/lnd/contractcourt"
@@ -325,7 +326,8 @@ type server struct {
graphDB *graphdb.ChannelGraph
v1Graph *graphdb.VersionedGraph
- chanStateDB *channeldb.ChannelStateDB
+ chanStateDB chanstate.Store
+ linkNodeDB *channeldb.LinkNodeDB
addrSource channeldb.AddrSource
@@ -728,13 +730,15 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
)
addrSource := channeldb.NewMultiAddrSource(dbs.ChanStateDB, v1Graph)
+ chanStateDB := dbs.ChanStateDB.ChannelStateDB()
s := &server{
cfg: cfg,
implCfg: implCfg,
graphDB: dbs.GraphDB,
v1Graph: v1Graph,
- chanStateDB: dbs.ChanStateDB.ChannelStateDB(),
+ chanStateDB: chanStateDB,
+ linkNodeDB: chanStateDB.LinkNodeDB(),
addrSource: addrSource,
miscDB: dbs.ChanStateDB,
invoicesDB: dbs.InvoiceDB,
@@ -748,9 +752,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
blockbeatDispatcher: chainio.NewBlockbeatDispatcher(
cc.ChainNotifier,
),
- channelNotifier: channelnotifier.New(
- dbs.ChanStateDB.ChannelStateDB(),
- ),
+ channelNotifier: channelnotifier.New(chanStateDB),
identityECDH: nodeKeyECDH,
identityKeyLoc: nodeKeyDesc.KeyLocator,
@@ -3610,7 +3612,7 @@ func (s *server) establishPersistentConnections(ctx context.Context) error {
// Iterate through the list of LinkNodes to find addresses we should
// attempt to connect to based on our set of previous connections. Set
// the reconnection port to the default peer port.
- linkNodes, err := s.chanStateDB.LinkNodeDB().FetchAllLinkNodes()
+ linkNodes, err := s.linkNodeDB.FetchAllLinkNodes()
if err != nil && !errors.Is(err, channeldb.ErrLinkNodesNotFound) {
return fmt.Errorf("failed to fetch all link nodes: %w", err)
}
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.