From 34f74c71ce1fa79db4ec68b147c6540b131f1e41 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 19 Nov 2025 08:07:17 +0200 Subject: [PATCH] graph/db: use route.Vertex for channel keys Replace [33]byte with route.Vertex for NodeKey1Bytes, NodeKey2Bytes, BitcoinKey1Bytes, and BitcoinKey2Bytes in ChannelEdgeInfo. Since route.Vertex is defined as [33]byte, this change is functionally equivalent but provides better type safety and consistency with the rest of the routing subsystem. OtherNodeKeyBytes is also updated to return route.Vertex. --- graph/db/kv_store.go | 6 +++--- graph/db/models/channel_edge_info.go | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 021f4a3c5..85b93caed 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 0d6cd04f0..cfa7e1e6a 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") } }