From 7c7a0ae13d9920da1ba532a34f729b960bc782b3 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Tue, 17 Feb 2026 10:08:59 +0200 Subject: [PATCH] graph/db: fetch policy version in cache paginated query The ListChannelsWithPoliciesForCachePaginated query was missing the policy version column, causing extractChannelPolicies to hardcode lnwire.GossipVersion1 for that row type. Add cp1.version and cp2.version to the query and use the fetched values instead. --- graph/db/sql_store.go | 4 ++-- sqldb/sqlc/graph.sql.go | 6 ++++++ sqldb/sqlc/queries/graph.sql | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 2841b9666..a04a70aba 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -5082,7 +5082,7 @@ func extractChannelPolicies(row any) (*sqlc.GraphChannelPolicy, case sqlc.ListChannelsWithPoliciesForCachePaginatedRow: if r.Policy1Timelock.Valid { policy1 = &sqlc.GraphChannelPolicy{ - Version: int16(lnwire.GossipVersion1), + Version: r.Policy1Version.Int16, Timelock: r.Policy1Timelock.Int32, FeePpm: r.Policy1FeePpm.Int64, BaseFeeMsat: r.Policy1BaseFeeMsat.Int64, @@ -5099,7 +5099,7 @@ func extractChannelPolicies(row any) (*sqlc.GraphChannelPolicy, } if r.Policy2Timelock.Valid { policy2 = &sqlc.GraphChannelPolicy{ - Version: int16(lnwire.GossipVersion1), + Version: r.Policy2Version.Int16, Timelock: r.Policy2Timelock.Int32, FeePpm: r.Policy2FeePpm.Int64, BaseFeeMsat: r.Policy2BaseFeeMsat.Int64, diff --git a/sqldb/sqlc/graph.sql.go b/sqldb/sqlc/graph.sql.go index b0d1f78dd..6293ef249 100644 --- a/sqldb/sqlc/graph.sql.go +++ b/sqldb/sqlc/graph.sql.go @@ -3334,6 +3334,7 @@ SELECT n2.pub_key AS node2_pubkey, -- Node 1 policy + cp1.version AS policy1_version, cp1.timelock AS policy_1_timelock, cp1.fee_ppm AS policy_1_fee_ppm, cp1.base_fee_msat AS policy_1_base_fee_msat, @@ -3348,6 +3349,7 @@ SELECT cp1.disable_flags AS policy1_disable_flags, -- Node 2 policy + cp2.version AS policy2_version, cp2.timelock AS policy_2_timelock, cp2.fee_ppm AS policy_2_fee_ppm, cp2.base_fee_msat AS policy_2_base_fee_msat, @@ -3385,6 +3387,7 @@ type ListChannelsWithPoliciesForCachePaginatedRow struct { Capacity sql.NullInt64 Node1Pubkey []byte Node2Pubkey []byte + Policy1Version sql.NullInt16 Policy1Timelock sql.NullInt32 Policy1FeePpm sql.NullInt64 Policy1BaseFeeMsat sql.NullInt64 @@ -3397,6 +3400,7 @@ type ListChannelsWithPoliciesForCachePaginatedRow struct { Policy1ChannelFlags sql.NullInt16 Policy1BlockHeight sql.NullInt64 Policy1DisableFlags sql.NullInt16 + Policy2Version sql.NullInt16 Policy2Timelock sql.NullInt32 Policy2FeePpm sql.NullInt64 Policy2BaseFeeMsat sql.NullInt64 @@ -3426,6 +3430,7 @@ func (q *Queries) ListChannelsWithPoliciesForCachePaginated(ctx context.Context, &i.Capacity, &i.Node1Pubkey, &i.Node2Pubkey, + &i.Policy1Version, &i.Policy1Timelock, &i.Policy1FeePpm, &i.Policy1BaseFeeMsat, @@ -3438,6 +3443,7 @@ func (q *Queries) ListChannelsWithPoliciesForCachePaginated(ctx context.Context, &i.Policy1ChannelFlags, &i.Policy1BlockHeight, &i.Policy1DisableFlags, + &i.Policy2Version, &i.Policy2Timelock, &i.Policy2FeePpm, &i.Policy2BaseFeeMsat, diff --git a/sqldb/sqlc/queries/graph.sql b/sqldb/sqlc/queries/graph.sql index 2cc2b22c5..ec44bc015 100644 --- a/sqldb/sqlc/queries/graph.sql +++ b/sqldb/sqlc/queries/graph.sql @@ -834,6 +834,7 @@ SELECT n2.pub_key AS node2_pubkey, -- Node 1 policy + cp1.version AS policy1_version, cp1.timelock AS policy_1_timelock, cp1.fee_ppm AS policy_1_fee_ppm, cp1.base_fee_msat AS policy_1_base_fee_msat, @@ -848,6 +849,7 @@ SELECT cp1.disable_flags AS policy1_disable_flags, -- Node 2 policy + cp2.version AS policy2_version, cp2.timelock AS policy_2_timelock, cp2.fee_ppm AS policy_2_fee_ppm, cp2.base_fee_msat AS policy_2_base_fee_msat,