From ec44a4b7b20727527e67ca5ee5b954f79a966af0 Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Thu, 24 Oct 2024 19:13:57 -0300 Subject: [PATCH] Add TODO for pending change and non-change handling #1592 --- zcash_client_sqlite/src/wallet/transparent.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zcash_client_sqlite/src/wallet/transparent.rs b/zcash_client_sqlite/src/wallet/transparent.rs index 97e6e803e..1c59c2785 100644 --- a/zcash_client_sqlite/src/wallet/transparent.rs +++ b/zcash_client_sqlite/src/wallet/transparent.rs @@ -386,6 +386,7 @@ pub(crate) fn add_transparent_account_balances( min_confirmations: u32, account_balances: &mut HashMap, ) -> Result<(), SqliteClientError> { + // TODO (#1592): Ability to distinguish between Transparent pending change and pending non-change let mut stmt_account_spendable_balances = conn.prepare( "SELECT u.account_id, SUM(u.value_zat) FROM transparent_received_outputs u @@ -394,7 +395,7 @@ pub(crate) fn add_transparent_account_balances( -- the transaction that created the output is mined and with enough confirmations WHERE ( t.mined_height < :mempool_height -- tx is mined - AND t.mined_height <= (t.mined_height - :min_confirmations) -- has at least min_confirmations + AND (:mempool_height - t.mined_height + 1) >= :min_confirmations -- has at least min_confirmations ) -- and the received txo is unspent AND u.id NOT IN ( @@ -434,7 +435,7 @@ pub(crate) fn add_transparent_account_balances( -- the transaction that created the output is mined with not enough confirmations or is definitely unexpired WHERE ( t.mined_height < :mempool_height - AND t.mined_height > (t.mined_height - :min_confirmations) -- tx is mined but not confirmed + AND (:mempool_height - t.mined_height + 1) < :min_confirmations -- tx is mined but not confirmed OR t.expiry_height = 0 -- tx will not expire OR t.expiry_height >= :mempool_height )