What changed, and why it matters
This commit is a straightforward internal code cleanup in LND's channel graph database. It swaps one Go data type for another equivalent one (route.Vertex, which is defined as exactly the same 33-byte array) when storing public keys in channel records. There is no functional change, no bug fix, and no security-relevant behavior change.
No security action needed. Treat as normal refactoring/code-quality commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch changes ChannelEdgeInfo fields NodeKey1Bytes, NodeKey2Bytes, BitcoinKey1Bytes, and BitcoinKey2Bytes from [33]byte to route.Vertex, plus updates OtherNodeKeyBytes’s return type. route.Vertex is itself defined as [33]byte, so memory layout, serialization, and semantics are unchanged. The only call-site change in kv_store.go removes pointer indirection because route.Vertex is used as a value type in a slice. This is a type-safety/refactoring change with no security implications.
Changed components
graph/db/models/channel_edge_info.gograph/db/kv_store.goInspect captured patch +12 / −11
diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go
index 021f4a3..85b93ca 100644
--- a/graph/db/kv_store.go
+++ b/graph/db/kv_store.go
@@ -1262,9 +1262,9 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx,
// Mark edge policies for both sides as unknown. This is to enable
// efficient incoming channel lookup for a node.
- keys := []*[33]byte{
- &edge.NodeKey1Bytes,
- &edge.NodeKey2Bytes,
+ keys := []route.Vertex{
+ edge.NodeKey1Bytes,
+ edge.NodeKey2Bytes,
}
for _, key := range keys {
err := putChanEdgePolicyUnknown(edges, edge.ChannelID, key[:])
diff --git a/graph/db/models/channel_edge_info.go b/graph/db/models/channel_edge_info.go
index 0d6cd04..cfa7e1e 100644
--- a/graph/db/models/channel_edge_info.go
+++ b/graph/db/models/channel_edge_info.go
@@ -10,6 +10,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwire"
+ "github.com/lightningnetwork/lnd/routing/route"
)
// ChannelEdgeInfo represents a fully authenticated channel along with all its
@@ -29,16 +30,16 @@ type ChannelEdgeInfo struct {
ChainHash chainhash.Hash
// NodeKey1Bytes is the raw public key of the first node.
- NodeKey1Bytes [33]byte
+ NodeKey1Bytes route.Vertex
- // NodeKey2Bytes is the raw public key of the first node.
- NodeKey2Bytes [33]byte
+ // NodeKey2Bytes is the raw public key of the second node.
+ NodeKey2Bytes route.Vertex
// BitcoinKey1Bytes is the raw public key of the first node.
- BitcoinKey1Bytes [33]byte
+ BitcoinKey1Bytes route.Vertex
- // BitcoinKey2Bytes is the raw public key of the first node.
- BitcoinKey2Bytes [33]byte
+ // BitcoinKey2Bytes is the raw public key of the second node.
+ BitcoinKey2Bytes route.Vertex
// Features is the list of protocol features supported by this channel
// edge.
@@ -90,7 +91,7 @@ func (c *ChannelEdgeInfo) NodeKey2() (*btcec.PublicKey, error) {
// OtherNodeKeyBytes returns the node key bytes of the other end of the channel.
func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
- [33]byte, error) {
+ route.Vertex, error) {
switch {
case bytes.Equal(c.NodeKey1Bytes[:], thisNodeKey):
@@ -98,7 +99,7 @@ func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
case bytes.Equal(c.NodeKey2Bytes[:], thisNodeKey):
return c.NodeKey1Bytes, nil
default:
- return [33]byte{}, fmt.Errorf("node not participating in " +
+ return route.Vertex{}, fmt.Errorf("node not participating in " +
"this channel")
}
}
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.