fix(history): unstick the unconfirmed-tx badge on confirmed shields

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 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 10:06:46 -05:00
parent 5796664b51
commit 88851f5eea

View File

@@ -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<std::string> 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<std::string> 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<int>(unconfirmedTxids.size());
}
// Sidebar margins from ui.toml schema (DPI-scaled like all sidebar values)