fix(net): stop re-running the connect sequence while the wallet is locked

Connected-but-locked fell through to tryConnect() on every Core tick
while the lock screen sat idle: new sockets, getinfo and getwalletinfo,
a forced address scan, a CoinGecko fetch and a wallet-index rewrite.
Its wallet scans also held cs_main ahead of the user's
walletpassphrase.

- While locked, poll chain state only (refreshCoreData without the
  balance). That keeps the sync height current and the 3-strike
  lost-connection check armed, so a node that exits while locked is
  still restarted. Pool mining keeps the lock screen down, so while it
  runs the throttled balance, the peers and the lock state (for an
  unlock done in the Console tab) keep refreshing too.
- Warmup polls count refused/reset connections toward the
  lost-connection check, so a node that died during warmup is
  restarted instead of leaving the loading or lock screen over it.
- The wallet salvage/degraded detectors run at connect and again when
  warmup ends: for encrypted wallets they relied on the repeated
  tryConnect.
- restartDaemonAfterEncryption records the wallet as encrypted and
  locked itself (the wizard's deferred path never did), and marks the
  main client disconnected so the reconnect path picks up the restarted
  node, aborting any in-flight call first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 19:52:09 -05:00
co-authored by Claude Opus 5.5
parent 575abd4bcc
commit 1cb03332e7
6 changed files with 69 additions and 3 deletions
+19
View File
@@ -1441,6 +1441,25 @@ void App::update()
if (network_refresh_.consumeDue(RefreshTimer::Peers)) {
refreshPeerInfo();
}
} else if (rpcConnected && state_.isLocked()) {
// Connected but locked is still connected. This used to fall through to tryConnect(), which
// re-ran the whole connect sequence every Core tick while the lock screen sat idle: new
// sockets, getinfo + getwalletinfo, a forced address scan, a CoinGecko fetch and a wallet-index
// rewrite. Poll chain state only: that keeps the sync height current and refreshCoreData's
// 3-strike lost-connection check armed, so a node that exits while locked is still noticed and
// restarted. Wallet scans wait for the unlock (they would also hold cs_main ahead of the user's
// walletpassphrase), except the throttled balance while pool mining keeps the lock screen down.
const bool poolMiningActive = xmrig_manager_ && xmrig_manager_->isRunning();
if (!rpcBusy && !runtime_rescan_active_ && network_refresh_.consumeDue(RefreshTimer::Core)) {
refreshCoreData(/*allowBalance=*/poolMiningActive);
}
// Pool mining keeps the lock screen down, so the tabs stay usable while locked: keep peers
// current, and re-read the lock state at the slow peers cadence so an unlock done another way
// (walletpassphrase in the Console tab) is noticed.
if (poolMiningActive && !rpcBusy && network_refresh_.consumeDue(RefreshTimer::Peers)) {
refreshPeerInfo();
refreshEncryptionState();
}
} else if (!rpcBusy && network_refresh_.consumeDue(RefreshTimer::Core)) {
if (!connection_in_progress_ &&
wizard_phase_ == WizardPhase::None &&