mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:00:39 +00:00
Reject stale actions from wallet menus #992
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#992
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: #577 — Create and manage wallets.
Problem
Send options, coin menus, receiving-address menus and QR controls can retain an old opening after the selected wallet changes. A delayed action can then clear the wrong draft, start an import or change the new wallet's settings.
Suggested fix
Tie each opening to its wallet and relevant request. Close and invalidate it when that context changes or its parent hides. Reject stale actions, including after switching away and back. Preserve each wallet's draft.
Validation
Cover wallet switches, unloads, hidden views and actions during closing. Confirm stale actions affect neither wallet and fresh actions still work.
Related features: #581 Receive, #582 Send, and #923 Fee selection and coin control.
Related work: #974, #975 and #978. The backup-dialog case is already reported in #991.
Adding a concrete PSBT reproduction here. An import dialog opened for A can end up importing into B and replacing B’s send draft.
psbtfield fromwalletcreatefundedpsbtas a binary.psbtfile.unloadwallet "A" false. B becomes selected.B’s draft changes from 0.75 to 1.25 BTC, and the review opens for B. Nothing was signed or broadcast.
The acceptance handler uses the currently selected wallet. We should invalidate the pending import when its wallet changes or unloads, before it can touch another wallet’s draft. Related to #975.
Reproduced with native dialogs on macOS/Qt 6.9.0 at
b03cf0554841and its parent77e8005455cd, so this predates #1009.There’s another case in the receiving-address QR menu: Save can write B’s address even though the dialog was opened for A.
unloadwallet "A" falsethrough the GUI’s RPC server. B becomes selected.The PNG contains B’s address. I confirmed B owns it through
getaddressinfo.Visiting B’s Receive page first matters. Loading a fresh wallet can generate an address-change signal that closes the dialog and hides this case.
We need to invalidate the save when the wallet/request object changes, or keep the original QR tied to the operation. Checking the address only when Save is accepted is already too late.
Reproduced on macOS/Qt 6.9.0 at
b03cf0554841and parent77e8005455cd. This is also relevant to #972’s QR work.The saved payment-request QR has a smaller variation of this. Switching wallets closes the request modal but leaves its native Save dialog open. Clicking Save then silently writes nothing.
unloadwallet "A" falsethrough the GUI’s RPC server.The picker closes, but there’s no PNG and no save error. I also reproduced this by loading B through RPC while A’s picker was open.
The hidden-card guard stops the export, but we should close and invalidate its file dialog when the request modal closes too.
Tested on macOS/Qt 6.9.0 at
b03cf0554841. The relevant code is unchanged from the parent; I only reran this particular case on the PR build.Split the concrete reproductions above into two issues so we can fix and verify them separately:
Both include the reproduction steps and tested commits. Keeping this issue open to track the broader stale-menu behavior.
Went back through this after splitting out #1012 and #1013. The Send and receive-settings cases still reproduce, and I found a few more paths worth covering here.
Tested on
qt6at d567e3eb2497, native macOS/Qt 6.9.0, with disposable regtest wallets. I used RPC against the GUI’s node for the wallet changes below, so clicking outside didn’t dismiss the menus.Clear form clears the newly selected wallet’s draft.
unloadwallet "A" false. B becomes selected, but the menu stays open.B’s existing address and amount are cleared.
The manual payment-request dialog can apply to another wallet.
bitcoin:<valid-regtest-address>?amount=0.4&message=opened-for-B.loadwallet "A" false, with A’s Send draft empty.A’s draft gets the address, 0.4 BTC amount and
opened-for-Bmessage. This is the manual URI entry path, separate from the PSBT file dialog in #1012.The fee menu also follows the newly selected wallet.
unloadwallet "A" false, leaving C selected.C’s fee target changes from 6 blocks to 2.
Address settings changes the other wallet’s saved preference.
unloadwallet "A" false, then choose Base58 (Legacy) from the old menu.B switches to Legacy. I also checked
settings.json: B’s preference was saved aslegacy, while A remainedbech32m.Closing the coin picker leaves its Sort menu behind.
loadwallet "A" false.The picker has cleared
editingCoins, but the menu still accepts the click. It logs this and stays open until dismissed:I also tried the Lock coin menu under Settings → Wallet settings → View coins, including wallets sharing the same outputs. That path held up: changing wallets resets the settings page and removes the menu. I couldn’t reproduce a wrong-wallet lock there.
I think these belong here. We need to invalidate the old opening when the wallet changes and close any child menus with their parent. The coin picker is a useful example of why closing just the parent isn’t enough.
Found another case here where the old menu can delete a request from the other wallet.
unloadwallet "A" false. B becomes selected and A’s request modal closes, but the menu stays open.B’s previously viewed request gets deleted. I repeated this with A’s request ID 3 and B’s request ID 1, so it doesn’t depend on matching IDs. B’s request was still gone after reloading the wallet; A’s requests were unchanged.
We should close the child menu with its modal and reject the old action before it reads the current wallet/request. Moving deletion to a worker doesn’t cover that part.
Reproduced on
qt6atd567e3eb2497, native macOS / Qt 6.9.0. Also relevant to #972 and #990.There’s a timing gap in the coin picker’s wallet-change handling too.
unloadwallet "A" falsethrough the GUI’s RPC server.B becomes selected, but the picker stays open with no coins and Use selected inputs disabled, even though B has spendable coins.
I reproduced this twice by triggering the unload while
visiblewas true andopenedwas still false, without changing the animation. It remained open after the transition finished. The same unload afteropenedbecomes true closes it correctly.onWalletChangedonly checksopened, so it misses the opening transition. That needs to be covered too. This is separate from the surviving Sort menu reported above—the picker itself stays open here.Tested on
qt6atd567e3eb2497, native macOS / Qt 6.9.0.Tracking the PSBT Save case separately in #1026.
The transaction review has the same opening-transition gap as the coin picker above.
unloadwallet "A" falsethrough the GUI’s RPC server.B becomes selected, but an empty Review Transaction stays onscreen: no amounts, Save disabled, and no Send button. Close still works.
Reproduced twice on
qt6atd567e3eb2497, native macOS. To hit the timing reliably, I triggered the RPC when the review hadvisible == trueandopened == false, without changing the animation. It stayed open after the transition finished. Unloading after it was fully open closed it correctly.The wallet-change handler checks
opened, so it misses this window too. Let’s cover the review as well when fixing the coin picker.The saved-request menu has another variation: Request again can take effect much later, when closing a different request.
unloadwallet "A" falsethrough the GUI’s RPC server. B becomes selected and the request dialog closes, but More stays open.Closing that new request unexpectedly opens Receive with the earlier 0.12 BTC amount and message. Both saved requests are still there.
The old action sets
repeatRequestIdafter its modal has already closed, so the next close picks it up. We need to invalidate the child menu and discard the pending repeat when its opening ends.Reproduced on
qt6atd567e3eb2497, native macOS / Qt 6.9.0. Also relevant to #972 and #990; #990 still has this deferred-repeat handling in the current code.Found another dialog to include here: the PSBT “already in your wallet” warning keeps its View transaction action after switching wallets.
gettransaction, pass it toconverttopsbtwithpermitsigdata=true, and base64-decode the result into a binary.psbtfile.loadwallet "A" falsethrough the GUI’s RPC server. A becomes selected, but the warning stays open.It opens an empty transaction detail under A with “This transaction is no longer available.” Importing the same file in B without switching opens the correct details.
The warning keeps B’s transaction ID, but navigation uses the current wallet. It should close when its wallet changes. This happens after the file picker has finished, so it’s separate from the draft replacement in #1012. Related to #975.
Tested on
qt6atd567e3eb2497, native macOS / Qt 6.9.0.A smaller case alongside the Sort menu above: “Use locked coin?” also stays open after its picker closes.
lockunspent.loadwallet "A" falsethrough the GUI’s RPC server.The button just dismisses it. Neither wallet’s coin selection changes, and B’s coin stays locked. Clearing
pendingLockedCoinIdprevents the stale operation, but we should close this confirmation with the picker too.Reproduced on
qt6atd567e3eb2497, native macOS / Qt 6.9.0. Relevant to #974’s coin-control work.Opened #1028 for another case found while checking this: the creation/import completion screen can stay open after a wallet change, but Go to wallet opens a different wallet. The issue includes both reproductions and the tested commit.
Keeping that fix separate since it belongs to the creation/import flow.
The password prompt before a normal transaction review also follows the selected wallet. I reproduced this through the native File menu, without needing RPC to unload the wallet.
This opens B's 0.2 BTC transaction as Ready to send, even though the prompt was opened for A's 0.1 BTC draft. Nothing is broadcast at this step. Without closing A, the same prompt opens A's correct review.
reviewPassphrasePopupsurvives the wallet change and submits throughroot.wallet, which now points to B. We should close and invalidate the prompt when its wallet changes, and reject any stale submission.Tested on
qt6atd567e3eb2497, native macOS / Qt 6.9.0. Also relevant to #973. This is the preparation prompt inSendCreate.qml; #1027 concerns the later PSBT signing prompt.I'll look in to this
Opened #1045 for another Send case after switching wallets: the expanded recipient can differ from the wallet’s current recipient. Clicking Use maximum on recipient 1 changes recipient 2’s amount, and pasting a payment request into recipient 1 can replace recipient 2’s address. Reproduced both through the normal wallet picker; steps are in the new issue.
Opened #1048 for another Send confirmation case: importing a payment URI while “Use all available funds?” is open replaces the draft but leaves the warning active. This happens within the same wallet, without a timing race. The issue has reproduction steps and results from qt6 and #1046.