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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-10-01 13:49:19 +09:30
parent a05a3748d3
commit bee54f0ef6

View File

@@ -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)