Skip to content

Commit 4666e2c

Browse files
laanwjxdustinface
authored andcommitted
Merge bitcoin#13275: Qt: use [default wallet] as name for wallet with no name
2885c13 Qt: use [default wallet] as name for wallet with no name (Jonas Schnelli) Pull request description: Loading a wallet from a state where only the default wallet was active results in using an empty string for the initial/default wallet name. This is a GUI only quick-fix that overrides wallet(s) with name "" to "[default wallet]". Does not affect `getwalletinfo` or `listwallets`. Also, unsure if it should be fixed at a deeper level and if – instead of [default wallet] – it should use `wallet.dat` (the filename of the default wallet). Tree-SHA512: 1d50dbb200b23df5ac53ce15aeb6453af4da354d6e6e53fe33ff075b477493254d6028b6d3569a7804b1aa616cb9a988a53de818937e37cdcb19cb70a90e2a88
1 parent 5db88d2 commit 4666e2c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/qt/bitcoingui.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ void BitcoinGUI::createToolBars()
639639

640640
#ifdef ENABLE_WALLET
641641
m_wallet_selector = new QComboBox(this);
642-
connect(m_wallet_selector, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setCurrentWallet(const QString&)));
642+
connect(m_wallet_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentWalletBySelectorIndex(int)));
643643

644644
QVBoxLayout* walletSelectorLayout = new QVBoxLayout(this);
645645
walletSelectorLayout->addWidget(m_wallet_selector);
@@ -780,8 +780,9 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel)
780780
if(!walletFrame)
781781
return false;
782782
const QString name = walletModel->getWalletName();
783+
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
783784
setWalletActionsEnabled(true);
784-
m_wallet_selector->addItem(name);
785+
m_wallet_selector->addItem(display_name, name);
785786
if (m_wallet_selector->count() == 2) {
786787
m_wallet_selector_action->setVisible(true);
787788
}
@@ -811,6 +812,12 @@ bool BitcoinGUI::setCurrentWallet(const QString& name)
811812
return walletFrame->setCurrentWallet(name);
812813
}
813814

815+
bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
816+
{
817+
QString internal_name = m_wallet_selector->itemData(index).toString();
818+
return setCurrentWallet(internal_name);
819+
}
820+
814821
void BitcoinGUI::removeAllWallets()
815822
{
816823
if(!walletFrame)

src/qt/bitcoingui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ public Q_SLOTS:
239239

240240
#ifdef ENABLE_WALLET
241241
bool setCurrentWallet(const QString& name);
242+
bool setCurrentWalletBySelectorIndex(int index);
242243
/** Set the UI status indicators based on the currently selected wallet.
243244
*/
244245
void updateWalletStatus();

src/qt/rpcconsole.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,8 @@ void RPCConsole::addWallet(WalletModel * const walletModel)
743743
{
744744
const QString name = walletModel->getWalletName();
745745
// use name for text and internal data object (to allow to move to a wallet id later)
746-
ui->WalletSelector->addItem(name, name);
746+
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
747+
ui->WalletSelector->addItem(display_name, name);
747748
if (ui->WalletSelector->count() == 2 && !isVisible()) {
748749
// First wallet added, set to default so long as the window isn't presently visible (and potentially in use)
749750
ui->WalletSelector->setCurrentIndex(1);

0 commit comments

Comments
 (0)