qml: Move wallet overview, activity, address and receive work off the GUI thread

bitcoin-core/gui-qml: PR #1146

1 minor finding · 1 suggestion

Findings

Link

[minor] · Password changes can race temporary unlocks and leave the wallet unlocked

A password change submitted during a worker's temporary unlock can leave an originally locked wallet unlocked after both operations finish; source inspection establishes the interleaving, but it has not been reproduced.

Location: qml/models/signverifymessagemodel.cpp:76 (head).

Details and suggested fix

Worker signing and Receive address/save commands hold WalletUnlockSession through relocking, but changeWalletPassphrase() calls Core without acquiring it, and the password-settings button does not exclude that work. In pinned Core 44901d8f, ChangeWalletPassphrase() records fWasLocked = IsLocked() before acquiring m_relock_mutex and cs_wallet. If it records false during the temporary unlock, the worker can relock before the password change acquires those locks. Core then unlocks with the old password and skips if (fWasLocked) Lock(), leaving the wallet unlocked with no relock scheduled. Receive's wallet read extends the unlocked interval, although the user's password change must still hit this timing window. At base, signing and Receive unlocks ran synchronously on the GUI thread and could not overlap that GUI action.

Make changeWalletPassphrase() participate in the same session, for example using tryAcquire() and reporting a recoverable busy error as Send does. Add a regression test modeling Core's capture-then-restore lock-state behavior; the current fake password-change implementation only validates and records passwords.


Optional improvements

Link

[suggestion] · Unused label aliases contradict their documented contracts

Neither helper has a current caller, but writeAddressBookLabel() and syncPaymentRequestNoteToAddress() now both call setAddressLabel(), despite the documented distinction between address-book-only writes and request-note propagation.

Location: qml/models/walletqmlmodel.cpp:1510 (head).

Details and suggested fix

walletqmlmodel.h promises that writeAddressBookLabel() leaves saved payment requests untouched. Its new implementation instead submits the same Label command as setAddressLabel(), which updates noteSelf on every matching saved request. syncPaymentRequestNoteToAddress() is another alias of that complete operation. Remove both unused declarations and definitions rather than retaining misleading entry points. Neither is Q_INVOKABLE, and the Save command already performs its separate setAddressBook() write, so this removal preserves current production behavior.


Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Unresolved disagreements

The inspected historical balance-cache discussion did not resolve whether reduced average CPU usage from signal-driven updates adequately addressed the risk of long GUI lock waits.

Jonas Schnelli reported substantially lower profiling costs with the signal-based approach, while van der Laan emphasized contention-induced hangs. Russell Yanofsky explicitly questioned whether those measurements answered the latter concern. This distinction matters to the affected snapshot design: less repeated work and avoidance of GUI blocking are separate objectives. The captured record does not establish the eventual resolution or present-day performance.

Source 1 · Source 2 · Source 3