mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:03:39 +00:00
qml, wallet: give each open wallet its own view #1049
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml!1049
Loading…
Reference in a new issue
No description provided.
Delete branch "wallet-view"
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?
Loading, switching, or unloading wallets while a menu, dialog, or confirmation is open can leave it acting on a different wallet than the one it was opened for. This can back up the wrong wallet, replace another wallet's draft, export another wallet's history, or sign a transaction the user never reviewed.
This is an alternative approach to #1046. Instead of guarding each popup with a context token, every open wallet gets its own set of pages. A page's wallet never changes, so anything opened from a wallet's pages can only act on that wallet.
Key Changes
DesktopWalletskeeps oneWalletViewper open wallet, built from the newwalletController.openWallets. A view holds Activity, Send, Receive and wallet settings, each with its own navigation stack. Only the selected wallet's view is shown; hidden views keep their tab, drafts and navigation. A wallet's view is destroyed when the wallet closes or unloads.walletController.selectedWallet. Controller requests that concern one wallet (open Receive, open wallet settings, close a request detail) now name that wallet, and only its view reacts.Relation to #1046
This supersedes #1046.
#1046 keeps one set of pages that follows the selected wallet and makes each popup check that its opening is still valid. That works, but safety depends on every popup opting in: a missed guard reopens the bug, and new popups need the same care. Treating any selection change as invalidation also broke legacy wallet migration when no wallet is loaded.
Here the wallet cannot change underneath a page, so wrong-wallet actions are prevented by structure and need no per-popup code. The cases per-wallet views cannot catch (replacement within the same wallet, completion screens, the window while a wallet unloads) get targeted checks instead.
Notes
-dbcache=100: 258/348/439 MB with 1/3/5 wallets, versus 257/314/325 MB when only the shown view exists). Idle CPU is unchanged, since hidden views do not render. Views stay alive to keep per-wallet state and as groundwork for showing wallets side by side.-Wcovered-switch-default, an inexactlong doublebound in the sync estimate).Fixes #991
Fixes #992
Fixes #999
Fixes #1012
Fixes #1013
Fixes #1026
Fixes #1027
Fixes #1028
Fixes #1030
Fixes #1037
Fixes #1048
Left a review on the wrong PR. I don't know how to delete this comment.
RPC
loadwalletcan switch to wallet B while a Send field in wallet A keeps keyboard focus. Further typing edits A’s hidden draft while B is displayed. Hiding the view does not clear focus. Disable inactive wallet views or clear their focus when switching wallets.Addressed in
5e3bbb9f42Tested
97868a6488with real regtest wallets on Linux / Qt 6.12.0.Keyboard focus can return to a hidden wallet:
loadwallet Bover RPC.This reopens A's review while B is selected. Closing the popup restores focus to A's hidden Review button.
I also reproduced a possible stale wallet-creation success page in a mocked QML test, but could not confirm it with the real backend.
Thanks for testing. I was also able to reproduce. Fixed in
a07acc8dd2.🟠 Minor · Hiding Send dismisses completion without clearing the sent draft
WalletView.pageHidden(sendPage) closes transactionReviewPopup when Send hides. The popup's onClosed never calls resetSendForm, so the broadcast payment's recipients stay in the form. This is newly reachable through same-wallet navigation; reachability while the popup is open relies on native menus.
Location:
qml/pages/wallet/WalletView.qml:191(head).🟠 Minor · MainRouting lacks the open-wallet fixture needed for focused runs
tst_mainrouting.createMain never calls setOpenWallets, and the mock's reset() leaves m_open_wallets alone. Run on their own, these tests get no WalletView, so openSend and openWallet do nothing and the tab and creation-completion routing tests fail; they rely on state left by earlier test files.
Location:
test/qml/tst_mainrouting.qml:50(head).🔵 Suggestion · Unvisited startup wallets also load and poll their activity
Creating views eagerly loads history and starts polling for startup wallets that are never selected; creating each view on first selection and retaining it would avoid that work without losing visited-wallet state.
Location:
qml/pages/wallet/DesktopWallets.qml:50(head).🔵 Suggestion · Per-wallet Activity preferences still share app-wide storage keys
Changing Activity grouping or density leaves other open wallets on their old values, but all views persist under the same keys, making the preferences neither consistently app-wide nor reliably per-wallet.
Location:
qml/pages/wallet/WalletView.qml:186(head).🔵 Suggestion · Fee bumping and message signing omit the closing-wallet gate
BumpTransactionModel::confirmFeeBumpInternal and SignVerifyMessageModel::signMessageInternal check only m_wallet, not the new unload flag. Until beginShutdown detaches them, a confirmed fee bump or message signature can still go through after available() is false. This is the same as base behaviour.
Location:
qml/models/bumptransactionmodel.cpp:142(head).Review coverage was incomplete.
Reviewed:
c0aac977c710· Full review report · Previous reportspermalink
🔵 Suggestion · Fee bumping and message signing skip the new closing-wallet gate
The new closing-wallet refusal does not cover fee bumps or message signatures submitted before queued teardown, although those actions still require normal authorization.
Location: qml/models/walletqmlmodel.h:222 (head).
🔵 Suggestion · External signer approval on a closing wallet reports a missing signer
An approval attempted during the short unload interval reports "External signer not available." rather than explaining that the wallet is closing.
Location: qml/models/walletqmlmodel.cpp:2425 (head).
🔵 Suggestion · Unvisited startup wallets allocate full page sets
DesktopWallets.syncOpenWallets builds a WalletView for every open wallet, though startup selects only the first. Each view's ActivityList creates that wallet's TransactionActivityModel, which loads history and polls every second, even if the wallet is never shown.
Location: qml/pages/wallet/DesktopWallets.qml:50 (head).
🔵 Suggestion · Per-wallet Activity preferences still share app-wide storage keys
Each WalletView's ActivityListPage has its own AppSettings using the shared activityGrouping and activityDisplayDensity keys. Changing them in one wallet leaves other open views on the old value, while new views and restarts read the last value written, so the setting is neither global nor reliably per-wallet.
Location: qml/pages/wallet/WalletView.qml:186 (head).
Review coverage was incomplete.
Reviewed:
63346e0200e6· Full review reportResolved the two minor bugs reported by Ralph
ACK
63346e0200Tested native backup, PSBT import and CSV export dialogs during wallet switch, unload and Quit. Wallet shutdown tests passed, including shutdown while startup wallets were loading.
Memory use with many open wallets can be checked in a follow-up. Each wallet keeps its pages alive. Views are removed on unload, but I have not measured memory use over repeated load/unload cycles. I found no confirmed memory issue that blocks this PR.