aboutsummaryrefslogtreecommitdiff
path: root/src/qt/walletcontroller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/walletcontroller.cpp')
-rw-r--r--src/qt/walletcontroller.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp
index 7413a1f09e..9c1488fb0e 100644
--- a/src/qt/walletcontroller.cpp
+++ b/src/qt/walletcontroller.cpp
@@ -1,10 +1,11 @@
-// Copyright (c) 2019 The Bitcoin Core developers
+// Copyright (c) 2019-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/walletcontroller.h>
#include <qt/askpassphrasedialog.h>
+#include <qt/clientmodel.h>
#include <qt/createwalletdialog.h>
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
@@ -24,13 +25,14 @@
#include <QTimer>
#include <QWindow>
-WalletController::WalletController(interfaces::Node& node, const PlatformStyle* platform_style, OptionsModel* options_model, QObject* parent)
+WalletController::WalletController(ClientModel& client_model, const PlatformStyle* platform_style, QObject* parent)
: QObject(parent)
, m_activity_thread(new QThread(this))
, m_activity_worker(new QObject)
- , m_node(node)
+ , m_client_model(client_model)
+ , m_node(client_model.node())
, m_platform_style(platform_style)
- , m_options_model(options_model)
+ , m_options_model(client_model.getOptionsModel())
{
m_handler_load_wallet = m_node.handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
getOrCreateWallet(std::move(wallet));
@@ -104,7 +106,7 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
}
// Instantiate model and register it.
- WalletModel* wallet_model = new WalletModel(std::move(wallet), m_node, m_platform_style, m_options_model, nullptr);
+ WalletModel* wallet_model = new WalletModel(std::move(wallet), m_client_model, m_platform_style, nullptr);
// Handler callback runs in a different thread so fix wallet model thread affinity.
wallet_model->moveToThread(thread());
wallet_model->setParent(this);
@@ -116,7 +118,7 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
const bool called = QMetaObject::invokeMethod(wallet_model, "startPollBalance");
assert(called);
- connect(wallet_model, &WalletModel::unload, [this, wallet_model] {
+ connect(wallet_model, &WalletModel::unload, this, [this, wallet_model] {
// Defer removeAndDeleteWallet when no modal widget is active.
// TODO: remove this workaround by removing usage of QDiallog::exec.
if (QApplication::activeModalWidget()) {
@@ -128,7 +130,7 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
} else {
removeAndDeleteWallet(wallet_model);
}
- });
+ }, Qt::QueuedConnection);
// Re-emit coinsSent signal from wallet model.
connect(wallet_model, &WalletModel::coinsSent, this, &WalletController::coinsSent);
@@ -166,6 +168,7 @@ WalletControllerActivity::~WalletControllerActivity()
void WalletControllerActivity::showProgressDialog(const QString& label_text)
{
+ assert(!m_progress_dialog);
m_progress_dialog = new QProgressDialog(m_parent_widget);
m_progress_dialog->setLabelText(label_text);
@@ -175,6 +178,13 @@ void WalletControllerActivity::showProgressDialog(const QString& label_text)
GUIUtil::PolishProgressDialog(m_progress_dialog);
}
+void WalletControllerActivity::destroyProgressDialog()
+{
+ assert(m_progress_dialog);
+ delete m_progress_dialog;
+ m_progress_dialog = nullptr;
+}
+
CreateWalletActivity::CreateWalletActivity(WalletController* wallet_controller, QWidget* parent_widget)
: WalletControllerActivity(wallet_controller, parent_widget)
{
@@ -216,10 +226,13 @@ void CreateWalletActivity::createWallet()
if (m_create_wallet_dialog->isMakeBlankWalletChecked()) {
flags |= WALLET_FLAG_BLANK_WALLET;
}
+ if (m_create_wallet_dialog->isDescriptorWalletChecked()) {
+ flags |= WALLET_FLAG_DESCRIPTORS;
+ }
QTimer::singleShot(500, worker(), [this, name, flags] {
- std::unique_ptr<interfaces::Wallet> wallet;
- WalletCreationStatus status = node().createWallet(m_passphrase, flags, name, m_error_message, m_warning_message, wallet);
+ WalletCreationStatus status;
+ std::unique_ptr<interfaces::Wallet> wallet = node().createWallet(m_passphrase, flags, name, m_error_message, m_warning_message, status);
if (status == WalletCreationStatus::SUCCESS) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
@@ -229,7 +242,7 @@ void CreateWalletActivity::createWallet()
void CreateWalletActivity::finish()
{
- m_progress_dialog->hide();
+ destroyProgressDialog();
if (!m_error_message.empty()) {
QMessageBox::critical(m_parent_widget, tr("Create wallet failed"), QString::fromStdString(m_error_message));
@@ -270,7 +283,7 @@ OpenWalletActivity::OpenWalletActivity(WalletController* wallet_controller, QWid
void OpenWalletActivity::finish()
{
- m_progress_dialog->hide();
+ destroyProgressDialog();
if (!m_error_message.empty()) {
QMessageBox::critical(m_parent_widget, tr("Open wallet failed"), QString::fromStdString(m_error_message));