Fix staking crash with large wallets + add -zapwallettxes

- ThreadStakeMiner: catch-and-retry instead of crash on exception
  (boost::bad_weak_ptr no longer kills the daemon)
- GetStakeWeight: take wallet lock once instead of per-coin to
  reduce lock contention with 20K+ transaction wallets
- StakeMiner: continue instead of exit when CreateNewBlock fails
- Wrap all NotifyTransactionChanged/NotifyAddressBookChanged signal
  emissions in try/catch to absorb stale slot exceptions
- Add -zapwallettxes flag: strips all tx records from wallet.dat
  keeping only keys, then rescans blockchain to rebuild history

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-03 23:12:21 -07:00
parent 64db028788
commit 014947580b
7 changed files with 163 additions and 30 deletions
+4 -1
View File
@@ -434,7 +434,10 @@ void StakeMiner(CWallet *pwallet)
int64_t nFees;
unique_ptr<CBlock> pblock(CreateNewBlock(pwallet, true, &nFees));
if (!pblock.get())
return;
{
MilliSleep(5000);
continue;
}
// Try to sign the block
if (pblock->SignBlock(*pwallet, nFees))