mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 07:54:42 +00:00
Keep wallet security, backup and recovery work off the GUI thread #967
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml#967
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #578. Extend or consolidate #625 for backup and #627 for password operations instead of creating duplicate work.
Setting or changing a wallet password and saving a backup can block the interface during key derivation, wallet locking or database I/O. Restore and migration also need safe preflight and completion handling, even when their main jobs already run in the background.
Cover
encryptWallet(),changeWalletPassphrase(),backupWallet(), security-state refresh, unlock/action/relock, restore file checks, migration encryption checks and returned wallet metadata.Run blocking work outside the GUI thread. Expose pending, success and failure states; prevent duplicate submission; and keep security getters cached. Perform temporary unlock and required relock with the protected action, including failure paths. Retain resources until work finishes and handle secret request data carefully.
Acceptance should cover delayed backup, wrong passwords, failed writes, duplicate clicks, restore/migration preflight, relock after failure and closing during an operation. Coordinate catalogue and close behavior with #577; message signing remains under #580.
Found a migration case to add here: finishing one wallet’s migration can close another wallet’s password prompt and hide its failure.
Reproduced on native macOS / Qt 6.9.0,
qt6at d567e3eb2497, using disposable regtest wallets.-keypool=20000.A finishes and becomes selected, but B’s password dialog disappears too. B remains unmigrated and there’s no password error or retry prompt. Trying B alone with the same incorrect password leaves the dialog open with the error, as expected.
Selecting B clears the shared migration status. A’s success then clears
pendingMigrationPathand closes both dialogs, so B’s failure gets ignored because the pending path is empty.We should keep the active migration state intact and prevent a second migration from starting, or tie each completion to its own operation. Starting another wallet load shouldn’t reset that protection.
Two more results of the same root on the unencrypted route, at
2bd5a61e8304: nothing is gated while Update wallet runs, and clicking the same wallet again ends in a false "Failed to open wallet".While the update runs, the picker rows, Add wallet and File → Add Wallet, Close Wallet, Backup Wallet and Exit stay enabled, and no row shows a loading state. An ordinary wallet load from the picker shows "Loading…" and disables the row, Add wallet and File → Add Wallet and Close Wallet. The update sets only
walletMigrationInProgress, and the gates readwalletLoadInProgress.To reproduce the false failure, with a legacy wallet whose update takes several seconds:
When the update ends, an alert says "Failed to open wallet / Wallet file verification failed. SQLiteDatabase: Unable to obtain an exclusive lock on the database, is it being used by another instance of Bitcoin Core?" The wallet is open and selected, and
listwalletshas it. Its picker row stays red after OK, after reopening the picker and after clicking the row again. It cleared when another closed wallet was opened.The second click's load is queued behind the update, and starting it resets the update's status while Core is still migrating:
github.com/bitcoin-core/gui-qml@2bd5a61e83/qml/walletqmlcontroller.cpp (L1182-L1185)Seen in 4 of 4 runs at
2bd5a61e8304where the second click landed during the update, 2 offscreen and 2 native, with the click 2 to 6 s in, and once offscreen ateed1f426fcb6. In one more native run the click came after the update had finished and nothing went wrong.macOS arm64 / Qt 6.9.0, isolated regtest. The update lasted about 9 to 14 s on a hand-built legacy wallet with 20,001 keys. With a 15,000-key wallet written by Bitcoin Core 29.0 the update took about 10.5 s and the second click gave the same alert, 2 of 2, offscreen. Both clicks went through the test bridge; I have not made the second click by hand.