mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:03:39 +00:00
wallet: invalidate stale UI actions when context changes #1046
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!1046
Loading…
Reference in a new issue
No description provided.
Delete branch "wallet-context-invalidation"
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 or dialog is open can leave its actions pointing at the newly selected wallet. This can back up the wrong wallet, replace another wallet’s draft, or apply an action to a different request or transaction.
Key Changes
Tie each opening to the context it was opened for.
InteractionContexttracks that context, whileContextPopupcloses the popup and rejects stale actions when it becomes invalid.WalletContextadds wallet-specific checks without making generic menus and popups depend on wallets.Each opening gets a fresh token. Switching away and back cannot revive an old opening; the user must open it again.
Apply this to wallet menus, native file dialogs, transaction reviews, signing prompts, and payment-request actions. Keep creation/import completion actions tied to the resulting wallet, reject late migration results, and switch to Activity whenever a closed wallet is loaded.
Fixes #991
Fixes #992
Fixes #999
Fixes #1012
Fixes #1013
Fixes #1026
Fixes #1027
Fixes #1028
Fixes #1030
Fixes #1037
Opened #1048 for the same-wallet draft replacement case, reproduced on
4c085bf954. This predates this PR, and the subsequent review shows the correct payment. It could fit here as a small fix with a regression test, but a separate follow-up is fine too; I don’t think it needs to hold up this PR.The cancellation is too aggressive. After signing, the backend emits
currentTransactionChangedwhile keeping the same transaction object. This cancels approval before the success signal is handled. Extend the notifications to distinguish replacing the reviewed transaction from updating its signing status, so successful signing does not cancel the current interaction.With no wallet loaded,
selectedWalletis an unavailable placeholder. This makesmigrationContext.begin()returnnull, so clicking Update closes the dialog without starting migration. UseInteractionContextwithowner: rootandtarget: root.pendingMigrationPathto track the migration attempt without depending on a loaded or selected wallet.As a follow-up, we might want to consider adding in the migration progress and completion feedback we had, which seems to have been lost when the flow moved to popups. Keep the dialog open during migration, show which wallet is being updated, and display a clear success or error message. Preserve the existing behaviour of opening and selecting the migrated wallet after success.
Closing this in favor of https://github.com/bitcoin-core/gui-qml/pull/1049 which takes a different approach to the same problem.
This PR keeps one set of pages that follows the selected wallet and makes each popup check that its opening is still valid. While that works, the safety depends on every popup opting in: a missed guard reopens the bug, and new popups need the same care.
https://github.com/bitcoin-core/gui-qml/pull/1049 instead gives every open wallet its own set of pages (Activity, Send, Receive and wallet settings). A page's wallet never changes, so anything opened from it can only act on that wallet, with no per-popup guard needed. A wallet's pages close what they own when they're hidden, and actions are refused once a wallet starts unloading.