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 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 07:51:34 -05:00
co-authored by Claude Opus 4.8
parent 25ad23aee4
commit e2210cf5d3
2 changed files with 7 additions and 9 deletions
+4 -5
View File
@@ -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<std::string> 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<int>(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_;