From bee54f0ef65aca889198facfafd5ea17690ee50e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 1 Oct 2025 13:49:19 +0930 Subject: [PATCH] wallet: don't show htlcs from closed channels in listhtlcs. This doesn't happen yet, since we delete all HTLCs when we close a channel. But we're about to change that, so update the wallet_htlcs_first() code to avoid them. Signed-off-by: Rusty Russell --- wallet/wallet.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wallet/wallet.c b/wallet/wallet.c index ddc933d70..1c7ad2337 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -6558,7 +6558,8 @@ struct wallet_htlc_iter *wallet_htlcs_first(const tal_t *ctx, ", h.updated_index" " FROM channel_htlcs h" " JOIN channels ON channels.id = h.channel_id" - " WHERE h.updated_index >= ?" + " WHERE channels.state != ?" + " AND h.updated_index >= ?" " ORDER BY h.updated_index ASC" " LIMIT ?;")); } else { @@ -6575,10 +6576,12 @@ struct wallet_htlc_iter *wallet_htlcs_first(const tal_t *ctx, ", h.updated_index" " FROM channel_htlcs h" " JOIN channels ON channels.id = h.channel_id" - " WHERE h.id >= ?" + " WHERE channels.state != ?" + " AND h.id >= ?" " ORDER BY h.id ASC" " LIMIT ?;")); } + db_bind_int(i->stmt, channel_state_in_db(CLOSED)); } db_bind_u64(i->stmt, liststart); if (listlimit)