What changed, and why it matters
This commit adds a new helper function and data structure for creating version 2 node announcements in the Lightning Network graph database. It is a straightforward feature addition with no visible security bug or fix.
No security action required; review as normal feature code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces NodeV2Fields and NewV2Node in graph/db/models/node.go to construct models.Node values for gossip version 2. It also adds a LastBlockHeight field to Node and an ExtraSignedFields map for carrying unparsed but signed v2 fields. The change mirrors the existing NewV1Node constructor and appears to be part of protocol support work rather than a security patch.
Changed components
graph/db/models/node.goInspect captured patch +58 / −1
diff --git a/graph/db/models/node.go b/graph/db/models/node.go
index 9a045d5..7f3ce77 100644
--- a/graph/db/models/node.go
+++ b/graph/db/models/node.go
@@ -27,6 +27,11 @@ type Node struct {
// been updated.
LastUpdate time.Time
+ // LastBlockHeight is the block height that timestamps the last update
+ // we received for this node. This is only used if this is a V2 node
+ // announcement.
+ LastBlockHeight uint32
+
// Address is the TCP address this node is reachable over.
Addresses []net.Addr
@@ -49,8 +54,13 @@ type Node struct {
// parse. By holding onto this data, we ensure that we're able to
// properly validate the set of signatures that cover these new fields,
// and ensure we're able to make upgrades to the network in a forwards
- // compatible manner.
+ // compatible manner. This is only used for V1 node announcements.
ExtraOpaqueData []byte
+
+ // ExtraSignedFields is a map of extra fields that are covered by the
+ // node announcement's signature that we have not explicitly parsed.
+ // This is only used for version 2 node announcements and beyond.
+ ExtraSignedFields map[uint64][]byte
}
// NodeV1Fields houses the fields that are specific to a version 1 node
@@ -103,6 +113,53 @@ func NewV1Node(pub route.Vertex, n *NodeV1Fields) *Node {
}
}
+// NodeV2Fields houses the fields that are specific to a version 2 node
+// announcement.
+type NodeV2Fields struct {
+ // LastBlockHeight is the block height that timestamps the last update
+ // we received for this node.
+ LastBlockHeight uint32
+
+ // Address is the TCP address this node is reachable over.
+ Addresses []net.Addr
+
+ // Color is the selected color for the node.
+ Color fn.Option[color.RGBA]
+
+ // Alias is a nick-name for the node. The alias can be used to confirm
+ // a node's identity or to serve as a short ID for an address book.
+ Alias fn.Option[string]
+
+ // Signature is the schnorr signature under the advertised public key
+ // which serves to authenticate the attributes announced by this node.
+ Signature []byte
+
+ // Features is the list of protocol features supported by this node.
+ Features *lnwire.RawFeatureVector
+
+ // ExtraSignedFields is a map of extra fields that are covered by the
+ // node announcement's signature that we have not explicitly parsed.
+ ExtraSignedFields map[uint64][]byte
+}
+
+// NewV2Node creates a new version 2 node from the passed fields.
+func NewV2Node(pub route.Vertex, n *NodeV2Fields) *Node {
+ return &Node{
+ Version: lnwire.GossipVersion2,
+ PubKeyBytes: pub,
+ Addresses: n.Addresses,
+ AuthSigBytes: n.Signature,
+ Features: lnwire.NewFeatureVector(
+ n.Features, lnwire.Features,
+ ),
+ LastBlockHeight: n.LastBlockHeight,
+ Color: n.Color,
+ Alias: n.Alias,
+ LastUpdate: time.Unix(0, 0),
+ ExtraSignedFields: n.ExtraSignedFields,
+ }
+}
+
// NewV1ShellNode creates a new shell version 1 node.
func NewV1ShellNode(pubKey route.Vertex) *Node {
return NewShellNode(lnwire.GossipVersion1, pubKey)
Why this scored 12/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.