From e2210cf5d34477beaeff2f8220eb979cc133694f Mon Sep 17 00:00:00 2001 From: DanS Date: Wed, 14 Oct 2026 07:51:34 -0500 Subject: [PATCH] fix(lite): refresh the sidebar unconfirmed badge on confirmations The sidebar unconfirmed-tx badge was recomputed only when the tx list changed, keyed on last_tx_update plus the list size. That missed the one case that matters most: a transaction confirming without the list count changing. last_tx_update did not move for a same-second content change, and lite never stamped it at all, so the badge stuck on a stale 0-conf count until some unrelated refresh happened to shift the list size. - The badge now keys on tx_revision, which the state bumps on every content change - including a confirmation flip at an unchanged tx count - and which lite stamps too, so the count tracks confirmations on both the full node and the lite wallet. - The sentinel starts at 0, which tx_revision never takes (it starts at 1), so the first frame always computes once. - The recompute still runs only when the revision actually moved, so the per-frame work the previous guard avoided is still avoided. Co-Authored-By: Claude Opus 4.8 --- src/app.cpp | 9 ++++----- src/app.h | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index 1e54a6b..7e12b0a 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -2163,10 +2163,10 @@ void App::render() // 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. - // Recompute only when the tx list actually changed (last_tx_update is bumped on every tx refresh; - // size() catches same-second content changes). Otherwise this built two unordered_sets over the whole + // Recompute only when the tx list actually changed. tx_revision moves on EVERY content change (incl. a + // confirmation flip at equal tx count) and, unlike last_tx_update, lite stamps it. Otherwise this built two unordered_sets over the whole // wallet tx list every frame just to size a badge. - if (state_.last_tx_update != sb_unconf_key_ts_ || state_.transactions.size() != sb_unconf_key_n_) { + if (state_.tx_revision != sb_unconf_key_rev_) { std::unordered_set confirmedTxids; for (const auto& tx : state_.transactions) { if (tx.confirmations >= 1) confirmedTxids.insert(tx.txid); @@ -2178,8 +2178,7 @@ void App::render() } } sb_unconf_count_ = static_cast(unconfirmedTxids.size()); - sb_unconf_key_ts_ = state_.last_tx_update; - sb_unconf_key_n_ = state_.transactions.size(); + sb_unconf_key_rev_ = state_.tx_revision; } sbStatus.unconfirmedTxCount = sb_unconf_count_; diff --git a/src/app.h b/src/app.h index eecd018..fe37fab 100644 --- a/src/app.h +++ b/src/app.h @@ -1006,10 +1006,9 @@ private: mutable std::uint64_t chat_unread_rev_ = ~0ull; // ~0 forces the first compute mutable int chat_unread_cached_ = 0; mutable double chat_unread_computed_at_ = 0.0; - // Sidebar unconfirmed-tx badge — recomputed only when the tx list changes (keyed on last_tx_update + - // size), not every frame. See App::render(). - std::int64_t sb_unconf_key_ts_ = -1; - std::size_t sb_unconf_key_n_ = 0; + // Sidebar unconfirmed-tx badge — recomputed only when the tx list changes (keyed on tx_revision), + // not every frame. See App::render(). + std::uint64_t sb_unconf_key_rev_ = 0; // sentinel 0 never matches: tx_revision starts at 1 int sb_unconf_count_ = 0; // Daemon-memory probe is expensive (/proc scan on Linux, popen on macOS): it runs on this sampler's own // thread, at most once per 3 s and only while a reader asks (Mining tab memory bar, Peers tab Memory cell).