What changed, and why it matters
This commit adds a new database query to support v2 Lightning channel proofs. It simply updates a single signature column for v2 channels, whereas the older v1 proof format required four separate signatures. There is no security issue visible in the change itself.
No security action required. Review the callers of AddV2ChannelProof when they are added to ensure the signature parameter is properly validated and authorized before storage.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces AddV2ChannelProof, a SQL UPDATE statement that sets graph_channels.signature for rows matching a given short channel ID (scid) and version = 2. It is the v2 counterpart to the existing AddV1ChannelProof query. The change is purely additive: a new SQL query, generated Go wrapper, and interface method. No input validation, access control, or cryptographic logic is present in the diff.
Changed components
sqldb/sqlc/queries/graph.sqlsqldb/sqlc/graph.sql.gosqldb/sqlc/querier.goInspect captured patch +23 / −0
diff --git a/sqldb/sqlc/graph.sql.go b/sqldb/sqlc/graph.sql.go
index 0096d87..c08ba96 100644
--- a/sqldb/sqlc/graph.sql.go
+++ b/sqldb/sqlc/graph.sql.go
@@ -55,6 +55,22 @@ func (q *Queries) AddV1ChannelProof(ctx context.Context, arg AddV1ChannelProofPa
)
}
+const addV2ChannelProof = `-- name: AddV2ChannelProof :execresult
+UPDATE graph_channels
+SET signature = $2
+WHERE scid = $1
+ AND version = 2
+`
+
+type AddV2ChannelProofParams struct {
+ Scid []byte
+ Signature []byte
+}
+
+func (q *Queries) AddV2ChannelProof(ctx context.Context, arg AddV2ChannelProofParams) (sql.Result, error) {
+ return q.db.ExecContext(ctx, addV2ChannelProof, arg.Scid, arg.Signature)
+}
+
const countZombieChannels = `-- name: CountZombieChannels :one
SELECT COUNT(*)
FROM graph_zombie_channels
diff --git a/sqldb/sqlc/querier.go b/sqldb/sqlc/querier.go
index aa8ab2e..05bf918 100644
--- a/sqldb/sqlc/querier.go
+++ b/sqldb/sqlc/querier.go
@@ -13,6 +13,7 @@ import (
type Querier interface {
AddSourceNode(ctx context.Context, nodeID int64) error
AddV1ChannelProof(ctx context.Context, arg AddV1ChannelProofParams) (sql.Result, error)
+ AddV2ChannelProof(ctx context.Context, arg AddV2ChannelProofParams) (sql.Result, error)
ClearKVInvoiceHashIndex(ctx context.Context) error
CountZombieChannels(ctx context.Context, version int16) (int64, error)
CreateChannel(ctx context.Context, arg CreateChannelParams) (int64, error)
diff --git a/sqldb/sqlc/queries/graph.sql b/sqldb/sqlc/queries/graph.sql
index 549cc93..4f71fc8 100644
--- a/sqldb/sqlc/queries/graph.sql
+++ b/sqldb/sqlc/queries/graph.sql
@@ -312,6 +312,12 @@ SET node_1_signature = $2,
WHERE scid = $1
AND version = 1;
+-- name: AddV2ChannelProof :execresult
+UPDATE graph_channels
+SET signature = $2
+WHERE scid = $1
+ AND version = 2;
+
-- name: GetChannelsBySCIDRange :many
SELECT sqlc.embed(c),
n1.pub_key AS node1_pub_key,
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.