Skip to content

GUI: Add RPC console option to follow the wallet displayed in the main window - #331

Open
kwsantiago wants to merge 1 commit into
bitcoinknots:29.x-knotsfrom
privkeyio:fix-rpcconsole-wallet-selector-sync
Open

GUI: Add RPC console option to follow the wallet displayed in the main window#331
kwsantiago wants to merge 1 commit into
bitcoinknots:29.x-knotsfrom
privkeyio:fix-rpcconsole-wallet-selector-sync

Conversation

@kwsantiago

@kwsantiago kwsantiago commented Jul 10, 2026

Copy link
Copy Markdown

Switching wallets with the main window's toolbar selector does not update the RPC console's wallet selector, so console commands can silently run against a different wallet than the one displayed.

99c0eb9 ("Fix RPCConsole wallet selection") connected the console to the open, restore and create wallet activities, but not to the toolbar selector or wallet migration.

Rather than forcing the two selectors to match, which would override a console selection made on purpose, the console gets a "Use displayed wallet ()" entry. It is selected by default and its label follows the main window. Picking any other entry pins the console to that wallet.

wallet selector

BitcoinGUI::setCurrentWallet() now reports the displayed wallet to the console, covering every path that changes the active wallet. The three per-callsite connects are redundant with this and are removed, same as #344, which is the bugfix on its own.

Testing

bitcoin-qt on regtest with two wallets loaded, wallet_a and wallet_b.

  • Before this change, with the main window on wallet_b, the console stayed on wallet_a and commands ran against wallet_a. After it, the same steps run against wallet_b.
  • Pinned to wallet_a: switching the toolbar back and forth leaves the console on wallet_a.
  • Create Wallet, Restore Wallet, File > Open Wallet and loadwallet: the console follows the newly displayed wallet.
  • unloadwallet on the pinned wallet, and on the last wallet: no crash, commands fall back to the remaining wallet and then to no wallet.
  • Selecting "(none)": commands run without any wallet.
  • Built with -DENABLE_WALLET=OFF: builds and runs, console unaffected.
  • test_bitcoin-qt passes.

Wallet migration is not covered, this build has no bdb support so there is no legacy wallet to migrate. It uses the same setCurrentWallet() path.

@pdath

pdath commented Jul 15, 2026

Copy link
Copy Markdown

ACK accba6a

I reviewed the change and the fix seems elegant and simple.

I reviewed the change with Code Rabbit and it found no issues.

I built the system using Ubuntu 24.04 running on ARMv8-A (64-bit) with gcc and used guix to create a Windows binary.

git clone https://github.com/bitcoinknots/bitcoin.git pr331
cd pr331
git fetch origin pull/331/head:pr331
git switch pr331
cmake -B build -DCMAKE_BUILD_TYPE=Release -DRDTS_CONSENT=IMPLICIT
nice cmake --build build -j$(nproc)

I then built using guix.

env HOSTS='x86_64-w64-mingw32' ./contrib/guix/guix-build

And tested with:

bitcoin-qt.exe -regtest

I repeated the test of creating two wallets, and the fix works for me. The console follows the selected wallet.

@luke-jr

luke-jr commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Not sure if this is desired behaviour - what if the user intentionally selected a different wallet for the console? If we're going to force them to be aligned, we might as well remove the console selector entirely?

Maybe the console should have an additional option "Use displayed wallet ()"?

@kwsantiago
kwsantiago force-pushed the fix-rpcconsole-wallet-selector-sync branch from accba6a to 78c9368 Compare July 25, 2026 14:34
@kwsantiago kwsantiago changed the title GUI: Sync RPC console wallet selector with main window selector GUI: Add RPC console option to follow the wallet displayed in the main window Jul 25, 2026
@kwsantiago

Copy link
Copy Markdown
Author

Good point, forcing them aligned takes away a deliberate console selection. Reworked to your suggestion.

The console now has a "Use displayed wallet ()" entry, selected by default and relabeled as the main window's wallet changes. Selecting a specific wallet pins the console to it.

Retested on regtest with two wallets: follow mode tracks the toolbar, a pinned wallet survives toolbar switches, and unloading the pinned or last wallet is clean.

Comment thread src/qt/rpcconsole.cpp Outdated
@kwsantiago

kwsantiago commented Jul 25, 2026

Copy link
Copy Markdown
Author

Opened #344 as the bugfix-only version: it just drops the three RPCConsole::setCurrentWallet connects, so the console stays on the wallet it is set to and defaults to the first wallet loaded. No new option, no behavior beyond what 99c0eb9 intended. This PR keeps the "Use displayed wallet" entry.

@kwsantiago
kwsantiago force-pushed the fix-rpcconsole-wallet-selector-sync branch from 78c9368 to 28aa3c1 Compare July 25, 2026 18:51
@kwsantiago

Copy link
Copy Markdown
Author

Rebased on #344, so this is now feature-only: the bugfix commit is #344 and this adds the "Use displayed wallet" entry on top. Both branches merge together cleanly for assembly, which they did not before.

@kwsantiago
kwsantiago force-pushed the fix-rpcconsole-wallet-selector-sync branch 2 times, most recently from ddab4e6 to c509a38 Compare July 25, 2026 19:58
@kwsantiago
kwsantiago requested a review from luke-jr July 25, 2026 22:30
@kwsantiago
kwsantiago force-pushed the fix-rpcconsole-wallet-selector-sync branch from c509a38 to 0f74ad0 Compare July 26, 2026 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants