From 315f5ed741220ac105287454dd260e2572c81d9b Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 19 Nov 2025 17:19:53 +0200 Subject: [PATCH] sqldb/sqlc: add AddV2ChannelProof query Add SQL query to update the signature column for v2 channel auth proofs. Unlike v1 which requires four separate signatures, v2 channels use a single aggregated signature. --- sqldb/sqlc/graph.sql.go | 16 ++++++++++++++++ sqldb/sqlc/querier.go | 1 + sqldb/sqlc/queries/graph.sql | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/sqldb/sqlc/graph.sql.go b/sqldb/sqlc/graph.sql.go index 0096d87ec..c08ba967f 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 aa8ab2ecf..05bf91877 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 549cc930b..4f71fc8fa 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,