From 88851f5eea35036ecb92e33034d051f5da7acc6b Mon Sep 17 00:00:00 2001 From: DanS Date: Sat, 13 Jun 2026 10:06:46 -0500 Subject: [PATCH] fix(history): unstick the unconfirmed-tx badge on confirmed shields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The History badge counts transactions with confirmations==0, iterating the raw transaction list. Autoshield transactions have two legs sharing one txid, and the send leg parsed from z_viewtransaction carries confirmations=0 even when the transaction is long confirmed (the receive leg holds the real count). So the badge counted those stale legs and stuck at a non-zero number (e.g. 7) with no pending transactions. Treat a txid with ANY confirmed leg as confirmed, and count UNIQUE unconfirmed txids rather than legs — so confirmed multi-leg transactions don't inflate the badge and genuinely pending ones still count once each. Co-Authored-By: Claude Opus 4.8 --- src/app.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index d890ebb..521ea28 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -1277,13 +1277,24 @@ void App::render() if (gradient_tex_ != 0) { sbStatus.gradientTexID = gradient_tex_; } - // Count unconfirmed transactions (pending in mempool, not conflicted/orphaned) + // Count unconfirmed transactions (pending in mempool, not conflicted/orphaned). + // A transaction can appear as multiple legs sharing one txid (e.g. an autoshield send+receive), + // and a leg parsed from z_viewtransaction may carry confirmations=0 even when the transaction is + // long confirmed (the other leg holds the real count). So: a txid with ANY confirmed leg is + // confirmed, and we count UNIQUE unconfirmed txids — otherwise the badge sticks on stale 0-conf + // legs of already-confirmed transactions and double-counts multi-leg ones. { - int unconf = 0; + std::unordered_set confirmedTxids; for (const auto& tx : state_.transactions) { - if (tx.confirmations == 0) ++unconf; + if (tx.confirmations >= 1) confirmedTxids.insert(tx.txid); } - sbStatus.unconfirmedTxCount = unconf; + std::unordered_set unconfirmedTxids; + for (const auto& tx : state_.transactions) { + if (tx.confirmations == 0 && confirmedTxids.find(tx.txid) == confirmedTxids.end()) { + unconfirmedTxids.insert(tx.txid); + } + } + sbStatus.unconfirmedTxCount = static_cast(unconfirmedTxids.size()); } // Sidebar margins from ui.toml schema (DPI-scaled like all sidebar values)