What changed, and why it matters
This is a routine code cleanup in the LND Lightning Network daemon. It removes unused helper methods and outdated comments from the internal graph database node model, and updates callers to use direct field assignments instead. There is no security-relevant change.
No security action required. Treat as normal refactoring and review for code quality if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors models.Node in graph/db/models/node.go by removing the AuthSig() and AddPubKey() methods, dropping an unused ecdsa import, and deleting stale TODO comments. Callers in tests and in routing/payment_session_source.go are updated to copy serialized public key bytes directly into PubKeyBytes rather than going through AddPubKey. The routing change also simplifies RouteHintsToEdges by using route.Vertex directly instead of constructing a temporary models.Node. No cryptographic, access-control, or network-facing behavior is altered.
Changed components
graph/db/models/node.gorouting/payment_session_source.goautopilot/prefattach_test.gorouting/pathfind_test.goInspect captured patch +13 / −39
diff --git a/autopilot/prefattach_test.go b/autopilot/prefattach_test.go
index 70f7e2b..d93cda2 100644
--- a/autopilot/prefattach_test.go
+++ b/autopilot/prefattach_test.go
@@ -429,7 +429,10 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
),
AuthSigBytes: testSig.Serialize(),
}
- graphNode.AddPubKey(pub)
+ copy(
+ graphNode.PubKeyBytes[:],
+ pub.SerializeCompressed(),
+ )
err := d.db.AddNode(
context.Background(), graphNode,
)
@@ -459,7 +462,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
),
AuthSigBytes: testSig.Serialize(),
}
- dbNode.AddPubKey(nodeKey)
+ copy(dbNode.PubKeyBytes[:], nodeKey.SerializeCompressed())
if err := d.db.AddNode(
context.Background(), dbNode,
); err != nil {
@@ -560,7 +563,7 @@ func (d *testDBGraph) addRandNode() (*btcec.PublicKey, error) {
),
AuthSigBytes: testSig.Serialize(),
}
- dbNode.AddPubKey(nodeKey)
+ copy(dbNode.PubKeyBytes[:], nodeKey.SerializeCompressed())
err = d.db.AddNode(context.Background(), dbNode)
if err != nil {
return nil, err
diff --git a/graph/db/models/node.go b/graph/db/models/node.go
index 23d6a42..d67aa4b 100644
--- a/graph/db/models/node.go
+++ b/graph/db/models/node.go
@@ -7,7 +7,6 @@ import (
"time"
"github.com/btcsuite/btcd/btcec/v2"
- "github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/lightningnetwork/lnd/lnwire"
)
@@ -53,11 +52,6 @@ type Node struct {
// and ensure we're able to make upgrades to the network in a forwards
// compatible manner.
ExtraOpaqueData []byte
-
- // TODO(roasbeef): discovery will need storage to keep it's last IP
- // address and re-announce if interface changes?
-
- // TODO(roasbeef): add update method and fetch?
}
// PubKey is the node's long-term identity public key. This key will be used to
@@ -79,22 +73,6 @@ func (l *Node) PubKey() (*btcec.PublicKey, error) {
return key, nil
}
-// AuthSig is a signature under the advertised public key which serves to
-// authenticate the attributes announced by this node.
-//
-// NOTE: By having this method to access an attribute, we ensure we only need
-// to fully deserialize the signature if absolutely necessary.
-func (l *Node) AuthSig() (*ecdsa.Signature, error) {
- return ecdsa.ParseSignature(l.AuthSigBytes)
-}
-
-// AddPubKey is a setter-link method that can be used to swap out the public
-// key for a node.
-func (l *Node) AddPubKey(key *btcec.PublicKey) {
- l.pubKey = key
- copy(l.PubKeyBytes[:], key.SerializeCompressed())
-}
-
// NodeAnnouncement retrieves the latest node announcement of the node.
func (l *Node) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement1,
error) {
diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go
index 77bad02..4414aa1 100644
--- a/routing/pathfind_test.go
+++ b/routing/pathfind_test.go
@@ -1250,11 +1250,9 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) {
dogePubKeyHex := "03dd46ff29a6941b4a2607525b043ec9b020b3f318a1bf281536fd7011ec59c882"
dogePubKeyBytes, err := hex.DecodeString(dogePubKeyHex)
require.NoError(t, err, "unable to decode public key")
- dogePubKey, err := btcec.ParsePubKey(dogePubKeyBytes)
- require.NoError(t, err, "unable to parse public key from bytes")
doge := &models.Node{}
- doge.AddPubKey(dogePubKey)
+ copy(doge.PubKeyBytes[:], dogePubKeyBytes[:])
doge.Alias = "doge"
copy(doge.PubKeyBytes[:], dogePubKeyBytes)
graph.aliasMap["doge"] = doge.PubKeyBytes
diff --git a/routing/payment_session_source.go b/routing/payment_session_source.go
index bc1088d..1582005 100644
--- a/routing/payment_session_source.go
+++ b/routing/payment_session_source.go
@@ -1,7 +1,6 @@
package routing
import (
- "github.com/btcsuite/btcd/btcec/v2"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch"
@@ -102,17 +101,13 @@ func RouteHintsToEdges(routeHints [][]zpay32.HopHint, target route.Vertex) (
// we'll need to look at the next hint's start node. If
// we've reached the end of the hints list, we can
// assume we've reached the destination.
- endNode := &models.Node{}
+ endNode := target
if i != len(routeHint)-1 {
- endNode.AddPubKey(routeHint[i+1].NodeID)
- } else {
- targetPubKey, err := btcec.ParsePubKey(
- target[:],
+ nodeID := routeHint[i+1].NodeID
+ copy(
+ endNode[:],
+ nodeID.SerializeCompressed(),
)
- if err != nil {
- return nil, err
- }
- endNode.AddPubKey(targetPubKey)
}
// Finally, create the channel edge from the hop hint
@@ -120,7 +115,7 @@ func RouteHintsToEdges(routeHints [][]zpay32.HopHint, target route.Vertex) (
// at the start of the channel.
edgePolicy := &models.CachedEdgePolicy{
ToNodePubKey: func() route.Vertex {
- return endNode.PubKeyBytes
+ return endNode
},
ToNodeFeatures: lnwire.EmptyFeatureVector(),
ChannelID: hopHint.ChannelID,
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.