mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 07:54:42 +00:00
Watch-only wallet, wallet loading status #727
No reviewers
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!727
Loading…
Reference in a new issue
No description provided.
Delete branch "wallet-loading-status"
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?
This PR consolidates watch-only wallet creation and tracks per-wallet load states. It also bundles in small improvements to wallet picker view.
Screenshot
Screenshot
Wallet picker improvements
Screenshot
Screenshot
Screenshot
Screenshot
add create_wallet_name functional test as well as the wallet selector functional test to the workflow
Be sure to update unittest to cover needed changes.
this property seems redundant
this should probably be based on a different condition. If another wallet is already loaded and watch-only creation fails at qml/walletqmlcontroller.cpp (line 456) or qml/walletqmlcontroller.cpp (line 502), the wizard can still push the success screen.
we should let the wallet loader notification handler create the wallet model. doing it this way creates a duplicate model in the list and closing the wallet will have issues.
something like
We should fill in these values for the descriptor. This can be a followup issue as it likely requires designing the wizard to include these choices and maybe a date picker
i think you need to trim the string as
QDir::cleanPath(" ") -> " "
QDir::cleanPath(" foo ") -> " foo "
QDir::cleanPath("./foo//bar") -> "foo/bar"
QDir::cleanPath("foo/../bar") -> "bar"
cleanPath can still get " " through this condition
The CreateIntro page can be removed now
We should include external signer walets in this list if it is configured
That's embarrassing I didn't check the line above
we're moving fast, its going to happen and we're going to find more once things settle
You mean this page is to be removed? Sure? I see it on Figma and the core-app website

Added in 48d0575
This took a bit more time than I anticipated. Updated now.
https://github.com/bitcoin-core/gui-qml/issues/735
I meant the create wallet wizard page should just be the create type selector page
this is running synchronously on the qml controller thread.
The updated defer logic handles the model duplication problem, which is good. But the heavy wallet work is still happening inline here.
WalletLoader::createWallet()calls intoCreateWallet(), which can create or open wallet db storage, initialize wallet state, emit the load notification, add the wallet to the wallet context, run init processing, and update wallet settings.AddWalletDescriptor()persists descriptors and tops up descriptor script caches. Even if this is normally fast, it is still filesystem and wallet setup work being run from a QML invoked method.That differs from the rest of the controller methods we have implemented:
createSingleSigWallet(),createExternalSignerWallet(),startWalletLoad(), andstartWalletImport()all post the wallet operation tom_workerand then marshal back to the controller thread for QML state updates.I think the correct model we should maintain is wallet & db work runs outside of the UI thread; model adoption and signal emission stay on the QML thread.
This part intrigued me, so I dug into whether the pending wallet operation is actually tied to the wallet that just loaded. I think there is still a very real lifecycle bug here; that might be worthwhile to address in this PR.
The QML controller currently tracks “some wallet operation is pending” with
m_wallet_load_requestedandm_pending_wallet_load_action, but it does not track the target wallet name/path for that pending operation.handleLoadWallet()is registered as the global Core wallet-loaded callback, so it can be called for any wallet load notification, not only the wallet caused by the current QML action.That matters because this function reads
m_pending_wallet_load_action, clears it, and later emitswalletCreateSucceeded(),walletLoadSucceeded(), orwalletImportSucceeded()without first proving that the loaded wallet is the pending target. So an unrelated wallet notification can consume the active pending operation.Comparing with Qt Widgets, it avoids this specific issue by keeping global wallet adoption separate from operation completion:
WalletController::handleLoadWallet()only callsgetOrCreateWallet()to adopt the loaded wallet model.CreateWalletActivity,OpenWalletActivity, andRestoreWalletActivitycomplete from theWalletLoader::createWallet/loadWallet/restoreWalletresult returned by their own worker operation.created()/opened()/restored()only if that specific operation set its ownm_wallet_model.So in Widgets, an unrelated wallet loaded notification may adopt another wallet model globally, but it does not complete the active create or open activity. In QML,
handleLoadWallet()currently does both adoption and pending operation completion, which makes the global notification able to satisfy the wrong operation.I wrote two local unit tests to check this:
created_wallet, then deliver a load notification forunrelated_wallet;target_wallet, then deliver a load notification forunrelated_wallet.Both fail on current HEAD. The unrelated notification emits the pending success signal:
Here are the tests I wrote
Right now, it seems to me, this path can run before
initialize(), and it can also run while another wallet load or create is already in progress. In the second case,clearWalletLoadStatus()clears the existing in-progress state, then the function continues intoWalletLoader::createWallet().Maybe we add the same basic guards used by
createSingleSigWallet()here: return ifm_wallet_load_in_progressis true, and return with the “wallets still loading” error if!m_initialized?Overall, I think we need more unit tests around all these load and create functions
we've had other instances of calls that need to be protected with an initialization check
Good catch. I’m going to rework this so watch-only creation follows the same threading model as the other wallet operations. Validation will stay on the QML thread, but
createWallet()and descriptor import can run onm_workerProbably create a helper method
I think that means the fix should be:
thanks both for the suggestion! I reworked this along the same lines as Qt Widgets. The global
handleLoadWallet()path now only adopts/selects the wallet, and each create/load/import operation emits success from its own worker.I also removed the pending
m_wallet_load_requested/m_pending_wallet_load_actionstates.317e42f
Rebased on top of
qt6branch and added a commit to repurpose AlertPopupAre we intentionally wanting to leave a newly created and blank wallet on disk here? even though the real wallet creation work failed?
I can see why
remove()would avoid deleting wallets in general. But in this flow the UI reports watch-only creation as failed, so then retrying with the same name can be blocked because the wallet directory exists.I think we might need to define a flow to add keys to a wallet in the wallet settings. If we have this, we can re-order the watch-only onboarding to create the wallet first and then treat the xpub as adding keys to it. This better matches the actual interface and lets us have the create wallet stage be separate from the xpub failure so we don't have a left over wallet
My suggestion is to leave these as the follow follow-up issues.
Build 2 and then use that to close 1 by making it ok that the xpub path isn't filled in during onboard
ACK
a8527f13c6I agree this is ready to merge, we have documented several follow-ups to be done.
#737
ACK
a8527f13c6