sqldb/sqlc: add IsPublicV2Node query

Add SQL query to determine if a node has public v2 channels. Unlike
v1 which requires all four individual signatures, v2 channels are
considered public when the single aggregated signature is present.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:23 +02:00
1 parent b3cf9a806f
commit a99604c7d7
3 files changed
+53

No files matched your search

+22
View File
@@ -112,6 +112,28 @@ SELECT EXISTS (
AND n.pub_key = $1
);
-- name: IsPublicV2Node :one
SELECT EXISTS (
SELECT 1
FROM graph_channels c
JOIN graph_nodes n ON n.id = c.node_id_1
-- NOTE: we hard-code the version here since the clauses
-- here that determine if a node is public is specific
-- to the V2 gossip protocol.
WHERE c.version = 2
AND c.signature IS NOT NULL
AND n.pub_key = $1
UNION ALL
SELECT 1
FROM graph_channels c
JOIN graph_nodes n ON n.id = c.node_id_2
WHERE c.version = 2
AND COALESCE(length(c.signature), 0) > 0
AND n.pub_key = $1
);
-- name: DeleteUnconnectedNodes :many
DELETE FROM graph_nodes
WHERE