GUI: Add RPC console option to follow the wallet displayed in the main window - #331
Conversation
|
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. I then built using guix. And tested with: I repeated the test of creating two wallets, and the fix works for me. The console follows the selected wallet. |
|
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 ()"? |
accba6a to
78c9368
Compare
|
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. |
78c9368 to
28aa3c1
Compare
ddab4e6 to
c509a38
Compare
c509a38 to
0f74ad0
Compare
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.
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-qton regtest with two wallets loaded,wallet_aandwallet_b.wallet_b, the console stayed onwallet_aand commands ran againstwallet_a. After it, the same steps run againstwallet_b.wallet_a: switching the toolbar back and forth leaves the console onwallet_a.loadwallet: the console follows the newly displayed wallet.unloadwalleton the pinned wallet, and on the last wallet: no crash, commands fall back to the remaining wallet and then to no wallet.-DENABLE_WALLET=OFF: builds and runs, console unaffected.test_bitcoin-qtpasses.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.