graph/db: treat empty channel signatures as missing
This commit improves handling of missing channel signatures in the database: - Return nil from auth proof accessors instead of empty slices so that missing signatures are stored as NULL in SQL. - Update public channel checks to require signature length > 0, which properly handles existing empty bytea values in the database. - Add regression test covering empty v1 and v2 channel signatures to prevent future issues.
This commit is contained in:
5 files changed
+85
-27
No files matched your search
@@ -101,14 +101,14 @@ SELECT EXISTS (
|
||||
-- one of the signatures since we only ever set them
|
||||
-- together.
|
||||
WHERE c.version = 1
|
||||
AND c.bitcoin_1_signature IS NOT NULL
|
||||
AND COALESCE(length(c.bitcoin_1_signature), 0) > 0
|
||||
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 = 1
|
||||
AND c.bitcoin_1_signature IS NOT NULL
|
||||
AND COALESCE(length(c.bitcoin_1_signature), 0) > 0
|
||||
AND n.pub_key = $1
|
||||
);
|
||||
|
||||
@@ -121,7 +121,7 @@ SELECT EXISTS (
|
||||
-- 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 COALESCE(length(c.signature), 0) > 0
|
||||
AND n.pub_key = $1
|
||||
|
||||
UNION ALL
|
||||
@@ -251,7 +251,7 @@ WHERE last_update >= @start_time
|
||||
SELECT 1
|
||||
FROM graph_channels c
|
||||
WHERE c.version = 1
|
||||
AND c.bitcoin_1_signature IS NOT NULL
|
||||
AND COALESCE(length(c.bitcoin_1_signature), 0) > 0
|
||||
AND (c.node_id_1 = graph_nodes.id OR c.node_id_2 = graph_nodes.id)
|
||||
)
|
||||
)
|
||||
@@ -731,7 +731,7 @@ WHERE c.version = $1
|
||||
-- name: GetPublicV1ChannelsBySCID :many
|
||||
SELECT *
|
||||
FROM graph_channels
|
||||
WHERE node_1_signature IS NOT NULL
|
||||
WHERE COALESCE(length(node_1_signature), 0) > 0
|
||||
AND scid >= @start_scid
|
||||
AND scid < @end_scid;
|
||||
|
||||
@@ -1217,4 +1217,4 @@ ON CONFLICT (channel_id, node_id, version)
|
||||
message_flags = EXCLUDED.message_flags,
|
||||
channel_flags = EXCLUDED.channel_flags,
|
||||
signature = EXCLUDED.signature
|
||||
RETURNING id;
|
||||
RETURNING id;
|
||||
Reference in new issue
Block a user