fix(history): update tx labels immediately when a mining address is toggled

Unmarking (or marking) a mining address didn't change the history. The refresh
re-scanned the affected transaction as "receive", but appendMissingPreviousTransactions
carries over not-yet-rescanned prior transactions and dedupes by txid+TYPE — so
the stale "mined" copy was carried over right alongside the fresh "receive", and
the change never appeared.

Re-label state_.transactions in setMiningAddress() the moment the flag changes
(mined vs receive is just whether the receiving address is mining-flagged). The
History tab updates instantly, and the next refresh's carry-over now matches the
fresh scan instead of duplicating the old label. The reclassified list is also
persisted via the existing cache save.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 09:13:36 -05:00
parent 2b70ee5cd8
commit 555f541c84

View File

@@ -2070,6 +2070,20 @@ void App::setMiningAddress(const std::string& addr, bool mining)
if (settings_) {
settings_->setMiningAddress(addr, mining);
settings_->save();
// Re-label the in-memory history right away. "mined" vs "receive" is purely a function of
// whether the receiving address is flagged for mining, so flip the affected rows now: the
// History tab updates immediately, and — importantly — the next refresh's carry-over of
// not-yet-rescanned transactions then matches the fresh scan. (Without this, the refresh
// re-scans a tx as "receive" but appendMissingPreviousTransactions, which dedupes by
// txid+type, still carries the stale "mined" copy over, so the change never showed.)
const auto miningAddrs = settings_->getMiningAddresses();
for (auto& tx : state_.transactions) {
if ((tx.type == "receive" || tx.type == "mined") && !tx.address.empty()) {
tx.type = miningAddrs.count(tx.address) ? "mined" : "receive";
}
}
invalidateShieldedHistoryScanProgress(true);
transactions_dirty_ = true;
last_tx_block_height_ = -1;