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.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:21 +02:00
1 parent 6fda2e8da9
commit 34f74c71ce
2 files changed
+12 -11

No files matched your search

+3 -3
View File
@@ -1262,9 +1262,9 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx,
// Mark edge policies for both sides as unknown. This is to enable // Mark edge policies for both sides as unknown. This is to enable
// efficient incoming channel lookup for a node. // efficient incoming channel lookup for a node.
keys := []*[33]byte{ keys := []route.Vertex{
&edge.NodeKey1Bytes, edge.NodeKey1Bytes,
&edge.NodeKey2Bytes, edge.NodeKey2Bytes,
} }
for _, key := range keys { for _, key := range keys {
err := putChanEdgePolicyUnknown(edges, edge.ChannelID, key[:]) err := putChanEdgePolicyUnknown(edges, edge.ChannelID, key[:])
+9 -8
View File
@@ -10,6 +10,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
) )
// ChannelEdgeInfo represents a fully authenticated channel along with all its // ChannelEdgeInfo represents a fully authenticated channel along with all its
@@ -29,16 +30,16 @@ type ChannelEdgeInfo struct {
ChainHash chainhash.Hash ChainHash chainhash.Hash
// NodeKey1Bytes is the raw public key of the first node. // 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 is the raw public key of the second node.
NodeKey2Bytes [33]byte NodeKey2Bytes route.Vertex
// BitcoinKey1Bytes is the raw public key of the first node. // 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 is the raw public key of the second node.
BitcoinKey2Bytes [33]byte BitcoinKey2Bytes route.Vertex
// Features is the list of protocol features supported by this channel // Features is the list of protocol features supported by this channel
// edge. // 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. // OtherNodeKeyBytes returns the node key bytes of the other end of the channel.
func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) ( func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
[33]byte, error) { route.Vertex, error) {
switch { switch {
case bytes.Equal(c.NodeKey1Bytes[:], thisNodeKey): case bytes.Equal(c.NodeKey1Bytes[:], thisNodeKey):
@@ -98,7 +99,7 @@ func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
case bytes.Equal(c.NodeKey2Bytes[:], thisNodeKey): case bytes.Equal(c.NodeKey2Bytes[:], thisNodeKey):
return c.NodeKey1Bytes, nil return c.NodeKey1Bytes, nil
default: default:
return [33]byte{}, fmt.Errorf("node not participating in " + return route.Vertex{}, fmt.Errorf("node not participating in " +
"this channel") "this channel")
} }
} }