sqldb/sqlc: update graph CreateChannel query for v2
What changed, and why it matters
This commit updates a database query used to store Lightning Network channel announcements. It adds three new optional fields needed for newer 'v2' channel types (a single Schnorr signature, the funding output script, and a Merkle root hash). For older 'v1' channels these fields are left empty/NULL. There is no security fix or vulnerability here; it is a straightforward schema/query update to support a new channel format.
No security action required. Treat as a normal feature/schema update. Ensure downstream database migrations add the corresponding nullable columns before this code is deployed.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change extends the CreateChannel SQL query and its generated Go wrapper to insert three additional nullable columns into the graph_channels table: signature (Schnorr), funding_pk_script, and merkle_root_hash. The CreateChannelParams struct and the Queries.CreateChannel method are updated to pass these new parameters. The columns are optional and NULL for v1 channels, populated for v2/taproot channels. No validation logic, cryptographic checks, or access-control changes are present in the diff.
Changed components
sqldb/sqlc/queries/graph.sqlsqldb/sqlc/graph.sql.goCreateChannel query/methodInspect captured patch +10 / −4
diff --git a/sqldb/sqlc/graph.sql.go b/sqldb/sqlc/graph.sql.go
index 2c26eb5..0096d87 100644
--- a/sqldb/sqlc/graph.sql.go
+++ b/sqldb/sqlc/graph.sql.go
@@ -78,9 +78,9 @@ INSERT INTO graph_channels (
version, scid, node_id_1, node_id_2,
outpoint, capacity, bitcoin_key_1, bitcoin_key_2,
node_1_signature, node_2_signature, bitcoin_1_signature,
- bitcoin_2_signature
+ bitcoin_2_signature, signature, funding_pk_script, merkle_root_hash
) VALUES (
- $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15
)
RETURNING id
`
@@ -98,6 +98,9 @@ type CreateChannelParams struct {
Node2Signature []byte
Bitcoin1Signature []byte
Bitcoin2Signature []byte
+ Signature []byte
+ FundingPkScript []byte
+ MerkleRootHash []byte
}
func (q *Queries) CreateChannel(ctx context.Context, arg CreateChannelParams) (int64, error) {
@@ -114,6 +117,9 @@ func (q *Queries) CreateChannel(ctx context.Context, arg CreateChannelParams) (i
arg.Node2Signature,
arg.Bitcoin1Signature,
arg.Bitcoin2Signature,
+ arg.Signature,
+ arg.FundingPkScript,
+ arg.MerkleRootHash,
)
var id int64
err := row.Scan(&id)
diff --git a/sqldb/sqlc/queries/graph.sql b/sqldb/sqlc/queries/graph.sql
index 2df865d..549cc93 100644
--- a/sqldb/sqlc/queries/graph.sql
+++ b/sqldb/sqlc/queries/graph.sql
@@ -297,9 +297,9 @@ INSERT INTO graph_channels (
version, scid, node_id_1, node_id_2,
outpoint, capacity, bitcoin_key_1, bitcoin_key_2,
node_1_signature, node_2_signature, bitcoin_1_signature,
- bitcoin_2_signature
+ bitcoin_2_signature, signature, funding_pk_script, merkle_root_hash
) VALUES (
- $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15
)
RETURNING id;
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.