diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include
index e60c9252b399..f0f4bc840bfe 100644
--- a/src/Makefile.qt.include
+++ b/src/Makefile.qt.include
@@ -16,7 +16,6 @@ QT_FORMS_UI = \
qt/forms/helpmessagedialog.ui \
qt/forms/intro.ui \
qt/forms/openuridialog.ui \
- qt/forms/optionsdialog.ui \
qt/forms/rpcconsole.ui \
qt/pivx/forms/loadingdialog.ui \
qt/pivx/forms/snackbar.ui \
@@ -59,8 +58,6 @@ QT_FORMS_UI = \
qt/pivx/settings/forms/settingsfaqwidget.ui \
qt/pivx/settings/forms/settingsinformationwidget.ui \
qt/pivx/settings/forms/settingsmainoptionswidget.ui \
- qt/pivx/settings/forms/settingsmultisenddialog.ui \
- qt/pivx/settings/forms/settingsmultisendwidget.ui \
qt/pivx/settings/forms/settingssignmessagewidgets.ui \
qt/pivx/settings/forms/settingswalletoptionswidget.ui \
qt/pivx/settings/forms/settingswalletrepairwidget.ui \
@@ -87,7 +84,6 @@ QT_MOC_CPP = \
qt/moc_macnotificationhandler.cpp \
qt/moc_notificator.cpp \
qt/moc_openuridialog.cpp \
- qt/moc_optionsdialog.cpp \
qt/moc_optionsmodel.cpp \
qt/moc_peertablemodel.cpp \
qt/moc_paymentserver.cpp \
@@ -148,8 +144,6 @@ QT_MOC_CPP = \
qt/pivx/settings/moc_settingsfaqwidget.cpp \
qt/pivx/settings/moc_settingsinformationwidget.cpp \
qt/pivx/settings/moc_settingsmainoptionswidget.cpp \
- qt/pivx/settings/moc_settingsmultisenddialog.cpp \
- qt/pivx/settings/moc_settingsmultisendwidget.cpp \
qt/pivx/settings/moc_settingssignmessagewidgets.cpp \
qt/pivx/settings/moc_settingswalletoptionswidget.cpp \
qt/pivx/settings/moc_settingswalletrepairwidget.cpp \
@@ -195,7 +189,6 @@ BITCOIN_QT_H = \
qt/networkstyle.h \
qt/notificator.h \
qt/openuridialog.h \
- qt/optionsdialog.h \
qt/optionsmodel.h \
qt/paymentrequestplus.h \
qt/paymentserver.h \
@@ -269,8 +262,6 @@ BITCOIN_QT_H = \
qt/pivx/settings/settingsfaqwidget.h \
qt/pivx/settings/settingsinformationwidget.h \
qt/pivx/settings/settingsmainoptionswidget.h \
- qt/pivx/settings/settingsmultisenddialog.h \
- qt/pivx/settings/settingsmultisendwidget.h \
qt/pivx/settings/settingssignmessagewidgets.h \
qt/pivx/settings/settingswalletoptionswidget.h \
qt/pivx/settings/settingswalletrepairwidget.h \
@@ -511,7 +502,6 @@ BITCOIN_QT_BASE_CPP = \
qt/intro.cpp \
qt/networkstyle.cpp \
qt/notificator.cpp \
- qt/optionsdialog.cpp \
qt/optionsmodel.cpp \
qt/peertablemodel.cpp \
qt/platformstyle.cpp \
@@ -592,8 +582,6 @@ BITCOIN_QT_WALLET_CPP = \
qt/pivx/settings/settingsfaqwidget.cpp \
qt/pivx/settings/settingsinformationwidget.cpp \
qt/pivx/settings/settingsmainoptionswidget.cpp \
- qt/pivx/settings/settingsmultisenddialog.cpp \
- qt/pivx/settings/settingsmultisendwidget.cpp \
qt/pivx/settings/settingssignmessagewidgets.cpp \
qt/pivx/settings/settingswalletoptionswidget.cpp \
qt/pivx/settings/settingswalletrepairwidget.cpp \
diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt
index fa45f530d5a5..ecec5dc0130c 100644
--- a/src/qt/CMakeLists.txt
+++ b/src/qt/CMakeLists.txt
@@ -87,7 +87,6 @@ SET(QT_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/intro.cpp
${CMAKE_CURRENT_SOURCE_DIR}/networkstyle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/notificator.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/optionsdialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/optionsmodel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/peertablemodel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platformstyle.cpp
@@ -164,8 +163,6 @@ SET(QT_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/pivx/settings/settingsfaqwidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pivx/settings/settingsinformationwidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pivx/settings/settingsmainoptionswidget.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/pivx/settings/settingsmultisenddialog.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/pivx/settings/settingsmultisendwidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pivx/settings/settingssignmessagewidgets.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pivx/settings/settingswalletoptionswidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pivx/settings/settingswalletrepairwidget.cpp
diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui
deleted file mode 100644
index 02ba6afd6191..000000000000
--- a/src/qt/forms/optionsdialog.ui
+++ /dev/null
@@ -1,845 +0,0 @@
-
-
- OptionsDialog
-
-
-
- 0
- 0
- 576
- 442
-
-
-
- Options
-
-
- true
-
-
- -
-
-
- 0
-
-
-
- &Main
-
-
-
-
-
-
- Automatically start PIVX after logging in to the system.
-
-
- &Start PIVX on system login
-
-
-
- -
-
-
-
-
-
- Size of &database cache
-
-
- Qt::PlainText
-
-
- databaseCache
-
-
-
- -
-
-
- -
-
-
- MB
-
-
- Qt::PlainText
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
-
-
-
- Number of script &verification threads
-
-
- Qt::PlainText
-
-
- threadsScriptVerif
-
-
-
- -
-
-
- (0 = auto, <0 = leave that many cores free)
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
-
- 0
-
-
-
-
-
-
-
-
- Enable automatic minting of PIV units to zPIV
-
-
- Qt::LeftToRight
-
-
- Enable zPIV Automint
-
-
-
- -
-
-
- Enable automatic zPIV minting from specific addresses
-
-
- Qt::LeftToRight
-
-
- Enable Automint Addresses
-
-
-
-
-
- -
-
-
-
-
-
- Percentage of incoming PIV which get automatically converted to zPIV via Zerocoin Protocol (min: 10%)
-
-
- Percentage of autominted zPIV
-
-
-
- -
-
-
- 1
-
-
- 100
-
-
-
-
-
- -
-
-
- QLayout::SetFixedSize
-
-
-
-
-
-
- 16777215
- 16777215
-
-
-
- Wait with automatic conversion to Zerocoin until enough PIV for this denomination is available
-
-
- Preferred Automint zPIV Denomination
-
-
-
- -
-
-
-
- 16777215
- 27
-
-
-
- Wait with automatic conversion to Zerocoin until enough PIV for this denomination is available
-
-
- 9
-
-
- 9
-
-
-
-
-
-
-
-
-
-
-
-
- W&allet
-
-
- -
-
-
-
-
-
- Stake split threshold:
-
-
-
- -
-
-
- 1
-
-
- 999999
-
-
-
-
-
- -
-
-
- Expert
-
-
-
-
-
-
- Whether to show coin control features or not.
-
-
- Enable coin &control features
-
-
-
- -
-
-
- Show additional tab listing all your masternodes in first sub-tab<br/>and all masternodes on the network in second sub-tab.
-
-
- Show Masternodes Tab
-
-
-
- -
-
-
- If you disable the spending of unconfirmed change, the change from a transaction<br/>cannot be used until that transaction has at least one confirmation.<br/>This also affects how your balance is computed.
-
-
- &Spend unconfirmed change
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
- &Network
-
-
- -
-
-
- Automatically open the PIVX client port on the router. This only works when your router supports UPnP and it is enabled.
-
-
- Map port using &UPnP
-
-
-
- -
-
-
- Accept connections from outside
-
-
- Allow incoming connections
-
-
-
- -
-
-
- Connect to the PIVX network through a SOCKS5 proxy.
-
-
- &Connect through SOCKS5 proxy (default proxy):
-
-
-
- -
-
-
-
-
-
- Proxy &IP:
-
-
- Qt::PlainText
-
-
- proxyIp
-
-
-
- -
-
-
-
- 140
- 0
-
-
-
-
- 140
- 16777215
-
-
-
- IP address of the proxy (e.g. IPv4: 127.0.0.1 / IPv6: ::1)
-
-
-
- -
-
-
- &Port:
-
-
- Qt::PlainText
-
-
- proxyPort
-
-
-
- -
-
-
-
- 55
- 0
-
-
-
-
- 55
- 16777215
-
-
-
- Port of the proxy (e.g. 9050)
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
- &Window
-
-
- -
-
-
- Show only a tray icon after minimizing the window.
-
-
- &Minimize to the tray instead of the taskbar
-
-
-
- -
-
-
- Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu.
-
-
- M&inimize on close
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
- &Display
-
-
- -
-
-
-
-
-
- User Interface &language:
-
-
- Qt::PlainText
-
-
- lang
-
-
-
- -
-
-
- The user interface language can be set here. This setting will take effect after restarting PIVX.
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Language missing or translation incomplete? Help contributing translations here:
-https://www.transifex.com/pivx-project/pivx-project-translations
-
-
- true
-
-
- true
-
-
- Qt::TextBrowserInteraction
-
-
-
- -
-
-
-
-
-
- User Interface Theme:
-
-
-
- -
-
-
-
-
- -
-
-
-
- 0
-
-
-
-
-
- Qt::Horizontal
-
-
-
- -
-
-
-
-
-
- Unit to show amounts in:
-
-
- Qt::PlainText
-
-
-
- -
-
-
- Choose the default subdivision unit to show in the interface and when sending coins.
-
-
-
-
-
- -
-
-
-
-
-
- Decimal digits
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
- Hide empty balances
-
-
- Qt::LeftToRight
-
-
- Hide empty balances
-
-
-
- -
-
-
- Hide orphan stakes in transaction lists
-
-
- Hide orphan stakes
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
-
-
-
- Third party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items. %s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.
-
-
- Third party transaction URLs
-
-
-
- -
-
-
- Third party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items. %s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
- Active command-line options that override above options:
-
-
- Qt::PlainText
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
-
-
-
- Qt::PlainText
-
-
- true
-
-
-
-
-
-
- -
-
-
-
-
-
- Reset all client options to default.
-
-
- &Reset Options
-
-
- false
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 48
-
-
-
-
- -
-
-
-
- 200
- 0
-
-
-
-
- 75
- true
-
-
-
-
-
-
- Qt::PlainText
-
-
- true
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 48
-
-
-
-
- -
-
-
- &OK
-
-
- false
-
-
- true
-
-
-
- -
-
-
- &Cancel
-
-
- false
-
-
-
-
-
-
-
-
-
- QValidatedLineEdit
- QLineEdit
-
-
-
- QValueComboBox
- QComboBox
-
-
-
-
-
-
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
deleted file mode 100644
index bd2206cc3a52..000000000000
--- a/src/qt/optionsdialog.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-// Copyright (c) 2011-2013 The Bitcoin developers
-// Copyright (c) 2017-2020 The PIVX developers
-// Distributed under the MIT/X11 software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
-#if defined(HAVE_CONFIG_H)
-#include "config/pivx-config.h"
-#endif
-
-#include "optionsdialog.h"
-#include "ui_optionsdialog.h"
-
-#include "bitcoinunits.h"
-#include "guiutil.h"
-#include "optionsmodel.h"
-
-#include "netbase.h"
-#include "txdb.h" // for -dbcache defaults
-
-#ifdef ENABLE_WALLET
-#include "wallet/wallet.h" // for CWallet::minTxFee
-#endif
-
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
- ui(new Ui::OptionsDialog),
- model(0),
- mapper(0),
- fProxyIpValid(true)
-{
- ui->setupUi(this);
- GUIUtil::restoreWindowGeometry("nOptionsDialogWindow", this->size(), this);
-
- /* Main elements init */
- ui->databaseCache->setMinimum(nMinDbCache);
- ui->databaseCache->setMaximum(nMaxDbCache);
- ui->threadsScriptVerif->setMinimum(-GetNumCores());
- ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
-
- /* Network elements init */
-#ifndef USE_UPNP
- ui->mapPortUpnp->setEnabled(false);
-#endif
-
- ui->proxyIp->setEnabled(false);
- ui->proxyPort->setEnabled(false);
- ui->proxyPort->setValidator(new QIntValidator(1, 65535, this));
-
- connect(ui->connectSocks, &QCheckBox::toggled, ui->proxyIp, &QWidget::setEnabled);
- connect(ui->connectSocks, &QCheckBox::toggled, ui->proxyPort, &QWidget::setEnabled);
-
- ui->proxyIp->installEventFilter(this);
- ui->proxyPort->installEventFilter(this);
-
-/* Window elements init */
-#ifdef Q_OS_MAC
- /* remove Window tab on Mac */
- ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow));
-#endif
-
- /* remove Wallet tab in case of -disablewallet */
- if (!enableWallet) {
- ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWallet));
- }
-
- /* Display elements init */
-
- /* Number of displayed decimal digits selector */
- QString digits;
- for (int index = 2; index <= 8; index++) {
- digits.setNum(index);
- ui->digits->addItem(digits, digits);
- }
-
- /* Theme selector static themes */
- ui->theme->addItem(QString("Default"), QVariant("default"));
-
- /* Preferred Zerocoin Denominations */
- ui->preferredDenom->addItem(QString(tr("Any")), QVariant("0"));
- ui->preferredDenom->addItem(QString("1"), QVariant("1"));
- ui->preferredDenom->addItem(QString("5"), QVariant("5"));
- ui->preferredDenom->addItem(QString("10"), QVariant("10"));
- ui->preferredDenom->addItem(QString("50"), QVariant("50"));
- ui->preferredDenom->addItem(QString("100"), QVariant("100"));
- ui->preferredDenom->addItem(QString("500"), QVariant("500"));
- ui->preferredDenom->addItem(QString("1000"), QVariant("1000"));
- ui->preferredDenom->addItem(QString("5000"), QVariant("5000"));
-
- /* Theme selector external themes */
- fs::path pathAddr = GetDataDir() / "themes";
- QDir dir(pathAddr.string().c_str());
- dir.setFilter(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
- QFileInfoList list = dir.entryInfoList();
-
- for (int i = 0; i < list.size(); ++i) {
- QFileInfo fileInfo = list.at(i);
- ui->theme->addItem(fileInfo.fileName(), QVariant(fileInfo.fileName()));
- }
-
- /* Language selector */
- QDir translations(":translations");
- ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
- for (const QString& langStr : translations.entryList()) {
- QLocale locale(langStr);
-
- /** check if the locale name consists of 2 parts (language_country) */
- if(langStr.contains("_"))
- {
- /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
- ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
- }
- else
- {
- /** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */
- ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
- }
- }
- ui->thirdPartyTxUrls->setPlaceholderText("https://example.com/tx/%s");
-
- ui->unit->setModel(new BitcoinUnits(this));
-
- /* Widget-to-option mapper */
- mapper = new QDataWidgetMapper(this);
- mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
- mapper->setOrientation(Qt::Vertical);
-
- /* setup/change UI elements when proxy IP is invalid/valid */
- connect(this, &OptionsDialog::proxyIpChecks, this, &OptionsDialog::doProxyIpChecks);
-}
-
-OptionsDialog::~OptionsDialog()
-{
- GUIUtil::saveWindowGeometry("nOptionsDialogWindow", this);
- delete ui;
-}
-
-void OptionsDialog::setModel(OptionsModel* model)
-{
- this->model = model;
-
- if (model) {
- /* check if client restart is needed and show persistent message */
- if (model->isRestartRequired())
- showRestartWarning(true);
-
- QString strLabel = model->getOverriddenByCommandLine();
- if (strLabel.isEmpty())
- strLabel = tr("none");
- ui->overriddenByCommandLineLabel->setText(strLabel);
-
- mapper->setModel(model);
- setMapper();
- mapper->toFirst();
- }
-
- /* warn when one of the following settings changes by user action (placed here so init via mapper doesn't trigger them) */
-
- /* Main */
- connect(ui->databaseCache, static_cast(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
- connect(ui->threadsScriptVerif, static_cast(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
- /* Wallet */
- connect(ui->spendZeroConfChange, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
- /* Network */
- connect(ui->allowIncoming, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
- connect(ui->connectSocks, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
- /* Display */
- connect(ui->digits, static_cast(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });
- connect(ui->theme, static_cast(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });
- connect(ui->lang, static_cast(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });
- connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, [this]{ showRestartWarning(); });
- connect(ui->showMasternodesTab, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
-}
-
-void OptionsDialog::setMapper()
-{
- /* Main */
- mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
- mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif);
- mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache);
- // Zeromint Enabled
- mapper->addMapping(ui->checkBoxZeromintEnable, OptionsModel::ZeromintEnable);
- // Zeromint Addresses
- mapper->addMapping(ui->checkBoxZeromintAddresses, OptionsModel::ZeromintAddresses);
- // Zerocoin mint percentage
- mapper->addMapping(ui->zeromintPercentage, OptionsModel::ZeromintPercentage);
- // Zerocoin preferred denomination
- mapper->addMapping(ui->preferredDenom, OptionsModel::ZeromintPrefDenom);
-
- /* Wallet */
- mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
- mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
- mapper->addMapping(ui->spinBoxStakeSplitThreshold, OptionsModel::StakeSplitThreshold);
-
- /* Network */
- mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);
- mapper->addMapping(ui->allowIncoming, OptionsModel::Listen);
-
- mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse);
- mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP);
- mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort);
-
- /* Window */
-#ifndef Q_OS_MAC
- mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
- mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);
-#endif
-
- /* Display */
- mapper->addMapping(ui->digits, OptionsModel::Digits);
- mapper->addMapping(ui->theme, OptionsModel::Theme);
- mapper->addMapping(ui->theme, OptionsModel::Theme);
- mapper->addMapping(ui->lang, OptionsModel::Language);
- mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
- mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls);
- mapper->addMapping(ui->checkBoxHideZeroBalances, OptionsModel::HideZeroBalances);
- mapper->addMapping(ui->checkBoxHideOrphans, OptionsModel::HideOrphans);
-
- /* Masternode Tab */
- mapper->addMapping(ui->showMasternodesTab, OptionsModel::ShowMasternodesTab);
-}
-
-void OptionsDialog::enableOkButton()
-{
- /* prevent enabling of the OK button when data modified, if there is an invalid proxy address present */
- if (fProxyIpValid)
- setOkButtonState(true);
-}
-
-void OptionsDialog::disableOkButton()
-{
- setOkButtonState(false);
-}
-
-void OptionsDialog::setOkButtonState(bool fState)
-{
- ui->okButton->setEnabled(fState);
-}
-
-void OptionsDialog::on_resetButton_clicked()
-{
- if (model) {
- // confirmation dialog
- QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"),
- tr("Client restart required to activate changes.") + "
" + tr("Client will be shutdown, do you want to proceed?"),
- QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
-
- if (btnRetVal == QMessageBox::Cancel)
- return;
-
- /* reset all options and close GUI */
- model->Reset();
- QApplication::quit();
- }
-}
-
-void OptionsDialog::on_okButton_clicked()
-{
- mapper->submit();
- pwalletMain->MarkDirty();
- accept();
-}
-
-void OptionsDialog::on_cancelButton_clicked()
-{
- reject();
-}
-
-void OptionsDialog::showRestartWarning(bool fPersistent)
-{
- ui->statusLabel->setStyleSheet("QLabel { color: red; }");
-
- if (fPersistent) {
- ui->statusLabel->setText(tr("Client restart required to activate changes."));
- } else {
- ui->statusLabel->setText(tr("This change would require a client restart."));
- // clear non-persistent status label after 10 seconds
- // Todo: should perhaps be a class attribute, if we extend the use of statusLabel
- QTimer::singleShot(10000, this, &OptionsDialog::clearStatusLabel);
- }
-}
-
-void OptionsDialog::clearStatusLabel()
-{
- ui->statusLabel->clear();
-}
-
-void OptionsDialog::updateHideOrphans(bool fHide)
-{
- if(ui->checkBoxHideOrphans->isChecked() != fHide)
- ui->checkBoxHideOrphans->setChecked(fHide);
-}
-
-void OptionsDialog::doProxyIpChecks(QValidatedLineEdit* pUiProxyIp, QLineEdit* pUiProxyPort)
-{
- const std::string strAddrProxy = pUiProxyIp->text().toStdString();
- const int nProxyPort = pUiProxyPort->text().toInt();
- CService addrProxy(LookupNumeric(strAddrProxy.c_str(), nProxyPort));
-
- // Check for a valid IPv4 / IPv6 address
- if (!(fProxyIpValid = addrProxy.IsValid())) {
- disableOkButton();
- pUiProxyIp->setValid(false);
- ui->statusLabel->setStyleSheet("QLabel { color: red; }");
- ui->statusLabel->setText(tr("The supplied proxy address is invalid."));
- return;
- }
- // Check proxy port
- if (!pUiProxyPort->hasAcceptableInput()) {
- disableOkButton();
- ui->statusLabel->setStyleSheet("QLabel { color: red; }");
- ui->statusLabel->setText(tr("The supplied proxy port is invalid."));
- return;
- }
-
- proxyType checkProxy = proxyType(addrProxy);
- if (!checkProxy.IsValid()) {
- disableOkButton();
- ui->statusLabel->setStyleSheet("QLabel { color: red; }");
- ui->statusLabel->setText(tr("The supplied proxy settings are invalid."));
- return;
- }
-
- enableOkButton();
- ui->statusLabel->clear();
-}
-
-bool OptionsDialog::eventFilter(QObject* object, QEvent* event)
-{
- if (event->type() == QEvent::FocusOut) {
- if (object == ui->proxyIp || object == ui->proxyPort) {
- Q_EMIT proxyIpChecks(ui->proxyIp, ui->proxyPort);
- }
- }
- return QDialog::eventFilter(object, event);
-}
-
-void OptionsDialog::setCurrentIndex(int index)
-{
- ui->tabWidget->setCurrentIndex(index);
-}
diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h
deleted file mode 100644
index 704ebe49f45c..000000000000
--- a/src/qt/optionsdialog.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2011-2013 The Bitcoin developers
-// Copyright (c) 2017-2019 The PIVX developers
-// Distributed under the MIT/X11 software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
-#ifndef BITCOIN_QT_OPTIONSDIALOG_H
-#define BITCOIN_QT_OPTIONSDIALOG_H
-
-#include
-
-class OptionsModel;
-class QValidatedLineEdit;
-class QLineEdit;
-
-QT_BEGIN_NAMESPACE
-class QDataWidgetMapper;
-QT_END_NAMESPACE
-
-namespace Ui
-{
-class OptionsDialog;
-}
-
-/** Preferences dialog. */
-class OptionsDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit OptionsDialog(QWidget* parent, bool enableWallet);
- ~OptionsDialog();
-
- void setModel(OptionsModel* model);
- void setMapper();
- void setCurrentIndex(int index);
-
-protected:
- bool eventFilter(QObject* object, QEvent* event);
-
-private Q_SLOTS:
- /* enable OK button */
- void enableOkButton();
- /* disable OK button */
- void disableOkButton();
- /* set OK button state (enabled / disabled) */
- void setOkButtonState(bool fState);
- void on_resetButton_clicked();
- void on_okButton_clicked();
- void on_cancelButton_clicked();
-
- void updateHideOrphans(bool fHide);
-
- void showRestartWarning(bool fPersistent = false);
- void clearStatusLabel();
- void doProxyIpChecks(QValidatedLineEdit* pUiProxyIp, QLineEdit* pUiProxyPort);
-
-Q_SIGNALS:
- void proxyIpChecks(QValidatedLineEdit* pUiProxyIp, QLineEdit* pUiProxyPort);
-
-private:
- Ui::OptionsDialog* ui;
- OptionsModel* model;
- QDataWidgetMapper* mapper;
- bool fProxyIpValid;
-};
-
-#endif // BITCOIN_QT_OPTIONSDIALOG_H
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 3346d57425d5..bdb2e4cfadbc 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -47,7 +47,6 @@ void OptionsModel::Init()
// Ensure restart flag is unset on client startup
setRestartRequired(false);
- setSSTChanged(false);
// These are Qt-only settings:
@@ -127,8 +126,6 @@ void OptionsModel::setWalletDefaultOptions(QSettings& settings, bool reset)
if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
addOverriddenOption("-spendzeroconfchange");
if (reset) {
- setStakeSplitThreshold(CWallet::DEFAULT_STAKE_SPLIT_THRESHOLD);
- setUseCustomFee(false);
refreshDataView();
}
}
@@ -261,16 +258,6 @@ QVariant OptionsModel::data(const QModelIndex& index, int role) const
return settings.value("bSpendZeroConfChange");
case ShowMasternodesTab:
return settings.value("fShowMasternodesTab");
- case StakeSplitThreshold:
- {
- // Return CAmount/qlonglong as double
- const CAmount nStakeSplitThreshold = (pwalletMain) ? pwalletMain->nStakeSplitThreshold : CWallet::DEFAULT_STAKE_SPLIT_THRESHOLD;
- return QVariant(static_cast(nStakeSplitThreshold / static_cast(COIN)));
- }
- case fUseCustomFee:
- return QVariant((pwalletMain) ? pwalletMain->fUseCustomFee : false);
- case nCustomFee:
- return QVariant(static_cast((pwalletMain) ? pwalletMain->nCustomFee : CWallet::GetRequiredFee(1000)));
#endif
case DisplayUnit:
return nDisplayUnit;
@@ -375,18 +362,7 @@ bool OptionsModel::setData(const QModelIndex& index, const QVariant& value, int
setRestartRequired(true);
}
break;
- case fUseCustomFee:
- setUseCustomFee(value.toBool());
- break;
- case nCustomFee:
- setCustomFeeValue(value.toLongLong());
- break;
#endif
- case StakeSplitThreshold:
- // Write double as qlonglong/CAmount
- setStakeSplitThreshold(static_cast(value.toDouble() * COIN));
- setSSTChanged(true);
- break;
case DisplayUnit:
setDisplayUnit(value);
break;
@@ -478,61 +454,6 @@ void OptionsModel::setDisplayUnit(const QVariant& value)
}
}
-/* Update StakeSplitThreshold's value in wallet */
-void OptionsModel::setStakeSplitThreshold(const CAmount nStakeSplitThreshold)
-{
- if (pwalletMain && pwalletMain->nStakeSplitThreshold != nStakeSplitThreshold) {
- CWalletDB walletdb(pwalletMain->GetDBHandle());
- LOCK(pwalletMain->cs_wallet);
- {
- pwalletMain->nStakeSplitThreshold = nStakeSplitThreshold;
- walletdb.WriteStakeSplitThreshold(nStakeSplitThreshold);
- }
- }
-}
-
-/* returns default minimum value for stake split threshold as doulbe */
-double OptionsModel::getSSTMinimum() const
-{
- return static_cast(CWallet::minStakeSplitThreshold / COIN);
-}
-
-/* Verify that StakeSplitThreshold's value is either 0 or above the min. Else reset */
-bool OptionsModel::isSSTValid()
-{
- if (pwalletMain && pwalletMain->nStakeSplitThreshold &&
- pwalletMain->nStakeSplitThreshold < CWallet::minStakeSplitThreshold) {
- setStakeSplitThreshold(CWallet::minStakeSplitThreshold);
- return false;
- }
- return true;
-}
-
-/* Update Custom Fee value in wallet */
-void OptionsModel::setUseCustomFee(bool fUse)
-{
- if (pwalletMain && pwalletMain->fUseCustomFee != fUse) {
- CWalletDB walletdb(pwalletMain->GetDBHandle());
- {
- LOCK(pwalletMain->cs_wallet);
- pwalletMain->fUseCustomFee = fUse;
- walletdb.WriteUseCustomFee(fUse);
- }
- }
-}
-
-void OptionsModel::setCustomFeeValue(const CAmount& value)
-{
- if (pwalletMain && pwalletMain->nCustomFee != value) {
- CWalletDB walletdb(pwalletMain->GetDBHandle());
- {
- LOCK(pwalletMain->cs_wallet);
- pwalletMain->nCustomFee = value;
- walletdb.WriteCustomFeeValue(value);
- }
- }
-}
-
bool OptionsModel::getProxySettings(QNetworkProxy& proxy) const
{
// Directly query current base proxy, because
@@ -561,15 +482,3 @@ bool OptionsModel::isRestartRequired()
QSettings settings;
return settings.value("fRestartRequired", false).toBool();
}
-
-void OptionsModel::setSSTChanged(bool fChanged)
-{
- QSettings settings;
- return settings.setValue("fSSTChanged", fChanged);
-}
-
-bool OptionsModel::isSSTChanged()
-{
- QSettings settings;
- return settings.value("fSSTChanged", false).toBool();
-}
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index 4657786a95d3..1c9bc7c5efd9 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -55,10 +55,7 @@ class OptionsModel : public QAbstractListModel
AnonymizePivxAmount, //int
ShowMasternodesTab, // bool
Listen, // bool
- StakeSplitThreshold, // CAmount (LongLong)
ShowColdStakingScreen, // bool
- fUseCustomFee, // bool
- nCustomFee, // CAmount (LongLong)
OptionIDRowCount,
};
@@ -71,13 +68,6 @@ class OptionsModel : public QAbstractListModel
void refreshDataView();
/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
void setDisplayUnit(const QVariant& value);
- /* Update StakeSplitThreshold's value in wallet */
- void setStakeSplitThreshold(const CAmount value);
- double getSSTMinimum() const;
- bool isSSTValid();
- /* Update Custom Fee value in wallet */
- void setUseCustomFee(bool fUse);
- void setCustomFeeValue(const CAmount& value);
/* Explicit getters */
bool isHideCharts() { return fHideCharts; }
@@ -93,8 +83,6 @@ class OptionsModel : public QAbstractListModel
/* Restart flag helper */
void setRestartRequired(bool fRequired);
bool isRestartRequired();
- void setSSTChanged(bool fChanged);
- bool isSSTChanged();
bool resetSettings;
bool isColdStakingScreenEnabled() { return showColdStakingScreen; }
diff --git a/src/qt/pivx/coldstakingmodel.cpp b/src/qt/pivx/coldstakingmodel.cpp
index 9b86108fbe4c..22fc9f19654c 100644
--- a/src/qt/pivx/coldstakingmodel.cpp
+++ b/src/qt/pivx/coldstakingmodel.cpp
@@ -32,7 +32,7 @@ void ColdStakingModel::refresh()
cachedAmount = 0;
// First get all of the p2cs utxo inside the wallet
std::vector utxoList;
- pwalletMain->GetAvailableP2CSCoins(utxoList);
+ model->getAvailableP2CSCoins(utxoList);
if (!utxoList.empty()) {
// Loop over each COutput into a CSDelegation
diff --git a/src/qt/pivx/masternodeswidget.cpp b/src/qt/pivx/masternodeswidget.cpp
index d9297ac48f9a..8fefa18403e2 100644
--- a/src/qt/pivx/masternodeswidget.cpp
+++ b/src/qt/pivx/masternodeswidget.cpp
@@ -77,7 +77,7 @@ MasterNodesWidget::MasterNodesWidget(PIVXGUI *parent) :
new MNHolder(isLightTheme()),
this
);
- mnModel = new MNModel(this);
+ mnModel = new MNModel(this, walletModel);
this->setStyleSheet(parent->styleSheet());
diff --git a/src/qt/pivx/masternodewizarddialog.cpp b/src/qt/pivx/masternodewizarddialog.cpp
index 3a39b381b144..60e1107ebe33 100644
--- a/src/qt/pivx/masternodewizarddialog.cpp
+++ b/src/qt/pivx/masternodewizarddialog.cpp
@@ -11,6 +11,7 @@
#include "qt/pivx/mnmodel.h"
#include "qt/pivx/guitransactionsutils.h"
#include "qt/pivx/qtutils.h"
+#include "qt/walletmodeltransaction.h"
#include
#include
diff --git a/src/qt/pivx/mnmodel.cpp b/src/qt/pivx/mnmodel.cpp
index 04ae3c5430cb..9c80eac19cac 100644
--- a/src/qt/pivx/mnmodel.cpp
+++ b/src/qt/pivx/mnmodel.cpp
@@ -12,7 +12,9 @@
#include "uint256.h"
#include "wallet/wallet.h"
-MNModel::MNModel(QObject *parent) : QAbstractTableModel(parent)
+MNModel::MNModel(QObject *parent, WalletModel* _model) :
+ QAbstractTableModel(parent),
+ walletModel(_model)
{
updateMNList();
}
@@ -34,11 +36,8 @@ void MNModel::updateMNList()
pmn->vin = txIn;
}
nodes.insert(QString::fromStdString(mne.getAlias()), std::make_pair(QString::fromStdString(mne.getIp()), pmn));
- if (pwalletMain) {
- const CWalletTx *walletTx = pwalletMain->GetWalletTx(txHash);
- bool txAccepted = walletTx &&
- WITH_LOCK(pwalletMain->cs_wallet, return walletTx->GetDepthInMainChain()) >= MasternodeCollateralMinConf();
- collateralTxAccepted.insert(mne.getTxHash(), txAccepted);
+ if (walletModel) {
+ collateralTxAccepted.insert(mne.getTxHash(), walletModel->getWalletTxDepth(txHash) >= MasternodeCollateralMinConf());
}
}
Q_EMIT dataChanged(index(0, 0, QModelIndex()), index(end, 5, QModelIndex()) );
@@ -109,9 +108,8 @@ QVariant MNModel::data(const QModelIndex &index, int role) const
case WAS_COLLATERAL_ACCEPTED:{
if (!isAvailable) return false;
std::string txHash = rec->vin.prevout.hash.GetHex();
- if (!collateralTxAccepted.value(txHash)) {
- const CWalletTx *walletTx = pwalletMain->GetWalletTx(rec->vin.prevout.hash);
- return walletTx && WITH_LOCK(pwalletMain->cs_wallet, return walletTx->GetDepthInMainChain()) > 0;
+ if (!collateralTxAccepted.value(txHash) && walletModel) {
+ return walletModel->getWalletTxDepth(rec->vin.prevout.hash) > 0;
}
return true;
}
diff --git a/src/qt/pivx/mnmodel.h b/src/qt/pivx/mnmodel.h
index ca10bf15d1d7..e425e5ea92c1 100644
--- a/src/qt/pivx/mnmodel.h
+++ b/src/qt/pivx/mnmodel.h
@@ -8,13 +8,14 @@
#include
#include "masternode.h"
#include "masternodeconfig.h"
+#include "qt/walletmodel.h"
class MNModel : public QAbstractTableModel
{
Q_OBJECT
public:
- explicit MNModel(QObject *parent = nullptr);
+ explicit MNModel(QObject *parent, WalletModel* _model);
~MNModel() override {
nodes.clear();
collateralTxAccepted.clear();
@@ -56,6 +57,7 @@ class MNModel : public QAbstractTableModel
private:
+ WalletModel* walletModel;
// alias mn node ---> pair
QMap> nodes;
QMap collateralTxAccepted;
diff --git a/src/qt/pivx/pivxgui.cpp b/src/qt/pivx/pivxgui.cpp
index 9bf67562db8d..f7bae2b13fab 100644
--- a/src/qt/pivx/pivxgui.cpp
+++ b/src/qt/pivx/pivxgui.cpp
@@ -653,7 +653,7 @@ void PIVXGUI::incomingTransaction(const QString& date, int unit, const CAmount&
// Only send notifications when not disabled
if (!bdisableSystemnotifications) {
// On new transaction, make an info balloon
- message((amount) < 0 ? (pwalletMain->fMultiSendNotify == true ? tr("Sent MultiSend transaction") : tr("Sent transaction")) : tr("Incoming transaction"),
+ message(amount < 0 ? tr("Sent transaction") : tr("Incoming transaction"),
tr("Date: %1\n"
"Amount: %2\n"
"Type: %3\n"
@@ -663,8 +663,6 @@ void PIVXGUI::incomingTransaction(const QString& date, int unit, const CAmount&
.arg(type)
.arg(address),
CClientUIInterface::MSG_INFORMATION);
-
- pwalletMain->fMultiSendNotify = false;
}
}
diff --git a/src/qt/pivx/sendconfirmdialog.cpp b/src/qt/pivx/sendconfirmdialog.cpp
index 026aeac9865e..984a9b6e6fb5 100644
--- a/src/qt/pivx/sendconfirmdialog.cpp
+++ b/src/qt/pivx/sendconfirmdialog.cpp
@@ -363,12 +363,8 @@ void TxDetailDialog::onOutputsClicked()
}
// Obtain the noteData to get the cached amount value
SaplingNoteData noteData = walletTx->mapSaplingNoteData.at(op);
- Optional opAddr =
- pwalletMain->GetSaplingScriptPubKeyMan()->GetOutPointAddress(*walletTx, op);
-
- QString labelRes = opAddr ? QString::fromStdString(Standard::EncodeDestination(*opAddr)) : "";
- labelRes = labelRes.left(18) + "..." + labelRes.right(18);
- appendOutput(layoutGrid, i, labelRes, *noteData.amount, nDisplayUnit);
+ const QString& addrStr = model->getSaplingAddressString(walletTx, op);
+ appendOutput(layoutGrid, i, addrStr, *noteData.amount, nDisplayUnit);
i++;
}
diff --git a/src/qt/pivx/settings/forms/settingsmultisenddialog.ui b/src/qt/pivx/settings/forms/settingsmultisenddialog.ui
deleted file mode 100644
index cbc59160b272..000000000000
--- a/src/qt/pivx/settings/forms/settingsmultisenddialog.ui
+++ /dev/null
@@ -1,433 +0,0 @@
-
-
- SettingsMultisendDialog
-
-
-
- 0
- 0
- 500
- 428
-
-
-
- Form
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 30
-
-
- 20
-
-
- 30
-
-
- 20
-
-
-
-
-
- 0
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 0
- 40
-
-
-
-
- 16777215
- 40
-
-
-
- padding-left:24px;
-
-
- Transaction Details
-
-
- Qt::AlignCenter
-
-
- 7
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 24
- 24
-
-
-
-
- 24
- 24
-
-
-
- Qt::NoFocus
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
-
- 16777215
- 90
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- 3
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 20
-
-
-
-
- 16777215
- 20
-
-
-
- TextLabel
-
-
-
- -
-
-
-
- 0
- 50
-
-
-
-
- 16777215
- 50
-
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- 3
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 20
-
-
-
-
- 16777215
- 20
-
-
-
- TextLabel
-
-
-
- -
-
-
-
- 0
- 50
-
-
-
-
- 16777215
- 50
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 20
-
-
-
-
- -
-
-
- 5
-
-
-
-
-
-
- 16777215
- 20
-
-
-
- TextLabel
-
-
-
- -
-
-
-
- 0
- 50
-
-
-
-
- 16777215
- 50
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 30
-
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 0
- 50
-
-
-
-
- 200
- 16777215
-
-
-
- Qt::NoFocus
-
-
- CANCEL
-
-
-
- -
-
-
-
- 0
- 50
-
-
-
-
- 200
- 16777215
-
-
-
- Qt::NoFocus
-
-
- SAVE
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/qt/pivx/settings/forms/settingsmultisendwidget.ui b/src/qt/pivx/settings/forms/settingsmultisendwidget.ui
deleted file mode 100644
index 75b3458591bb..000000000000
--- a/src/qt/pivx/settings/forms/settingsmultisendwidget.ui
+++ /dev/null
@@ -1,497 +0,0 @@
-
-
- SettingsMultisendWidget
-
-
-
- 0
- 0
- 437
- 434
-
-
-
- Form
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- 0
-
-
-
-
-
-
- 40
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- 5
-
-
-
-
-
- TextLabel
-
-
-
- -
-
-
- TextLabel
-
-
- true
-
-
-
-
-
- -
-
-
-
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 120
- 30
-
-
-
-
- 120
- 30
-
-
-
- Qt::NoFocus
-
-
-
-
-
- true
-
-
- true
-
-
-
- -
-
-
-
- 120
- 30
-
-
-
-
- 120
- 30
-
-
-
- Qt::NoFocus
-
-
-
-
-
- true
-
-
- true
-
-
- true
-
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 20
-
-
-
-
- -
-
-
- QAbstractItemView::NoSelection
-
-
-
- -
-
-
-
- 0
- 100
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::Vertical
-
-
-
- 20
- 20
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
- 30
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 100
- 100
-
-
-
-
- 100
- 100
-
-
-
- Qt::NoFocus
-
-
-
-
-
-
- 100
- 100
-
-
-
-
- -
-
-
-
-
-
- N/A
-
-
- Qt::AlignCenter
-
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- 0
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- CheckBox
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 20
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- CheckBox
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 12
-
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Expanding
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 200
- 50
-
-
-
- Qt::NoFocus
-
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 10
- 20
-
-
-
-
- -
-
-
-
- 200
- 50
-
-
-
-
- 200
- 50
-
-
-
- Qt::NoFocus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/qt/pivx/settings/forms/settingswidget.ui b/src/qt/pivx/settings/forms/settingswidget.ui
index 9785591b8d39..0dfdce4af62c 100644
--- a/src/qt/pivx/settings/forms/settingswidget.ui
+++ b/src/qt/pivx/settings/forms/settingswidget.ui
@@ -331,34 +331,6 @@
- -
-
-
-
- 0
- 50
-
-
-
-
- 16777215
- 50
-
-
-
- Qt::NoFocus
-
-
- Multisend
-
-
- true
-
-
- false
-
-
-
-
diff --git a/src/qt/pivx/settings/settingsbittoolwidget.cpp b/src/qt/pivx/settings/settingsbittoolwidget.cpp
index 671962bf7ec6..6b537f5fb14e 100644
--- a/src/qt/pivx/settings/settingsbittoolwidget.cpp
+++ b/src/qt/pivx/settings/settingsbittoolwidget.cpp
@@ -166,7 +166,7 @@ void SettingsBitToolWidget::onEncryptKeyButtonENCClicked()
}
CKey key;
- if (!pwalletMain->GetKey(*keyID, key)) {
+ if (!walletModel->getKey(*keyID, key)) {
ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_ENC->setText(tr("Private key for the entered address is not available."));
return;
@@ -272,7 +272,7 @@ void SettingsBitToolWidget::onDecryptClicked()
void SettingsBitToolWidget::importAddressFromDecKey()
{
// whenever a key is imported, we need to scan the whole chain
- WalletRescanReserver reserver(pwalletMain);
+ WalletRescanReserver reserver = walletModel->getRescanReserver();
if (!reserver.reserve()) {
ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_DEC->setText(tr("Wallet is currently rescanning. Abort existing rescan or wait."));
@@ -299,24 +299,20 @@ void SettingsBitToolWidget::importAddressFromDecKey()
ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_DEC->setText(tr("Please wait while key is imported"));
- pwalletMain->MarkDirty();
- pwalletMain->SetAddressBook(vchAddress, "", AddressBook::AddressBookPurpose::RECEIVE);
+ walletModel->updateAddressBookLabels(vchAddress, "", AddressBook::AddressBookPurpose::RECEIVE);
// Don't throw error in case a key is already there
- if (pwalletMain->HaveKey(vchAddress)) {
+ if (walletModel->haveKey(vchAddress)) {
ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_DEC->setText(tr("Cannot import address, key already held by the wallet"));
return;
}
- pwalletMain->mapKeyMetadata[vchAddress].nCreateTime = 1;
-
- if (!pwalletMain->AddKeyPubKey(key, pubkey)) {
+ if (!walletModel->addKeys(key, pubkey, reserver)) {
ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_DEC->setText(tr("Error adding key to the wallet"));
return;
}
- pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), nullptr, reserver, true);
}
ui->statusLabel_DEC->setStyleSheet("QLabel { color: green; }");
diff --git a/src/qt/pivx/settings/settingsmultisenddialog.cpp b/src/qt/pivx/settings/settingsmultisenddialog.cpp
deleted file mode 100644
index c71c980bba56..000000000000
--- a/src/qt/pivx/settings/settingsmultisenddialog.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2019 The PIVX developers
-// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
-#include "qt/pivx/settings/settingsmultisenddialog.h"
-#include "qt/pivx/settings/forms/ui_settingsmultisenddialog.h"
-#include
-#include
-#include "qt/pivx/qtutils.h"
-
-SettingsMultisendDialog::SettingsMultisendDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::SettingsMultisendDialog)
-{
- ui->setupUi(this);
-
- // Stylesheet
- this->setStyleSheet(parent->styleSheet());
-
- // Container
- setCssProperty(ui->frame, "container-dialog");
-
- // Text
- ui->labelTitle->setText(tr("New recipient for multisend"));
- setCssProperty(ui->labelTitle, "text-title-dialog");
-
- // Label
- ui->labelSubtitleLabel->setText(tr("Address Label (optional)"));
- setCssProperty(ui->labelSubtitleLabel, "text-title2-dialog");
-
- ui->lineEditLabel->setPlaceholderText(tr("Enter label to be saved with this address"));
- initCssEditLine(ui->lineEditLabel, true);
-
- // Address
- ui->labelSubtitleAddress->setText("PIVX address or contact label");
- setCssProperty(ui->labelSubtitleAddress, "text-title2-dialog");
- ui->lineEditAddress->setPlaceholderText("Enter address");
- initCssEditLine(ui->lineEditAddress, true);
- ui->lineEditAddress->setValidator(new QRegExpValidator(QRegExp("^[A-Za-z0-9]+"), ui->lineEditAddress));
-
-
- ui->labelSubtitlePercentage->setText(tr("Percentage"));
- setCssProperty(ui->labelSubtitlePercentage, "text-title2-dialog");
- ui->lineEditPercentage->setPlaceholderText("10%");
- initCssEditLine(ui->lineEditPercentage, true);
- ui->lineEditPercentage->setValidator(new QIntValidator(0, 100, ui->lineEditPercentage));
-
- // Buttons
- setCssProperty(ui->btnEsc, "ic-close");
- setCssProperty(ui->btnCancel, "btn-dialog-cancel");
- ui->btnSave->setText("ADD");
- setCssBtnPrimary(ui->btnSave);
-
- connect(ui->btnEsc, &QPushButton::clicked, this, &SettingsMultisendDialog::close);
- connect(ui->btnCancel, &QPushButton::clicked, this, &SettingsMultisendDialog::close);
- connect(ui->btnSave, &QPushButton::clicked, [this](){
- this->isOk = true;
- accept();
- });
-}
-
-QString SettingsMultisendDialog::getAddress(){
- return ui->lineEditAddress->text();
-}
-QString SettingsMultisendDialog::getLabel(){
- return ui->lineEditLabel->text();
-}
-int SettingsMultisendDialog::getPercentage(){
- QString percentage = ui->lineEditPercentage->text();
- if (percentage.isEmpty()) return 0;
- return percentage.toInt();
-}
-
-SettingsMultisendDialog::~SettingsMultisendDialog(){
- delete ui;
-}
diff --git a/src/qt/pivx/settings/settingsmultisenddialog.h b/src/qt/pivx/settings/settingsmultisenddialog.h
deleted file mode 100644
index d66bd854368f..000000000000
--- a/src/qt/pivx/settings/settingsmultisenddialog.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2019 The PIVX developers
-// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
-#ifndef SETTINGSMULTISENDDIALOG_H
-#define SETTINGSMULTISENDDIALOG_H
-
-#include
-
-namespace Ui {
-class SettingsMultisendDialog;
-}
-
-class SettingsMultisendDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit SettingsMultisendDialog(QWidget *parent = nullptr);
- ~SettingsMultisendDialog();
-
- QString getAddress();
- QString getLabel();
- int getPercentage();
-
- bool isOk = false;
-private:
- Ui::SettingsMultisendDialog *ui;
-};
-
-#endif // SETTINGSMULTISENDDIALOG_H
diff --git a/src/qt/pivx/settings/settingsmultisendwidget.cpp b/src/qt/pivx/settings/settingsmultisendwidget.cpp
deleted file mode 100644
index 70be1059c64a..000000000000
--- a/src/qt/pivx/settings/settingsmultisendwidget.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-// Copyright (c) 2019-2020 The PIVX developers
-// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
-#include "qt/pivx/settings/settingsmultisendwidget.h"
-#include "qt/pivx/settings/forms/ui_settingsmultisendwidget.h"
-#include "qt/pivx/settings/settingsmultisenddialog.h"
-#include "qt/pivx/qtutils.h"
-#include "addresstablemodel.h"
-#include "base58.h"
-#include "init.h"
-#include "walletmodel.h"
-#include "wallet/wallet.h"
-
-
-#define DECORATION_SIZE 65
-#define NUM_ITEMS 3
-
-MultiSendModel::MultiSendModel(QObject *parent) : QAbstractTableModel(parent)
-{
- updateList();
-}
-
-void MultiSendModel::updateList()
-{
- Q_EMIT dataChanged(index(0, 0, QModelIndex()), index((int) pwalletMain->vMultiSend.size(), 5, QModelIndex()) );
-}
-
-int MultiSendModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid())
- return 0;
- return (int) pwalletMain->vMultiSend.size();
-}
-
-QVariant MultiSendModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- int row = index.row();
- if (role == Qt::DisplayRole || role == Qt::EditRole) {
- switch (index.column()) {
- case PERCENTAGE:
- return pwalletMain->vMultiSend[row].second;
- case ADDRESS: {
- return QString::fromStdString(pwalletMain->vMultiSend[row].first);
- }
- }
- }
- return QVariant();
-}
-
-QModelIndex MultiSendModel::index(int row, int column, const QModelIndex& parent) const
-{
- Q_UNUSED(parent);
- return createIndex(row, column, nullptr);
-}
-
-class MultiSendHolder : public FurListRow
-{
-public:
- MultiSendHolder();
-
- explicit MultiSendHolder(bool _isLightTheme) : FurListRow(), isLightTheme(_isLightTheme) {}
-
- QWidget* createHolder(int pos) override
- {
- if (!row) {
- row = new QWidget();
- QVBoxLayout *verticalLayout_2;
- QFrame *frame_2;
- QHBoxLayout *horizontalLayout;
- QLabel *labelName;
- QSpacerItem *horizontalSpacer;
- QLabel *labelDate;
- QLabel *lblDivisory;
-
- if (row->objectName().isEmpty())
- row->setObjectName(QStringLiteral("multiSendrow"));
- row->resize(475, 65);
- row->setStyleSheet(QStringLiteral(""));
- setCssProperty(row, "container");
- verticalLayout_2 = new QVBoxLayout(row);
- verticalLayout_2->setSpacing(0);
- verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2"));
- verticalLayout_2->setContentsMargins(20, 0, 20, 0);
- frame_2 = new QFrame(row);
- frame_2->setObjectName(QStringLiteral("frame_2"));
- frame_2->setStyleSheet(QStringLiteral("border:none;"));
- frame_2->setFrameShape(QFrame::StyledPanel);
- frame_2->setFrameShadow(QFrame::Raised);
- horizontalLayout = new QHBoxLayout(frame_2);
- horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
- horizontalLayout->setContentsMargins(0, -1, 0, -1);
- labelName = new QLabel(frame_2);
- labelName->setObjectName(QStringLiteral("labelAddress"));
- setCssProperty(labelName, "text-list-title1");
- horizontalLayout->addWidget(labelName);
-
- horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- horizontalLayout->addItem(horizontalSpacer);
-
- labelDate = new QLabel(frame_2);
- labelDate->setObjectName(QStringLiteral("labelPercentage"));
- setCssProperty(labelDate, "text-list-caption-medium");
- horizontalLayout->addWidget(labelDate);
-
- verticalLayout_2->addWidget(frame_2);
-
- lblDivisory = new QLabel(row);
- lblDivisory->setObjectName(QStringLiteral("lblDivisory"));
- lblDivisory->setMinimumSize(QSize(0, 1));
- lblDivisory->setMaximumSize(QSize(16777215, 1));
- lblDivisory->setStyleSheet(QStringLiteral("background-color:#bababa;"));
- lblDivisory->setAlignment(Qt::AlignBottom | Qt::AlignLeading | Qt::AlignLeft);
- verticalLayout_2->addWidget(lblDivisory);
- }
-
- return row;
- }
-
- void init(QWidget* holder,const QModelIndex &index, bool isHovered, bool isSelected) const override
- {
- holder->findChild("labelAddress")->setText(index.data(Qt::DisplayRole).toString());
- holder->findChild("labelPercentage")->setText(
- QString::number(index.sibling(index.row(), MultiSendModel::PERCENTAGE).data(Qt::DisplayRole).toInt()) + QString("%")
- );
- }
-
- QColor rectColor(bool isHovered, bool isSelected) override
- {
- return getRowColor(isLightTheme, isHovered, isSelected);
- }
-
- ~MultiSendHolder() override {}
-
- bool isLightTheme;
- QWidget *row = nullptr;
-};
-
-
-SettingsMultisendWidget::SettingsMultisendWidget(PWidget *parent) :
- PWidget(parent),
- ui(new Ui::SettingsMultisendWidget)
-{
- ui->setupUi(this);
-
- this->setStyleSheet(parent->styleSheet());
- delegate = new FurAbstractListItemDelegate(
- DECORATION_SIZE,
- new MultiSendHolder(isLightTheme()),
- this
- );
-
- // Containers
- setCssProperty(ui->left, "container");
- ui->left->setContentsMargins(10,10,10,10);
-
- // Title
- ui->labelTitle->setText("Multisend");
- setCssTitleScreen(ui->labelTitle);
-
- ui->labelSubtitle1->setText(tr("MultiSend allows you to automatically send up to 100% of your stake or masternode reward to a list of other PIVX addresses after it matures."));
- setCssSubtitleScreen(ui->labelSubtitle1);
-
- //Button Group
- ui->pushLeft->setText(tr("Active"));
- setCssProperty(ui->pushLeft, "btn-check-left");
- ui->pushRight->setText(tr("Disable"));
- setCssProperty(ui->pushRight, "btn-check-right");
-
- setCssProperty(ui->pushImgEmpty, "img-empty-multisend");
- ui->labelEmpty->setText(tr("No active recipient yet"));
- setCssProperty(ui->labelEmpty, "text-empty");
-
- // CheckBox
- ui->checkBoxStake->setText(tr("Send stakes"));
- ui->checkBoxRewards->setText(tr("Send masternode rewards"));
-
- setCssProperty(ui->listView, "container");
- ui->listView->setItemDelegate(delegate);
- ui->listView->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE));
- ui->listView->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
- ui->listView->setAttribute(Qt::WA_MacShowFocusRect, false);
- ui->listView->setSelectionBehavior(QAbstractItemView::SelectRows);
-
- // Buttons
- ui->pushButtonSave->setText(tr("ADD RECIPIENT"));
- ui->pushButtonClear->setText(tr("CLEAR ALL"));
- setCssBtnPrimary(ui->pushButtonSave);
- setCssBtnSecondary(ui->pushButtonClear);
-
- connect(ui->pushButtonSave, &QPushButton::clicked, this, &SettingsMultisendWidget::onAddRecipientClicked);
- connect(ui->pushButtonClear, &QPushButton::clicked, this, &SettingsMultisendWidget::clearAll);
-}
-
-void SettingsMultisendWidget::showEvent(QShowEvent *event)
-{
- if (multiSendModel) {
- multiSendModel->updateList();
- updateListState();
- }
-}
-
-void SettingsMultisendWidget::loadWalletModel()
-{
- if (walletModel) {
- multiSendModel = new MultiSendModel(this);
- ui->listView->setModel(multiSendModel);
- ui->listView->setModelColumn(MultiSendModel::ADDRESS);
-
- ui->pushLeft->setChecked(pwalletMain->isMultiSendEnabled());
- ui->checkBoxStake->setChecked(pwalletMain->fMultiSendStake);
- ui->checkBoxRewards->setChecked(pwalletMain->fMultiSendMasternodeReward);
- connect(ui->checkBoxStake, &QCheckBox::stateChanged, this, &SettingsMultisendWidget::checkBoxChanged);
- connect(ui->checkBoxRewards, &QCheckBox::stateChanged, this, &SettingsMultisendWidget::checkBoxChanged);
- connect(ui->pushLeft, &QPushButton::clicked, this, &SettingsMultisendWidget::activate);
- connect(ui->pushRight, &QPushButton::clicked, this, &SettingsMultisendWidget::deactivate);
-
- updateListState();
- }
-}
-
-void SettingsMultisendWidget::updateListState()
-{
- if (multiSendModel->rowCount() > 0) {
- ui->listView->setVisible(true);
- ui->emptyContainer->setVisible(false);
- } else {
- ui->listView->setVisible(false);
- ui->emptyContainer->setVisible(true);
- }
-}
-
-void SettingsMultisendWidget::clearAll()
-{
- WalletModel::UnlockContext ctx(walletModel->requestUnlock());
- if (!ctx.isValid()) {
- // Unlock wallet was cancelled
- inform(tr("Cannot perform operation, wallet locked"));
- return;
- }
- std::vector > vMultiSendTemp = pwalletMain->vMultiSend;
- bool fRemoved = true;
- pwalletMain->vMultiSend.clear();
- CWalletDB walletdb(pwalletMain->GetDBHandle());
- if (!walletdb.EraseMultiSend(vMultiSendTemp))
- fRemoved = false;
- if (!walletdb.WriteMultiSend(pwalletMain->vMultiSend))
- fRemoved = false;
-
- checkBoxChanged();
- multiSendModel->updateList();
- updateListState();
- inform(fRemoved ? tr("Clear succeed") : tr("Clear all failed, could not locate address in wallet file"));
-}
-
-void SettingsMultisendWidget::checkBoxChanged()
-{
- pwalletMain->fMultiSendStake = ui->checkBoxStake->isChecked();
- pwalletMain->fMultiSendMasternodeReward = ui->checkBoxRewards->isChecked();
-}
-
-void SettingsMultisendWidget::onAddRecipientClicked()
-{
- WalletModel::UnlockContext ctx(walletModel->requestUnlock());
- if (!ctx.isValid()) {
- // Unlock wallet was cancelled
- inform(tr("Cannot add multisend recipient, wallet locked"));
- return;
- }
- showHideOp(true);
- SettingsMultisendDialog* dialog = new SettingsMultisendDialog(window);
- openDialogWithOpaqueBackgroundY(dialog, window, 3, 5);
-
- if (dialog->isOk) {
- addMultiSend(
- dialog->getAddress(),
- dialog->getPercentage(),
- dialog->getLabel()
- );
- }
- dialog->deleteLater();
-}
-
-void SettingsMultisendWidget::addMultiSend(QString address, int percentage, QString addressLabel)
-{
- std::string strAddress = address.toStdString();
- CTxDestination destAddress = DecodeDestination(strAddress);
- if (!IsValidDestination(destAddress)) {
- inform(tr("The entered address: %1 is invalid.\nPlease check the address and try again.").arg(address));
- return;
- }
- if (percentage > 100 || percentage <= 0) {
- inform(tr("Invalid percentage, please enter values from 1 to 100."));
- return;
- }
-
- int nMultiSendPercent = percentage;
- int nSumMultiSend = 0;
- for (int i = 0; i < (int)pwalletMain->vMultiSend.size(); i++)
- nSumMultiSend += pwalletMain->vMultiSend[i].second;
- if (nSumMultiSend + nMultiSendPercent > 100) {
- inform(tr("The total amount of your MultiSend vector is over 100% of your stake reward"));
- return;
- }
- std::pair pMultiSend;
- pMultiSend.first = strAddress;
- pMultiSend.second = nMultiSendPercent;
- pwalletMain->vMultiSend.push_back(pMultiSend);
-
- if (walletModel && walletModel->getAddressTableModel()) {
- // update the address book with the label given or no label if none was given.
- std::string userInputLabel = addressLabel.toStdString();
- walletModel->updateAddressBookLabels(destAddress, (userInputLabel.empty()) ? "(no label)" : userInputLabel,
- AddressBook::AddressBookPurpose::SEND);
- }
-
- CWalletDB walletdb(pwalletMain->GetDBHandle());
- if (!walletdb.WriteMultiSend(pwalletMain->vMultiSend)) {
- inform(tr("Error saving MultiSend, failed saving properties to the database."));
- return;
- }
-
- multiSendModel->updateList();
- updateListState();
- inform("MultiSend recipient added.");
-}
-
-void SettingsMultisendWidget::activate()
-{
- if (pwalletMain->isMultiSendEnabled())
- return;
- QString strRet;
- if (pwalletMain->vMultiSend.size() < 1)
- strRet = tr("Unable to activate MultiSend, no available recipients");
- else if (!(ui->checkBoxStake->isChecked() || ui->checkBoxRewards->isChecked())) {
- strRet = tr("Unable to activate MultiSend\nCheck one or both of the check boxes to send on stake and/or masternode rewards");
- } else if (IsValidDestinationString(pwalletMain->vMultiSend[0].first, false, Params())) {
- pwalletMain->fMultiSendStake = ui->checkBoxStake->isChecked();
- pwalletMain->fMultiSendMasternodeReward = ui->checkBoxRewards->isChecked();
-
- CWalletDB walletdb(pwalletMain->GetDBHandle());
- if (!walletdb.WriteMSettings(pwalletMain->fMultiSendStake, pwalletMain->fMultiSendMasternodeReward, pwalletMain->nLastMultiSendHeight))
- strRet = tr("MultiSend activated but writing settings to DB failed");
- else
- strRet = tr("MultiSend activated");
- } else
- strRet = tr("First multiSend address invalid");
-
- inform(strRet);
-}
-
-void SettingsMultisendWidget::deactivate()
-{
- if (pwalletMain->isMultiSendEnabled()) {
- QString strRet;
- pwalletMain->setMultiSendDisabled();
- CWalletDB walletdb(pwalletMain->GetDBHandle());
- inform(!walletdb.WriteMSettings(false, false, pwalletMain->nLastMultiSendHeight) ?
- tr("MultiSend deactivated but writing settings to DB failed") :
- tr("MultiSend deactivated")
- );
- }
-}
-
-void SettingsMultisendWidget::changeTheme(bool isLightTheme, QString& theme)
-{
- static_cast(this->delegate->getRowFactory())->isLightTheme = isLightTheme;
-}
-
-SettingsMultisendWidget::~SettingsMultisendWidget()
-{
- delete ui;
-}
diff --git a/src/qt/pivx/settings/settingsmultisendwidget.h b/src/qt/pivx/settings/settingsmultisendwidget.h
deleted file mode 100644
index 82286d8a37b3..000000000000
--- a/src/qt/pivx/settings/settingsmultisendwidget.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2019 The PIVX developers
-// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
-#ifndef SETTINGSMULTISENDWIDGET_H
-#define SETTINGSMULTISENDWIDGET_H
-
-#include
-#include
-#include "qt/pivx/pwidget.h"
-#include "qt/pivx/furabstractlistitemdelegate.h"
-
-class PIVXGUI;
-
-namespace Ui {
-class SettingsMultisendWidget;
-}
-
-class MultiSendModel : public QAbstractTableModel
-{
- Q_OBJECT
-
-public:
- explicit MultiSendModel(QObject *parent = nullptr);
- ~MultiSendModel() override{}
-
- enum ColumnIndex {
- ADDRESS = 0,
- PERCENTAGE = 1
- };
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- int columnCount(const QModelIndex &parent = QModelIndex()) const override { return 2; }
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
- QModelIndex index(int row, int column, const QModelIndex& parent) const override;
- void updateList();
-};
-
-class SettingsMultisendWidget : public PWidget
-{
- Q_OBJECT
-
-public:
- explicit SettingsMultisendWidget(PWidget *parent);
- ~SettingsMultisendWidget();
-
- void showEvent(QShowEvent *event) override;
- void loadWalletModel() override;
- void changeTheme(bool isLightTheme, QString &theme) override;
-
-private Q_SLOTS:
- void onAddRecipientClicked();
- void clearAll();
- void checkBoxChanged();
- void activate();
- void deactivate();
-
-private:
- Ui::SettingsMultisendWidget *ui;
- MultiSendModel* multiSendModel = nullptr;
- FurAbstractListItemDelegate *delegate = nullptr;
-
- void addMultiSend(QString address, int percentage, QString addressLabel);
- void updateListState();
-};
-
-#endif // SETTINGSMULTISENDWIDGET_H
diff --git a/src/qt/pivx/settings/settingssignmessagewidgets.cpp b/src/qt/pivx/settings/settingssignmessagewidgets.cpp
index 671f93285176..bc3413a83999 100644
--- a/src/qt/pivx/settings/settingssignmessagewidgets.cpp
+++ b/src/qt/pivx/settings/settingssignmessagewidgets.cpp
@@ -181,7 +181,7 @@ void SettingsSignMessageWidgets::onSignMessageButtonSMClicked()
}
CKey key;
- if (!pwalletMain->GetKey(*keyID, key)) {
+ if (!walletModel->getKey(*keyID, key)) {
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_SM->setText(tr("Private key for the entered address is not available."));
return;
diff --git a/src/qt/pivx/settings/settingswalletoptionswidget.cpp b/src/qt/pivx/settings/settingswalletoptionswidget.cpp
index 8ad57c92bffe..26a61951c170 100644
--- a/src/qt/pivx/settings/settingswalletoptionswidget.cpp
+++ b/src/qt/pivx/settings/settingswalletoptionswidget.cpp
@@ -57,19 +57,17 @@ SettingsWalletOptionsWidget::SettingsWalletOptionsWidget(PIVXGUI* _window, QWidg
connect(ui->pushButtonClean, &QPushButton::clicked, [this] { Q_EMIT discardSettings(); });
}
-void SettingsWalletOptionsWidget::onResetClicked(){
- if (clientModel) {
- OptionsModel *optionsModel = clientModel->getOptionsModel();
- QSettings settings;
- optionsModel->setWalletDefaultOptions(settings, true);
- optionsModel->setNetworkDefaultOptions(settings, true);
- inform(tr("Options reset succeed"));
- }
+void SettingsWalletOptionsWidget::onResetClicked()
+{
+ QSettings settings;
+ walletModel->resetWalletOptions(settings);
+ clientModel->getOptionsModel()->setNetworkDefaultOptions(settings, true);
+ inform(tr("Options reset succeed"));
}
-void SettingsWalletOptionsWidget::setMapper(QDataWidgetMapper *mapper){
+void SettingsWalletOptionsWidget::setMapper(QDataWidgetMapper *mapper)
+{
mapper->addMapping(ui->radioButtonSpend, OptionsModel::SpendZeroConfChange);
- mapper->addMapping(ui->spinBoxStakeSplitThreshold, OptionsModel::StakeSplitThreshold);
// Network
mapper->addMapping(ui->checkBoxMap, OptionsModel::MapPortUPnP);
@@ -79,11 +77,49 @@ void SettingsWalletOptionsWidget::setMapper(QDataWidgetMapper *mapper){
mapper->addMapping(ui->lineEditPort, OptionsModel::ProxyPort);
}
+void SettingsWalletOptionsWidget::loadWalletModel()
+{
+ reloadWalletOptions();
+ connect(walletModel, &WalletModel::notifySSTChanged, this, &SettingsWalletOptionsWidget::setSpinBoxStakeSplitThreshold);
+}
+
+void SettingsWalletOptionsWidget::reloadWalletOptions()
+{
+ setSpinBoxStakeSplitThreshold(static_cast(walletModel->getWalletStakeSplitThreshold()) / COIN);
+}
+
void SettingsWalletOptionsWidget::setSpinBoxStakeSplitThreshold(double val)
{
ui->spinBoxStakeSplitThreshold->setValue(val);
}
+double SettingsWalletOptionsWidget::getSpinBoxStakeSplitThreshold() const
+{
+ return ui->spinBoxStakeSplitThreshold->value();
+}
+
+bool SettingsWalletOptionsWidget::saveWalletOnlyOptions()
+{
+ // stake split threshold
+ const CAmount sstOld = walletModel->getWalletStakeSplitThreshold();
+ const CAmount sstNew = static_cast(getSpinBoxStakeSplitThreshold() * COIN);
+ if (sstNew != sstOld) {
+ const double stakeSplitMinimum = walletModel->getSSTMinimum();
+ if (sstNew != 0 && sstNew < static_cast(stakeSplitMinimum * COIN)) {
+ setSpinBoxStakeSplitThreshold(stakeSplitMinimum);
+ inform(tr("Stake Split too low, it shall be either >= %1 or equal to 0 (to disable stake splitting)").arg(stakeSplitMinimum));
+ return false;
+ }
+ walletModel->setWalletStakeSplitThreshold(sstNew);
+ }
+ return true;
+}
+
+void SettingsWalletOptionsWidget::discardWalletOnlyOptions()
+{
+ reloadWalletOptions();
+}
+
SettingsWalletOptionsWidget::~SettingsWalletOptionsWidget(){
delete ui;
}
diff --git a/src/qt/pivx/settings/settingswalletoptionswidget.h b/src/qt/pivx/settings/settingswalletoptionswidget.h
index 0af64006d9e3..55a3f7f84905 100644
--- a/src/qt/pivx/settings/settingswalletoptionswidget.h
+++ b/src/qt/pivx/settings/settingswalletoptionswidget.h
@@ -21,7 +21,9 @@ class SettingsWalletOptionsWidget : public PWidget
~SettingsWalletOptionsWidget();
void setMapper(QDataWidgetMapper *mapper);
- void setSpinBoxStakeSplitThreshold(double val);
+
+ void discardWalletOnlyOptions();
+ bool saveWalletOnlyOptions();
Q_SIGNALS:
void saveSettings();
@@ -32,6 +34,12 @@ public Q_SLOTS:
private:
Ui::SettingsWalletOptionsWidget *ui;
+
+ void loadWalletModel() override;
+ void reloadWalletOptions();
+
+ void setSpinBoxStakeSplitThreshold(double val);
+ double getSpinBoxStakeSplitThreshold() const;
};
#endif // SETTINGSWALLETOPTIONSWIDGET_H
diff --git a/src/qt/pivx/settings/settingswidget.cpp b/src/qt/pivx/settings/settingswidget.cpp
index b5e637ace3bd..99510cd387ef 100644
--- a/src/qt/pivx/settings/settingswidget.cpp
+++ b/src/qt/pivx/settings/settingswidget.cpp
@@ -40,7 +40,6 @@ SettingsWidget::SettingsWidget(PIVXGUI* parent) :
setCssProperty(ui->pushButtonFile, "btn-settings-check");
setCssProperty(ui->pushButtonFile2, "btn-settings-options");
- setCssProperty(ui->pushButtonFile3, "btn-settings-options");
setCssProperty(ui->pushButtonExportCsv, "btn-settings-options");
setCssProperty(ui->pushButtonConfiguration, "btn-settings-check");
@@ -63,7 +62,6 @@ SettingsWidget::SettingsWidget(PIVXGUI* parent) :
options = {
ui->pushButtonFile2,
- ui->pushButtonFile3,
ui->pushButtonExportCsv,
ui->pushButtonOptions1,
ui->pushButtonOptions2,
@@ -76,9 +74,6 @@ SettingsWidget::SettingsWidget(PIVXGUI* parent) :
ui->pushButtonTools5,
};
- /* disable multisend for now */
- ui->pushButtonFile3->setVisible(false);
-
menus.insert(ui->pushButtonFile, ui->fileButtonsWidget);
menus.insert(ui->pushButtonConfiguration, ui->configurationButtonsWidget);
menus.insert(ui->pushButtonOptions, ui->optionsButtonsWidget);
@@ -93,7 +88,6 @@ SettingsWidget::SettingsWidget(PIVXGUI* parent) :
settingsWalletOptionsWidget = new SettingsWalletOptionsWidget(window, this);
settingsMainOptionsWidget = new SettingsMainOptionsWidget(window, this);
settingsDisplayOptionsWidget = new SettingsDisplayOptionsWidget(window, this);
- //settingsMultisendWidget = new SettingsMultisendWidget(this); // no visible for now
settingsInformationWidget = new SettingsInformationWidget(window, this);
settingsConsoleWidget = new SettingsConsoleWidget(window, this);
@@ -105,7 +99,6 @@ SettingsWidget::SettingsWidget(PIVXGUI* parent) :
ui->stackedWidgetContainer->addWidget(settingsWalletOptionsWidget);
ui->stackedWidgetContainer->addWidget(settingsMainOptionsWidget);
ui->stackedWidgetContainer->addWidget(settingsDisplayOptionsWidget);
- //ui->stackedWidgetContainer->addWidget(settingsMultisendWidget);
ui->stackedWidgetContainer->addWidget(settingsInformationWidget);
ui->stackedWidgetContainer->addWidget(settingsConsoleWidget);
ui->stackedWidgetContainer->setCurrentWidget(settingsBackupWallet);
@@ -113,7 +106,6 @@ SettingsWidget::SettingsWidget(PIVXGUI* parent) :
// File Section
connect(ui->pushButtonFile, &QPushButton::clicked, this, &SettingsWidget::onFileClicked);
connect(ui->pushButtonFile2, &QPushButton::clicked, this, &SettingsWidget::onBackupWalletClicked);
- connect(ui->pushButtonFile3, &QPushButton::clicked, this, &SettingsWidget::onMultisendClicked);
connect(ui->pushButtonExportCsv, &QPushButton::clicked, this, &SettingsWidget::onExportCSVClicked);
// Options
@@ -148,9 +140,6 @@ SettingsWidget::SettingsWidget(PIVXGUI* parent) :
connect(settingsExportCsvWidget, &SettingsExportCSV::message,this, &SettingsWidget::message);
connect(settingsExportCsvWidget, &SettingsExportCSV::showHide, this, &SettingsWidget::showHide);
connect(settingsExportCsvWidget, &SettingsExportCSV::execDialog, this, &SettingsWidget::execDialog);
- // no visible for now
- //connect(settingsMultisendWidget, &SettingsMultisendWidget::showHide, this, &SettingsWidget::showHide);
- //connect(settingsMultisendWidget, &SettingsMultisendWidget::message, this, &SettingsWidget::message);
connect(settingsMainOptionsWidget, &SettingsMainOptionsWidget::message, this, &SettingsWidget::message);
connect(settingsDisplayOptionsWidget, &SettingsDisplayOptionsWidget::message, this, &SettingsWidget::message);
connect(settingsWalletOptionsWidget, &SettingsWalletOptionsWidget::message, this, &SettingsWidget::message);
@@ -211,8 +200,8 @@ void SettingsWidget::loadWalletModel()
this->settingsExportCsvWidget->setWalletModel(this->walletModel);
this->settingsSingMessageWidgets->setWalletModel(this->walletModel);
this->settingsBitToolWidget->setWalletModel(this->walletModel);
- //this->settingsMultisendWidget->setWalletModel(this->walletModel); no visible for now
this->settingsDisplayOptionsWidget->setWalletModel(this->walletModel);
+ this->settingsWalletOptionsWidget->setWalletModel(this->walletModel);
}
void SettingsWidget::onResetAction()
@@ -230,15 +219,13 @@ void SettingsWidget::onResetAction()
void SettingsWidget::onSaveOptionsClicked()
{
+ // Save settings that are stored inside the wallet only
+ if (!settingsWalletOptionsWidget->saveWalletOnlyOptions()) {
+ return;
+ }
+
if (mapper->submit()) {
OptionsModel* optionsModel = this->clientModel->getOptionsModel();
- if (optionsModel->isSSTChanged() && !optionsModel->isSSTValid()) {
- const double stakeSplitMinimum = optionsModel->getSSTMinimum();
- settingsWalletOptionsWidget->setSpinBoxStakeSplitThreshold(stakeSplitMinimum);
- inform(tr("Stake Split too low, it shall be either >= %1 or equal to 0 (to disable stake splitting)").arg(stakeSplitMinimum));
- return;
- }
- pwalletMain->MarkDirty();
if (optionsModel->isRestartRequired()) {
bool fAcceptRestart = openStandardDialog(tr("Restart required"), tr("Your wallet needs to be restarted to apply the changes\n"), tr("Restart Now"), tr("Restart Later"));
@@ -312,12 +299,6 @@ void SettingsWidget::onBipToolClicked()
selectOption(ui->pushButtonConfiguration3);
}
-void SettingsWidget::onMultisendClicked()
-{
- ui->stackedWidgetContainer->setCurrentWidget(settingsMultisendWidget);
- selectOption(ui->pushButtonFile3);
-}
-
void SettingsWidget::onExportCSVClicked()
{
ui->stackedWidgetContainer->setCurrentWidget(settingsExportCsvWidget);
@@ -422,6 +403,7 @@ void SettingsWidget::onDiscardChanges()
return;
clientModel->getOptionsModel()->refreshDataView();
}
+ settingsWalletOptionsWidget->discardWalletOnlyOptions();
}
void SettingsWidget::setMapper()
diff --git a/src/qt/pivx/settings/settingswidget.h b/src/qt/pivx/settings/settingswidget.h
index 621e30525dcf..6bb90ea372eb 100644
--- a/src/qt/pivx/settings/settingswidget.h
+++ b/src/qt/pivx/settings/settingswidget.h
@@ -15,7 +15,6 @@
#include "qt/pivx/settings/settingswalletoptionswidget.h"
#include "qt/pivx/settings/settingsmainoptionswidget.h"
#include "qt/pivx/settings/settingsdisplayoptionswidget.h"
-#include "qt/pivx/settings/settingsmultisendwidget.h"
#include "qt/pivx/settings/settingsinformationwidget.h"
#include "qt/pivx/settings/settingsconsolewidget.h"
@@ -57,7 +56,6 @@ private Q_SLOTS:
// Wallet Configuration
void onConfigurationClicked();
void onBipToolClicked();
- void onMultisendClicked();
void onExportCSVClicked();
// Options
@@ -92,7 +90,6 @@ private Q_SLOTS:
SettingsWalletOptionsWidget *settingsWalletOptionsWidget{nullptr};
SettingsMainOptionsWidget *settingsMainOptionsWidget{nullptr};
SettingsDisplayOptionsWidget *settingsDisplayOptionsWidget{nullptr};
- SettingsMultisendWidget *settingsMultisendWidget{nullptr};
SettingsInformationWidget *settingsInformationWidget{nullptr};
SettingsConsoleWidget *settingsConsoleWidget{nullptr};
diff --git a/src/qt/pivx/splash.cpp b/src/qt/pivx/splash.cpp
index eca2c3bc8c18..149f72ff4fee 100644
--- a/src/qt/pivx/splash.cpp
+++ b/src/qt/pivx/splash.cpp
@@ -97,10 +97,8 @@ void Splash::unsubscribeFromCoreSignals(){
m_handler_init_message->disconnect();
m_handler_show_progress->disconnect();
#ifdef ENABLE_WALLET
- if (pwalletMain) {
- m_handler_load_wallet->disconnect();
- if (m_handler_show_progress_wallet) m_handler_show_progress_wallet->disconnect();
- }
+ m_handler_load_wallet->disconnect();
+ if (m_handler_show_progress_wallet) m_handler_show_progress_wallet->disconnect();
#endif
}
diff --git a/src/qt/pivx/topbar.h b/src/qt/pivx/topbar.h
index 677683c945b3..065a77aaaa44 100644
--- a/src/qt/pivx/topbar.h
+++ b/src/qt/pivx/topbar.h
@@ -6,6 +6,7 @@
#define TOPBAR_H
#include
+#include "qt/askpassphrasedialog.h"
#include "qt/pivx/pwidget.h"
#include "qt/pivx/lockunlock.h"
#include "amount.h"
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 636c74fb7958..1ec5e9093a7a 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -6,26 +6,21 @@
#include "walletmodel.h"
-#include "addresstablemodel.h"
-#include "qt/clientmodel.h"
-#include "guiconstants.h"
-#include "optionsmodel.h"
-#include "recentrequeststablemodel.h"
-#include "transactiontablemodel.h"
-#include "init.h" // for ShutdownRequested(). Future: move to an interface wrapper
-
-#include "base58.h"
-#include "coincontrol.h"
-#include "db.h"
-#include "keystore.h"
+#include "init.h" // for ShutdownRequested()
#include "interfaces/handler.h"
#include "sapling/key_io_sapling.h"
#include "sapling/sapling_operation.h"
+#include "sapling/transaction_builder.h"
#include "spork.h"
-#include "sync.h"
-#include "guiinterface.h"
-#include "wallet/wallet.h"
-#include "wallet/walletdb.h" // for BackupWallet
+
+#include "qt/addresstablemodel.h"
+#include "qt/clientmodel.h"
+#include "qt/guiconstants.h"
+#include "qt/optionsmodel.h"
+#include "qt/recentrequeststablemodel.h"
+#include "qt/transactiontablemodel.h"
+#include "qt/walletmodeltransaction.h"
+
#include
#include
@@ -50,7 +45,6 @@ WalletModel::WalletModel(CWallet* wallet, OptionsModel* optionsModel, QObject* p
pollTimer = new QTimer(this);
connect(pollTimer, &QTimer::timeout, this, &WalletModel::pollBalanceChanged);
pollTimer->start(MODEL_UPDATE_DELAY * 5);
-
subscribeToCoreSignals();
}
@@ -59,6 +53,13 @@ WalletModel::~WalletModel()
unsubscribeFromCoreSignals();
}
+void WalletModel::resetWalletOptions(QSettings& settings)
+{
+ setWalletStakeSplitThreshold(CWallet::DEFAULT_STAKE_SPLIT_THRESHOLD);
+ setWalletCustomFee(false, DEFAULT_TRANSACTION_FEE);
+ optionsModel->setWalletDefaultOptions(settings, false);
+}
+
bool WalletModel::isTestNetwork() const
{
return Params().IsTestnet();
@@ -170,6 +171,11 @@ bool WalletModel::isColdStaking() const
return false;
}
+void WalletModel::getAvailableP2CSCoins(std::vector& vCoins) const
+{
+ return wallet->GetAvailableP2CSCoins(vCoins);
+}
+
void WalletModel::updateStatus()
{
if (!wallet) return;
@@ -200,35 +206,35 @@ static bool IsImportingOrReindexing()
std::atomic processingBalance{false};
-static bool processBalanceChangeInternal(WalletModel* walletModel)
+bool WalletModel::processBalanceChangeInternal()
{
- int chainHeight = walletModel->getLastBlockProcessedNum();
- const uint256& blockHash = walletModel->getLastBlockProcessed();
+ int chainHeight = getLastBlockProcessedNum();
+ const uint256& blockHash = getLastBlockProcessed();
- if (walletModel->hasForceCheckBalance() || chainHeight != walletModel->getCacheNumBLocks()) {
+ if (hasForceCheckBalance() || chainHeight != getCacheNumBLocks()) {
// Try to get lock only if needed
- TRY_LOCK(pwalletMain->cs_wallet, lockWallet);
+ TRY_LOCK(wallet->cs_wallet, lockWallet);
if (!lockWallet)
return false;
- walletModel->setfForceCheckBalanceChanged(false);
+ setfForceCheckBalanceChanged(false);
// Balance and number of transactions might have changed
- walletModel->setCacheNumBlocks(chainHeight);
- walletModel->setCacheBlockHash(blockHash);
- walletModel->checkBalanceChanged(walletModel->getBalances());
- QMetaObject::invokeMethod(walletModel, "updateTxModelData", Qt::QueuedConnection);
- QMetaObject::invokeMethod(walletModel, "pollFinished", Qt::QueuedConnection);
+ setCacheNumBlocks(chainHeight);
+ setCacheBlockHash(blockHash);
+ checkBalanceChanged(getBalances());
+ QMetaObject::invokeMethod(this, "updateTxModelData", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, "pollFinished", Qt::QueuedConnection);
// Address in receive tab may have been used
- Q_EMIT walletModel->notifyReceiveAddressChanged();
+ Q_EMIT notifyReceiveAddressChanged();
}
return true;
}
static void processBalanceChange(WalletModel* walletModel)
{
- if (!processBalanceChangeInternal(walletModel)) {
+ if (!walletModel || !walletModel->processBalanceChangeInternal()) {
processingBalance = false;
}
}
@@ -271,7 +277,7 @@ void WalletModel::updateTxModelData()
void WalletModel::emitBalanceChanged()
{
// Force update of UI elements even when no values have changed
- Q_EMIT balanceChanged(walletWrapper.getBalances());
+ Q_EMIT balanceChanged(getBalances());
}
void WalletModel::checkBalanceChanged(const interfaces::WalletBalances& newBalance)
@@ -307,26 +313,47 @@ void WalletModel::setWalletDefaultFee(CAmount fee)
bool WalletModel::hasWalletCustomFee()
{
- if (!optionsModel) return false;
- return optionsModel->data(optionsModel->index(OptionsModel::fUseCustomFee), Qt::EditRole).toBool();
+ LOCK(wallet->cs_wallet);
+ return wallet->fUseCustomFee;
}
bool WalletModel::getWalletCustomFee(CAmount& nFeeRet)
{
- nFeeRet = static_cast(optionsModel->data(optionsModel->index(OptionsModel::nCustomFee), Qt::EditRole).toLongLong());
- return hasWalletCustomFee();
+ LOCK(wallet->cs_wallet);
+ nFeeRet = wallet->nCustomFee;
+ return wallet->fUseCustomFee;
}
-void WalletModel::setWalletCustomFee(bool fUseCustomFee, const CAmount& nFee)
+void WalletModel::setWalletCustomFee(bool fUseCustomFee, const CAmount nFee)
{
- if (!optionsModel) return;
- optionsModel->setData(optionsModel->index(OptionsModel::fUseCustomFee), fUseCustomFee);
- // do not update custom fee value when fUseCustomFee is set to false
- if (fUseCustomFee) {
- optionsModel->setData(optionsModel->index(OptionsModel::nCustomFee), static_cast(nFee));
+ LOCK(wallet->cs_wallet);
+ CWalletDB db(wallet->GetDBHandle());
+ if (wallet->fUseCustomFee != fUseCustomFee) {
+ wallet->fUseCustomFee = fUseCustomFee;
+ db.WriteUseCustomFee(fUseCustomFee);
+ }
+ if (wallet->nCustomFee != nFee) {
+ wallet->nCustomFee = nFee;
+ db.WriteCustomFeeValue(nFee);
}
}
+void WalletModel::setWalletStakeSplitThreshold(const CAmount nStakeSplitThreshold)
+{
+ wallet->SetStakeSplitThreshold(nStakeSplitThreshold);
+}
+
+CAmount WalletModel::getWalletStakeSplitThreshold() const
+{
+ return wallet->GetStakeSplitThreshold();
+}
+
+/* returns default minimum value for stake split threshold as doulbe */
+double WalletModel::getSSTMinimum() const
+{
+ return static_cast(CWallet::minStakeSplitThreshold) / COIN;
+}
+
void WalletModel::updateTransaction()
{
// Balance and number of transactions might have changed
@@ -377,7 +404,7 @@ bool WalletModel::validateAddress(const QString& address, bool fStaking, bool& i
bool WalletModel::updateAddressBookLabels(const CWDestination& dest, const std::string& strName, const std::string& strPurpose)
{
- auto optAdd = pwalletMain->GetAddressBookEntry(dest);
+ auto optAdd = wallet->GetAddressBookEntry(dest);
// Check if we have a new address or an updated label
if (!optAdd) {
return wallet->SetAddressBook(dest, strName, strPurpose);
@@ -387,6 +414,24 @@ bool WalletModel::updateAddressBookLabels(const CWDestination& dest, const std::
return false;
}
+bool WalletModel::addKeys(const CKey& key, const CPubKey& pubkey, WalletRescanReserver& reserver)
+{
+ {
+ LOCK(wallet->cs_wallet);
+ wallet->mapKeyMetadata[pubkey.GetID()].nCreateTime = 1;
+
+ if (!wallet->AddKeyPubKey(key, pubkey)) {
+ return false;
+ }
+
+ // whenever a key is imported, we need to scan the whole chain
+ wallet->nTimeFirstKey = 1; // 0 would be considered 'no value'
+ }
+ CBlockIndex* pindexGenesis = WITH_LOCK(cs_main, return chainActive.Genesis(); );
+ wallet->ScanForWalletTransactions(pindexGenesis, nullptr, reserver, true);
+ return true;
+}
+
WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction* transaction, const CCoinControl* coinControl, bool fIncludeDelegations)
{
CAmount total = 0;
@@ -729,7 +774,7 @@ bool WalletModel::backupWallet(const QString& filename)
// Handlers for core signals
-static void NotifyKeyStoreStatusChanged(WalletModel* walletmodel, CCryptoKeyStore* wallet)
+static void NotifyKeyStoreStatusChanged(WalletModel* walletmodel)
{
qDebug() << "NotifyKeyStoreStatusChanged";
QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
@@ -737,7 +782,7 @@ static void NotifyKeyStoreStatusChanged(WalletModel* walletmodel, CCryptoKeyStor
static void NotifyAddressBookChanged(WalletModel* walletmodel, CWallet* wallet, const CWDestination& address, const std::string& label, bool isMine, const std::string& purpose, ChangeType status)
{
- QString strAddress = QString::fromStdString(pwalletMain->ParseIntoAddress(address, purpose));
+ QString strAddress = QString::fromStdString(wallet->ParseIntoAddress(address, purpose));
QString strLabel = QString::fromStdString(label);
QString strPurpose = QString::fromStdString(purpose);
@@ -782,6 +827,12 @@ static void NotifyWatchonlyChanged(WalletModel* walletmodel, bool fHaveWatchonly
Q_ARG(bool, fHaveWatchonly));
}
+static void NotifySSTChanged(WalletModel* walletmodel, const CAmount stakeSplitThreshold)
+{
+ const double val = static_cast(stakeSplitThreshold) / COIN;
+ Q_EMIT walletmodel->notifySSTChanged(val);
+}
+
static void NotifyWalletBacked(WalletModel* model, const bool& fSuccess, const std::string& filename)
{
std::string message;
@@ -809,8 +860,9 @@ static void NotifyWalletBacked(WalletModel* model, const bool& fSuccess, const s
void WalletModel::subscribeToCoreSignals()
{
// Connect signals to wallet
- m_handler_notify_status_changed = interfaces::MakeHandler(wallet->NotifyStatusChanged.connect(std::bind(&NotifyKeyStoreStatusChanged, this, std::placeholders::_1)));
+ m_handler_notify_status_changed = interfaces::MakeHandler(wallet->NotifyStatusChanged.connect(std::bind(&NotifyKeyStoreStatusChanged, this)));
m_handler_notify_addressbook_changed = interfaces::MakeHandler(wallet->NotifyAddressBookChanged.connect(std::bind(NotifyAddressBookChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)));
+ m_handler_notify_sst_changed = interfaces::MakeHandler(wallet->NotifySSTChanged.connect(std::bind(NotifySSTChanged, this, std::placeholders::_1)));
m_handler_notify_transaction_changed = interfaces::MakeHandler(wallet->NotifyTransactionChanged.connect(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
m_handler_show_progress = interfaces::MakeHandler(wallet->ShowProgress.connect(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2)));
m_handler_notify_watch_only_changed = interfaces::MakeHandler(wallet->NotifyWatchonlyChanged.connect(std::bind(NotifyWatchonlyChanged, this, std::placeholders::_1)));
@@ -822,6 +874,7 @@ void WalletModel::unsubscribeFromCoreSignals()
// Disconnect signals from wallet
m_handler_notify_status_changed->disconnect();
m_handler_notify_addressbook_changed->disconnect();
+ m_handler_notify_sst_changed->disconnect();
m_handler_notify_transaction_changed->disconnect();
m_handler_show_progress->disconnect();
m_handler_notify_watch_only_changed->disconnect();
@@ -878,26 +931,26 @@ int64_t WalletModel::getCreationTime() const {
int64_t WalletModel::getKeyCreationTime(const CPubKey& key)
{
- return pwalletMain->GetKeyCreationTime(key);
+ return wallet->GetKeyCreationTime(key);
}
int64_t WalletModel::getKeyCreationTime(const CTxDestination& address)
{
if (this->isMine(address)) {
- return pwalletMain->GetKeyCreationTime(address);
+ return wallet->GetKeyCreationTime(address);
}
return 0;
}
int64_t WalletModel::getKeyCreationTime(const std::string& address)
{
- return pwalletMain->GetKeyCreationTime(Standard::DecodeDestination(address));
+ return wallet->GetKeyCreationTime(Standard::DecodeDestination(address));
}
int64_t WalletModel::getKeyCreationTime(const libzcash::SaplingPaymentAddress& address)
{
if (this->isMine(address)) {
- return pwalletMain->GetKeyCreationTime(address);
+ return wallet->GetKeyCreationTime(address);
}
return 0;
}
@@ -944,7 +997,7 @@ bool WalletModel::updateAddressBookPurpose(const QString &addressStr, const std:
CKeyID keyID;
if (!getKeyId(address, keyID))
return false;
- return pwalletMain->SetAddressBook(keyID, getLabelForAddress(address), purpose);
+ return wallet->SetAddressBook(keyID, getLabelForAddress(address), purpose);
}
bool WalletModel::getKeyId(const CTxDestination& address, CKeyID& keyID)
@@ -967,6 +1020,17 @@ std::string WalletModel::getLabelForAddress(const CTxDestination& address)
return label;
}
+QString WalletModel::getSaplingAddressString(const CWalletTx* wtx, const SaplingOutPoint& op) const
+{
+ Optional opAddr =
+ wallet->GetSaplingScriptPubKeyMan()->GetOutPointAddress(*wtx, op);
+ if (!opAddr) {
+ return QString();
+ }
+ QString ret = QString::fromStdString(Standard::EncodeDestination(*opAddr));
+ return ret.left(18) + "..." + ret.right(18);
+}
+
// returns a COutPoint of 10000 PIV if found
bool WalletModel::getMNCollateralCandidate(COutPoint& outPoint)
{
@@ -985,6 +1049,17 @@ bool WalletModel::getMNCollateralCandidate(COutPoint& outPoint)
return false;
}
+// Depth of a wallet transaction or -1 if not found
+int WalletModel::getWalletTxDepth(const uint256& txHash) const
+{
+ const CWalletTx *walletTx = wallet->GetWalletTx(txHash);
+ if (!walletTx) {
+ return -1;
+ }
+ LOCK(wallet->cs_wallet);
+ return walletTx->GetDepthInMainChain();
+}
+
bool WalletModel::isSpent(const COutPoint& outpoint) const
{
LOCK(wallet->cs_wallet);
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index 08f20d95fd72..f08946b3bf21 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -7,22 +7,19 @@
#ifndef PIVX_QT_WALLETMODEL_H
#define PIVX_QT_WALLETMODEL_H
-#include "askpassphrasedialog.h"
-#include "paymentrequestplus.h"
-#include "walletmodeltransaction.h"
-
#include "interfaces/wallet.h"
#include "operationresult.h"
#include "support/allocators/zeroafterfree.h"
-#include "wallet/wallet.h"
#include "pairresult.h"
+#include "qt/paymentrequestplus.h"
#include