From d9af53c7493757de800adf9c9ed1af7b9aa16b73 Mon Sep 17 00:00:00 2001
From: lateminer <9951982+lateminer@users.noreply.github.com>
Date: Sat, 6 Jan 2024 23:10:24 +0100
Subject: [PATCH] Revert "gui: remove legacy wallet creation"
This reverts commit b442580ed2a6173f0cfb86f265887d783dde3ff8.
---
src/qt/bitcoingui.cpp | 27 +++++------
src/qt/bitcoingui.h | 2 -
src/qt/createwalletdialog.cpp | 20 +++++++++
src/qt/createwalletdialog.h | 1 +
src/qt/forms/createwalletdialog.ui | 72 +++++++-----------------------
src/qt/walletcontroller.cpp | 5 ++-
6 files changed, 50 insertions(+), 77 deletions(-)
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 5cb93034d1..58ccbe0fad 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -110,7 +110,10 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
{
/** Create wallet frame and make it the central widget */
walletFrame = new WalletFrame(_platformStyle, this);
- connect(walletFrame, &WalletFrame::createWalletButtonClicked, this, &BitcoinGUI::createWallet);
+ connect(walletFrame, &WalletFrame::createWalletButtonClicked, [this] {
+ auto activity = new CreateWalletActivity(getWalletController(), this);
+ activity->create();
+ });
connect(walletFrame, &WalletFrame::message, [this](const QString& title, const QString& message, unsigned int style) {
this->message(title, message, style);
});
@@ -474,7 +477,12 @@ void BitcoinGUI::createActions()
connect(m_close_wallet_action, &QAction::triggered, [this] {
m_wallet_controller->closeWallet(walletFrame->currentWalletModel(), this);
});
- connect(m_create_wallet_action, &QAction::triggered, this, &BitcoinGUI::createWallet);
+ connect(m_create_wallet_action, &QAction::triggered, [this] {
+ auto activity = new CreateWalletActivity(m_wallet_controller, this);
+ connect(activity, &CreateWalletActivity::created, this, &BitcoinGUI::setCurrentWallet);
+ connect(activity, &CreateWalletActivity::created, rpcConsole, &RPCConsole::setCurrentWallet);
+ activity->create();
+ });
connect(m_close_all_wallets_action, &QAction::triggered, [this] {
m_wallet_controller->closeAllWallets(this);
});
@@ -1215,21 +1223,6 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
progressBar->setToolTip(tooltip);
}
-void BitcoinGUI::createWallet()
-{
-#ifdef ENABLE_WALLET
-#ifndef USE_SQLITE
- // Compiled without sqlite support (required for descriptor wallets)
- message(tr("Error creating wallet"), tr("Cannot create new wallet, the software was compiled without sqlite support (required for descriptor wallets)"), CClientUIInterface::MSG_ERROR);
- return;
-#endif // USE_SQLITE
- auto activity = new CreateWalletActivity(getWalletController(), this);
- connect(activity, &CreateWalletActivity::created, this, &BitcoinGUI::setCurrentWallet);
- connect(activity, &CreateWalletActivity::created, rpcConsole, &RPCConsole::setCurrentWallet);
- activity->create();
-#endif // ENABLE_WALLET
-}
-
void BitcoinGUI::message(const QString& title, QString message, unsigned int style, bool* ret, const QString& detailed_message)
{
// Default title. On macOS, the window title is ignored (as required by the macOS Guidelines).
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 1c6346e828..d10efb8282 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -238,8 +238,6 @@ public Q_SLOTS:
void setNetworkActive(bool network_active);
/** Set number of blocks and last block date shown in the UI */
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state);
- /** Launch the wallet creation modal (no-op if wallet is not compiled) **/
- void createWallet();
/** Notify the user of an event from the core network or transaction handling code.
@param[in] title the message box / notification title
diff --git a/src/qt/createwalletdialog.cpp b/src/qt/createwalletdialog.cpp
index 9857c6a240..48657b884c 100644
--- a/src/qt/createwalletdialog.cpp
+++ b/src/qt/createwalletdialog.cpp
@@ -50,10 +50,12 @@ CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
ui->encrypt_wallet_checkbox->setEnabled(!checked);
ui->blank_wallet_checkbox->setEnabled(!checked);
ui->disable_privkeys_checkbox->setEnabled(!checked);
+ ui->descriptor_checkbox->setEnabled(!checked);
// The external signer checkbox is only enabled when a device is detected.
// In that case it is checked by default. Toggling it restores the other
// options to their default.
+ ui->descriptor_checkbox->setChecked(checked);
ui->encrypt_wallet_checkbox->setChecked(false);
ui->disable_privkeys_checkbox->setChecked(checked);
ui->blank_wallet_checkbox->setChecked(false);
@@ -85,6 +87,19 @@ CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
}
});
+#ifndef USE_SQLITE
+ ui->descriptor_checkbox->setToolTip(tr("Compiled without sqlite support (required for descriptor wallets)"));
+ ui->descriptor_checkbox->setEnabled(false);
+ ui->descriptor_checkbox->setChecked(false);
+ ui->external_signer_checkbox->setEnabled(false);
+ ui->external_signer_checkbox->setChecked(false);
+#endif
+
+#ifndef USE_BDB
+ ui->descriptor_checkbox->setEnabled(false);
+ ui->descriptor_checkbox->setChecked(true);
+#endif
+
#ifndef ENABLE_EXTERNAL_SIGNER
//: "External signing" means using devices such as hardware wallets.
ui->external_signer_checkbox->setToolTip(tr("Compiled without external signing support (required for external signing)"));
@@ -142,6 +157,11 @@ bool CreateWalletDialog::isMakeBlankWalletChecked() const
return ui->blank_wallet_checkbox->isChecked();
}
+bool CreateWalletDialog::isDescriptorWalletChecked() const
+{
+ return ui->descriptor_checkbox->isChecked();
+}
+
bool CreateWalletDialog::isExternalSignerChecked() const
{
return ui->external_signer_checkbox->isChecked();
diff --git a/src/qt/createwalletdialog.h b/src/qt/createwalletdialog.h
index 24ee97385b..939b82ff78 100644
--- a/src/qt/createwalletdialog.h
+++ b/src/qt/createwalletdialog.h
@@ -35,6 +35,7 @@ class CreateWalletDialog : public QDialog
bool isEncryptWalletChecked() const;
bool isDisablePrivateKeysChecked() const;
bool isMakeBlankWalletChecked() const;
+ bool isDescriptorWalletChecked() const;
bool isExternalSignerChecked() const;
private:
diff --git a/src/qt/forms/createwalletdialog.ui b/src/qt/forms/createwalletdialog.ui
index 1d6f0ed530..56adbe17a5 100644
--- a/src/qt/forms/createwalletdialog.ui
+++ b/src/qt/forms/createwalletdialog.ui
@@ -6,8 +6,8 @@
0
0
- 371
- 298
+ 364
+ 249
@@ -17,48 +17,6 @@
true
- -
-
-
-
- 0
- 0
-
-
-
- You are one step away from creating your new wallet!
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- false
-
-
-
- -
-
-
- Please provide a name and, if desired, enable any advanced options
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 3
-
-
-
-
-
-
@@ -117,19 +75,7 @@
Advanced Options
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- false
-
-
- false
-
-
- 9
-
-
@@ -153,6 +99,19 @@
+ -
+
+
+ Use descriptors for scriptPubKey management
+
+
+ Descriptor Wallet
+
+
+ true
+
+
+
-
@@ -196,6 +155,7 @@
encrypt_wallet_checkbox
disable_privkeys_checkbox
blank_wallet_checkbox
+ descriptor_checkbox
external_signer_checkbox
diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp
index fc21ca545c..5d8c17ad67 100644
--- a/src/qt/walletcontroller.cpp
+++ b/src/qt/walletcontroller.cpp
@@ -255,14 +255,15 @@ void CreateWalletActivity::createWallet()
std::string name = m_create_wallet_dialog->walletName().toStdString();
uint64_t flags = 0;
- // Enable descriptors by default.
- flags |= WALLET_FLAG_DESCRIPTORS;
if (m_create_wallet_dialog->isDisablePrivateKeysChecked()) {
flags |= WALLET_FLAG_DISABLE_PRIVATE_KEYS;
}
if (m_create_wallet_dialog->isMakeBlankWalletChecked()) {
flags |= WALLET_FLAG_BLANK_WALLET;
}
+ if (m_create_wallet_dialog->isDescriptorWalletChecked()) {
+ flags |= WALLET_FLAG_DESCRIPTORS;
+ }
if (m_create_wallet_dialog->isExternalSignerChecked()) {
flags |= WALLET_FLAG_EXTERNAL_SIGNER;
}