mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 07:42:38 +00:00
RPC console: a wallet loaded from outside the picker becomes the console's target, and a command already typed runs in it #1131
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#1131
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?
The RPC console has no wallet target of its own and shows none: each command goes to whichever wallet is selected in the window when Enter is pressed. That selection moves whenever Core reports a wallet load, so a command typed for one wallet runs in another. A
sendtoaddresstyped while the window was onwawas paid fromwb.To reproduce:
wa(funded) andwb(5 BTC) on disk and onlywaloaded. Start the app with the RPC server on. The badge readswa.getwalletinfoanswers"walletname": "wa".sendtoaddress <address> 0.01and do not press Enter.bitcoin-cli loadwallet wb. Within 0.13 to 0.17 s the badge readswb. The typed command is still in the field.The console prints
Executing command using "wb" wallet, the command and a txid on that one Enter.wbwent from 5 to 4.9899859 BTC andwais unchanged.bitcoin-cli loadwallet wbsendtoaddresspaid fromwbbitcoin-cli createwallet wcgetwalletinfoanswerswc;getnewaddressreturns an address ofwcloadwallet wdtyped in the app's own consolegetwalletinfoanswerswd;sendtoaddresspaid fromwdwa,wb,wcopen,wcselected;bitcoin-cli loadwallet wd, thenunloadwallet wdgetbalancetyped forwcruns inwa, the first wallet in the listwbalready loaded; outside RPCs addressed towbwaWhat tells the user is the wallet badge at the top left of the window, which changes name and balance at the load. The console page has no wallet name or selector, and the "Executing command using" row is added in the same call that starts the command, and only when the wallet differs from the previous command's. The payment goes to the address and for the amount typed, from another of the user's own wallets.
I am not reporting that the window follows a load: the fix for #991 kept that and the functional tests rely on it. The defect is the console, which reads the wallet at Enter:
github.com/bitcoin-core/gui-qml@2bd5a61e83/qml/pages/node/CommandConsole.qml (L446-L456)and names a changed target only as it runs the command:
github.com/bitcoin-core/gui-qml@2bd5a61e83/qml/models/rpcconsolemodel.cpp (L371-L384)Core alone never retargets a client: with several wallets loaded it refuses a wallet RPC that names none (error -19). Bitcoin-Qt's console, by its source, has its own wallet selector above the input, and a wallet loaded by another client is only added to the list. I did not run it.
Suggested: show the target wallet beside the console input, and do not run a wallet command whose target changed since it was typed.
Reproduced on
qt6at2bd5a61e8304, macOS arm64 / Qt 6.9.0, isolated regtest, offscreen and native; the same ateed1f426fcb6. Enter was not a key press: the function both Return handlers call was invoked through the test bridge. The console text was key events and the navigation was clicks, both through the bridge. One launch per platform and build. The rows with another client need the RPC server, which is off by default;loadwallettyped in the console does not. No spending command was run in the unload case.