RPC console: a wallet loaded from outside the picker becomes the console's target, and a command already typed runs in it #1131

Open
opened 2026-11-13 15:16:57 +00:00 by jarolrod · 0 comments
jarolrod commented 2026-11-13 15:16:57 +00:00 (Migrated from github.com)

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 sendtoaddress typed while the window was on wa was paid from wb.

To reproduce:

  1. Regtest node with wallets wa (funded) and wb (5 BTC) on disk and only wa loaded. Start the app with the RPC server on. The badge reads wa.
  2. Settings → RPC console. getwalletinfo answers "walletname": "wa".
  3. Type sendtoaddress <address> 0.01 and do not press Enter.
  4. In a shell: bitcoin-cli loadwallet wb. Within 0.13 to 0.17 s the badge reads wb. The typed command is still in the field.
  5. Press Enter.

The console prints Executing command using "wb" wallet, the command and a txid on that one Enter. wb went from 5 to 4.9899859 BTC and wa is unchanged.

What moved the selection Next console command
bitcoin-cli loadwallet wb sendtoaddress paid from wb
bitcoin-cli createwallet wc getwalletinfo answers wc; getnewaddress returns an address of wc
loadwallet wd typed in the app's own console getwalletinfo answers wd; sendtoaddress paid from wd
wa, wb, wc open, wc selected; bitcoin-cli loadwallet wd, then unloadwallet wd getbalance typed for wc runs in wa, the first wallet in the list
wb already loaded; outside RPCs addressed to wb still wa

What 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 qt6 at 2bd5a61e8304, macOS arm64 / Qt 6.9.0, isolated regtest, offscreen and native; the same at eed1f426fcb6. 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; loadwallet typed in the console does not. No spending command was run in the unload case.

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 `sendtoaddress` typed while the window was on `wa` was paid from `wb`. To reproduce: 1. Regtest node with wallets `wa` (funded) and `wb` (5 BTC) on disk and only `wa` loaded. Start the app with the RPC server on. The badge reads `wa`. 2. **Settings → RPC console**. `getwalletinfo` answers `"walletname": "wa"`. 3. Type `sendtoaddress <address> 0.01` and do not press Enter. 4. In a shell: `bitcoin-cli loadwallet wb`. Within 0.13 to 0.17 s the badge reads `wb`. The typed command is still in the field. 5. Press Enter. The console prints `Executing command using "wb" wallet`, the command and a txid on that one Enter. `wb` went from 5 to 4.9899859 BTC and `wa` is unchanged. | What moved the selection | Next console command | |---|---| | `bitcoin-cli loadwallet wb` | `sendtoaddress` paid from `wb` | | `bitcoin-cli createwallet wc` | `getwalletinfo` answers `wc`; `getnewaddress` returns an address of `wc` | | `loadwallet wd` typed in the app's own console | `getwalletinfo` answers `wd`; `sendtoaddress` paid from `wd` | | `wa`, `wb`, `wc` open, `wc` selected; `bitcoin-cli loadwallet wd`, then `unloadwallet wd` | `getbalance` typed for `wc` runs in `wa`, the first wallet in the list | | `wb` already loaded; outside RPCs addressed to `wb` | still `wa` | What 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: https://github.com/bitcoin-core/gui-qml/blob/2bd5a61e8304d5143e32f1ce977a2de2aceb6413/qml/pages/node/CommandConsole.qml#L446-L456 and names a changed target only as it runs the command: https://github.com/bitcoin-core/gui-qml/blob/2bd5a61e8304d5143e32f1ce977a2de2aceb6413/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 `qt6` at `2bd5a61e8304`, macOS arm64 / Qt 6.9.0, isolated regtest, offscreen and native; the same at `eed1f426fcb6`. 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; `loadwallet` typed in the console does not. No spending command was run in the unload case.
Sign in to join this conversation.
No description provided.