@@ -386,6 +386,7 @@ pub(crate) fn add_transparent_account_balances(
386
386
min_confirmations : u32 ,
387
387
account_balances : & mut HashMap < AccountId , AccountBalance > ,
388
388
) -> Result < ( ) , SqliteClientError > {
389
+ // TODO (#1592): Ability to distinguish between Transparent pending change and pending non-change
389
390
let mut stmt_account_spendable_balances = conn. prepare (
390
391
"SELECT u.account_id, SUM(u.value_zat)
391
392
FROM transparent_received_outputs u
@@ -394,7 +395,7 @@ pub(crate) fn add_transparent_account_balances(
394
395
-- the transaction that created the output is mined and with enough confirmations
395
396
WHERE (
396
397
t.mined_height < :mempool_height -- tx is mined
397
- AND t.mined_height <= ( t.mined_height - :min_confirmations) -- has at least min_confirmations
398
+ AND (:mempool_height - t.mined_height + 1) >= :min_confirmations -- has at least min_confirmations
398
399
)
399
400
-- and the received txo is unspent
400
401
AND u.id NOT IN (
@@ -434,7 +435,7 @@ pub(crate) fn add_transparent_account_balances(
434
435
-- the transaction that created the output is mined with not enough confirmations or is definitely unexpired
435
436
WHERE (
436
437
t.mined_height < :mempool_height
437
- AND t.mined_height > ( t.mined_height - :min_confirmations) -- tx is mined but not confirmed
438
+ AND (:mempool_height - t.mined_height + 1) < :min_confirmations -- tx is mined but not confirmed
438
439
OR t.expiry_height = 0 -- tx will not expire
439
440
OR t.expiry_height >= :mempool_height
440
441
)
0 commit comments