mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:03:39 +00:00
qml: Keep the app usable while an imported wallet rescans #986
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml!986
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/wallet-import-rescan-nonblocking"
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?
Fixes #840.
An import set the same flag as a wallet load and kept its dialog open until restoreWallet() returned, so the app stayed locked for the whole rescan.
Unit and QML tests cover the new state, the selector and the dialog. Tested by hand on regtest with a rescan of about six minutes.
#991 is an existing backup bug that this PR makes easier to reach.
The backup dialog uses
selectedWalletwhen accepted, rather than retaining the wallet it was opened for. I reproduced this onqt6: open A’s backup dialog, load B through RPC, then accept. Restoring the saved file confirmed it contained B. This also replaced an existing A backup after the normal overwrite confirmation.With background imports, the same sequence appears possible entirely through the GUI:
The RPC route is reproduced end to end; the import route above is based on reviewing this PR’s code.
But I think we will want to close out that issue before moving with async stuff here.
@jarolrod thanks for catching this. I opened #1009 to fix #991: the backup dialog now pins the wallet it was opened for, so a selection change while it is open (including a background import finishing) can no longer redirect the backup. I'll rebase this PR once that one is merged.
ACK 670b588a386bf3dc9500fc299bb2192fb49ba845
If the modal is closed, a failed import reopens it but a successful one shows nothing. The flow is destroyed with the modal, so its
onWalletImportSucceedednever runs.Can we show a toast here with an "Open" action?
If the user quits while the import is running, shutdown aborts the rescan and
restoreWallet()fails. Then this reopens the import modal with "Failed to rescan the wallet during initialization" on top of the shutdown screen. I hit it 2/2 times.Clearing the import state in
unloadWallets()fixes it (tested):github.com/bitcoin-core/gui-qml@670b588a38/qml/walletqmlcontroller.cpp (L300-L306)Also the new subheading says "You can close this window and keep using the app", but quitting drops the import and the wallet isn't there after restart. Maybe warn on quit while importing?
When the import finishes,
addOrSelectWalletModel()selects the imported wallet. Before this PR it was fine because the modal blocked everything. Now the user can be working in another wallet when the rescan ends, and the app switches wallets under them.I tested it: closed the modal, went to Send on
mainand typed 0.5. When the import finished, the badge switched tobigwalletand the Send form was cleared. This is also how #991 can happen from the GUI only.Shouldn't we keep the current wallet selected and let the user open the imported one? Something like:
Same for the worker success path:
github.com/bitcoin-core/gui-qml@670b588a38/qml/walletqmlcontroller.cpp (L381)Also
importWalletLeavesLoadedWalletsSelectableasserts the switch:github.com/bitcoin-core/gui-qml@670b588a38/test/test_walletqmlcontroller.cpp (L576)Is that intended?
"Only the import can report a load error while it runs" is only true now because the other callers are guarded. Any new
setWalletLoadError()call during an import will stop tracking it and open the import error modal for an unrelated error.Why not emit it from the import failure lambda instead?
nit: the
setWalletLoadInProgress(false)calls in both import lambdas aren't needed anymore. Import doesn't set that flag.github.com/bitcoin-core/gui-qml@670b588a38/qml/walletqmlcontroller.cpp (L1062)github.com/bitcoin-core/gui-qml@670b588a38/qml/walletqmlcontroller.cpp (L1075)ACK
fc26982db3Tested closing the import dialog during a rescan, switching open wallets, and quitting during an import. Wallet selection and Send input were preserved when the import finished.
A persistent scanning indicator would make the background work clearer. That can be added in a follow-up.
🟠 Minor · Import busy state clears before restoreWallet() returns
Handling Core's early load notification clears import progress before restore completion, allowing precisely timed actions to queue more work or lose or misattribute the success notification.
Location:
qml/walletqmlcontroller.cpp:484(head).🟠 Minor · Import success tests can outlive their fake wallet state
The two new import success tests use a non-draining controller, allowing asynchronous unload cleanup to access destroyed FakeWallet::State locals.
Location:
test/test_walletqmlcontroller.cpp:814(head).🟠 Minor · Migration can queue behind a background import
Unlike create and import, migration does not check walletWorkerBusy(), so confirmation during a background rescan can queue a delayed migration that later changes the selected wallet.
Location:
qml/walletqmlcontroller.cpp:702(head).🟠 Minor · A failed import can leave a nonexistent wallet in the selector
Refreshing the selector during an import makes its row directory-backed, so a later restore failure preserves it as a closed wallet even after Core removes the copied database.
Location:
qml/models/walletlistmodel.cpp:179(head).🔵 Suggestion · Background import failures interrupt the active workflow
Unlike success, a background import failure automatically opens a focused modal without checking whether the user is already working in another dialog.
Location:
qml/pages/MainWindow.qml:369(head).Review coverage was incomplete.
Reviewed:
fc26982db3c3· Full review report · Previous reportspermalink
Earlier concerns remain unresolved; see the Run archive linked from the Review report.
🟠 Minor · Imports chosen during another wallet load are silently discarded
After a failed import, Details can reopen the import flow during another wallet load, where the enabled Import row accepts a file but
importFile()silently discards it; this sequence is source-traced, not observed.Location: qml/pages/wallet/WalletCreationFlow.qml:91 (head).
🔵 Suggestion · The import guidance omits possible stalls in wallet and chain updates
The invitation to keep using the app omits a pre-existing pinned-Core limitation: other wallets can stop updating during the import rescan, and sufficient queued callbacks can also stall chain progress.
Location: qml/pages/wallet/WalletCreationTypePage.qml:31 (head).
🔵 Suggestion · Import banners bypass
ToastBanner's fade-out lifecycleBoth import banners replace
visibleinstead of usingshown, preventingToastBannerfrom retaining visibility during its hide animation; the error banner also unnecessarily redeclaresshown.Location: qml/pages/MainWindow.qml:489 (head).
🔵 Suggestion · The quit-path rewrite shares a commit with controller and import-presentation changes
Commit
e1b1f6f54ac990ee1b0c5a3cc8f787629712c01dcombines platform quit routing, wallet-selection/error semantics, and closable-dialog/banner UI, making the shutdown change harder to validate independently.Location: qml/pages/MainWindow.qml:98 at e1b1f6f54ac9 (commit) (commit).
Review coverage was incomplete.
Reviewed:
4cadb820ca0d· Review reportTested
9eb5f34bee3fon macOS 26.6.2 with Qt 6.11.2.Two findings are already covered in rreview’s comment: the wallet row stuck as “Importing…” after a same-name import failure, and the quit confirmation opening inside a hidden window. Both are worth fixing, though the hidden-window issue is lower priority since restoring the window lets the user answer.
I also confirmed a separate native macOS quit bypass. During a real 20,000-block regtest rescan:
terminate:through a test-only bridge hook started shutdown without showing the confirmation.QmlQuitHandler::quitRequestedconnects directly toNodeModel::requestShutdown()inqml/bitcoin.cpp, bypassing the newMainWindow.requestQuit()guard. Native quit requests should pass through the same import confirmation.This exercises the native Cocoa termination path; physically clicking Dock → Quit was not tested.
Thanks @johnny9 for testing. Fixed and squashed:
Could you retest terminate: on macOS?
ACK
a974a48da7Retested on macOS 26.6.2 with Qt 6.11.2. AppKit
terminate:through the test bridge now shows the import confirmation; cancelling preserves the rescan, and confirming shuts down. Hidden and minimized-then-hidden windows restored correctly. The wallet-row and import-error regression tests also pass.The remaining retry and stale-confirmation issues already reported are minor and can be addressed in follow-ups.
ACK
a974a48On current
qt6there is one page where Close stays available during an import, and the result is then lost. This PR's banners cover the lost result. One part of it looks untouched on this branch.To reproduce at
eed1f426fcb6:The dialog closes and nothing reports the outcome:
Controls in the same sessions reported the result correctly: leaving the dialog open, using Back instead of Close, and a first-attempt import, where Close is hidden while importing.
The error page has
showCloseButton: modalView(WalletImportErrorPage.qml#L25), where the type page hasmodalView && !importingWallet(WalletCreationTypePage.qml#L33). Close ends the flow, so nothing is left to show the result.At
a974a48da76d, closing during an import is allowed and the result arrives as a banner, so the lost result goes away.WalletImportErrorPage.qmlis unchanged on this branch, though, andstartWalletImportclears the previous error before the retry (walletqmlcontroller.cpp#L1066-L1072). By source, a retried import still shows the error page with its cross icon, no text and no progress while the restore runs. I have not run this branch. The retry could show the same "Importing your wallet file…" state as a first attempt.Reproduced on merged
qt6ateed1f426fcb6, macOS / Qt 6.9, isolated regtest, offscreen and native. The slow restore was produced with-keypool=60000, not a real rescan. File paths were supplied through the test-automation path field and clicks went through the test bridge.@jarolrod Thanks for the report. Fixed in
a5f9e6896b: choosing another file on the error page now returns to the page that shows "Importing your wallet file…", as a first attempt does, instead of leaving the emptied error page. With this branch, Close during that import also reports the result through the banner.Rebased on qt6 after #1052 and addressed the rreview findings on
a9b2ea2c99: