Skip to content

Commit e9f079d

Browse files
hebastoPastaPastaPasta
authored andcommitted
Merge bitcoin-core/gui#696: Switch RPCConsole wallet selection to the one most recently opened/restored/created
99c0eb9 Fix RPCConsole wallet selection (John Moffett) Pull request description: If a user opens multiple wallets in the GUI from the menu bar, the last one opened is the active one in the main window. However, For the RPC Console window, the _first_ one opened is active. This can be confusing, as wallet RPC commands may be sent to a wallet the user didn't intend. This PR makes the RPC Console switch to the wallet just opened / restored / created from the menu bar, which is how the main GUI now works. Similar to bitcoin-core/gui#665 and specifically requested [in a comment](bitcoin-core/gui#665 (comment)). ACKs for top commit: luke-jr: utACK 99c0eb9 hebasto: ACK 99c0eb9, tested on Ubuntu 23.04. Tree-SHA512: d5e5acdaa114130ad4d27fd3f25393bc8d02d92b5001cd39352601d04283cdad3bd62c4da6d369c69764e3b188e9cd3e83152c00b09bd42966082ad09037c328
1 parent d5f83e3 commit e9f079d

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/qt/bitcoingui.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ void BitcoinGUI::createActions()
537537
connect(action, &QAction::triggered, [this, path] {
538538
auto activity = new OpenWalletActivity(m_wallet_controller, this);
539539
connect(activity, &OpenWalletActivity::opened, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection);
540+
connect(activity, &OpenWalletActivity::opened, rpcConsole, &RPCConsole::setCurrentWallet, Qt::QueuedConnection);
540541
activity->open(path);
541542
});
542543
}
@@ -566,6 +567,7 @@ void BitcoinGUI::createActions()
566567

567568
auto activity = new RestoreWalletActivity(m_wallet_controller, this);
568569
connect(activity, &RestoreWalletActivity::restored, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection);
570+
connect(activity, &RestoreWalletActivity::restored, rpcConsole, &RPCConsole::setCurrentWallet, Qt::QueuedConnection);
569571

570572
auto backup_file_path = fs::PathFromString(backup_file.toStdString());
571573
activity->restore(backup_file_path, wallet_name.toStdString());
@@ -576,6 +578,7 @@ void BitcoinGUI::createActions()
576578
connect(m_create_wallet_action, &QAction::triggered, [this] {
577579
auto activity = new CreateWalletActivity(m_wallet_controller, this);
578580
connect(activity, &CreateWalletActivity::created, this, &BitcoinGUI::setCurrentWallet);
581+
connect(activity, &CreateWalletActivity::created, rpcConsole, &RPCConsole::setCurrentWallet);
579582
activity->create();
580583
});
581584
connect(m_close_all_wallets_action, &QAction::triggered, [this] {

src/qt/rpcconsole.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,12 @@ void RPCConsole::removeWallet(WalletModel * const walletModel)
863863
ui->wallet_path->clear();
864864
}
865865
}
866+
867+
void RPCConsole::setCurrentWallet(WalletModel* const wallet_model)
868+
{
869+
QVariant data = QVariant::fromValue(wallet_model);
870+
ui->WalletSelector->setCurrentIndex(ui->WalletSelector->findData(data));
871+
}
866872
#endif
867873

868874
static QString categoryClass(int category)

src/qt/rpcconsole.h

+4
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ public Q_SLOTS:
143143
void unbanSelectedNode();
144144
/** set which tab has the focus (is visible) */
145145
void setTabFocus(enum TabTypes tabType);
146+
#ifdef ENABLE_WALLET
147+
/** Set the current (ie - active) wallet */
148+
void setCurrentWallet(WalletModel* const wallet_model);
149+
#endif // ENABLE_WALLET
146150

147151
Q_SIGNALS:
148152
// For RPC command executor

0 commit comments

Comments
 (0)