graph/db: remove unused sig field from ChannelEdgePolicy
What changed, and why it matters
This commit removes an unused internal cache field that stored a parsed cryptographic signature alongside the raw signature bytes. It is a straightforward code cleanup with no security-relevant behavior change: callers still access the raw signature bytes, and the only consumer is updated to set the field directly instead of through a helper method.
No security action required. Treat as normal refactoring/cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes the sig *ecdsa.Signature cached field and the Signature() lazy getter from graph/db/models.ChannelEdgePolicy. It also removes SetSigBytes, replacing its single remaining use in routing/localchans/manager.go with a direct assignment to edge.SigBytes = nil. The raw signature storage (SigBytes) and all external interfaces remain unchanged.
Changed components
graph/db/models/channel_edge_policy.gorouting/localchans/manager.goInspect captured patch +2 / −34
diff --git a/graph/db/models/channel_edge_policy.go b/graph/db/models/channel_edge_policy.go
index 48d748e..a2661ef 100644
--- a/graph/db/models/channel_edge_policy.go
+++ b/graph/db/models/channel_edge_policy.go
@@ -4,7 +4,6 @@ import (
"fmt"
"time"
- "github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwire"
)
@@ -17,13 +16,9 @@ import (
type ChannelEdgePolicy struct {
// SigBytes is the raw bytes of the signature of the channel edge
// policy. We'll only parse these if the caller needs to access the
- // signature for validation purposes. Do not set SigBytes directly, but
- // use SetSigBytes instead to make sure that the cache is invalidated.
+ // signature for validation purposes.
SigBytes []byte
- // sig is a cached fully parsed signature.
- sig *ecdsa.Signature
-
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
@@ -84,33 +79,6 @@ type ChannelEdgePolicy struct {
ExtraOpaqueData lnwire.ExtraOpaqueData
}
-// Signature is a channel announcement signature, which is needed for proper
-// edge policy announcement.
-//
-// NOTE: By having this method to access an attribute, we ensure we only need
-// to fully deserialize the signature if absolutely necessary.
-func (c *ChannelEdgePolicy) Signature() (*ecdsa.Signature, error) {
- if c.sig != nil {
- return c.sig, nil
- }
-
- sig, err := ecdsa.ParseSignature(c.SigBytes)
- if err != nil {
- return nil, err
- }
-
- c.sig = sig
-
- return sig, nil
-}
-
-// SetSigBytes updates the signature and invalidates the cached parsed
-// signature.
-func (c *ChannelEdgePolicy) SetSigBytes(sig []byte) {
- c.SigBytes = sig
- c.sig = nil
-}
-
// IsDisabled determines whether the edge has the disabled bit set.
func (c *ChannelEdgePolicy) IsDisabled() bool {
return c.ChannelFlags.IsDisabled()
diff --git a/routing/localchans/manager.go b/routing/localchans/manager.go
index a48486e..1a7c1d5 100644
--- a/routing/localchans/manager.go
+++ b/routing/localchans/manager.go
@@ -449,7 +449,7 @@ func (r *Manager) updateEdge(chanPoint wire.OutPoint,
}
// Clear signature to help prevent usage of the previous signature.
- edge.SetSigBytes(nil)
+ edge.SigBytes = nil
return nil
}
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.