db: fix the list_txids query
We need to limit the number of *distinct* txids. Limiting the number of results in the inner queries at all could lead to incorrect results with regard to ordering too. See https://github.com/revault/liana/pull/99#discussion_r1029619579.
This commit is contained in:
parent
774f969594
commit
1f06c4d4dc
@ -500,14 +500,14 @@ impl SqliteConn {
|
||||
SELECT txid, blocktime AS date FROM coins \
|
||||
WHERE blocktime >= (?1) \
|
||||
AND blocktime <= (?2) \
|
||||
ORDER BY blocktime DESC LIMIT (?3) \
|
||||
ORDER BY blocktime \
|
||||
) \
|
||||
UNION \
|
||||
SELECT * FROM (
|
||||
SELECT spend_txid AS txid, spend_block_time AS date FROM coins \
|
||||
WHERE spend_block_time >= (?1) \
|
||||
AND spend_block_time <= (?2) \
|
||||
ORDER BY spend_block_time DESC LIMIT (?3) \
|
||||
ORDER BY spend_block_time \
|
||||
) \
|
||||
ORDER BY date DESC LIMIT (?3) \
|
||||
)",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user