diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 073cdd7459..9837558ebc 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -163,6 +163,16 @@ + + + + Restore all Sigma transactions following a reindex. + + + &Reindex Sigma + + + diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 7ff00b1e9e..20885ffc5e 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -164,6 +164,7 @@ void OptionsDialog::setModel(OptionsModel *_model) connect(ui->threadsScriptVerif, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning())); /* Wallet */ connect(ui->spendZeroConfChange, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); + connect(ui->reindexSigma, SIGNAL(clicked(bool)), this, SLOT(handleEnabledZapChanged())); /* Network */ connect(ui->allowIncoming, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); @@ -182,6 +183,7 @@ void OptionsDialog::setMapper() /* Wallet */ mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange); + mapper->addMapping(ui->reindexSigma, OptionsModel::ReindexSigma); mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures); /* Network */ @@ -256,6 +258,23 @@ void OptionsDialog::on_hideTrayIcon_stateChanged(int fState) ui->minimizeToTray->setEnabled(true); } } +void OptionsDialog::handleEnabledZapChanged(){ + QMessageBox msgBox; + + if(ui->reindexSigma->isChecked()){ + QMessageBox::StandardButton retval = QMessageBox::warning(this, tr("Confirm Reindex Sigma"), + tr("Warning: On restart, this setting will wipe your transaction list, reindex the blockchain, and restore the list from the seed in your wallet. This will likely take a few hours. Are you sure?"), + QMessageBox::Yes|QMessageBox::Cancel, + QMessageBox::Cancel); + if(retval == QMessageBox::Cancel) { + ui->reindexSigma->setChecked(false); + }else { + showRestartWarning(); + } + }else { + clearStatusLabel(); + } +} void OptionsDialog::showRestartWarning(bool fPersistent) { diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index d98c1dc193..9a3353c0dc 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -53,6 +53,7 @@ private Q_SLOTS: void on_hideTrayIcon_stateChanged(int fState); void showRestartWarning(bool fPersistent = false); + void handleEnabledZapChanged(); void clearStatusLabel(); void updateProxyValidationState(); /* query the networks, for which the default proxy is used */ diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 65810162eb..a08e65ae7e 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -109,6 +109,15 @@ void OptionsModel::Init(bool resetSettings) settings.setValue("bSpendZeroConfChange", true); if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool())) addOverriddenOption("-spendzeroconfchange"); + + if (!settings.contains("bReindexSigma")) + settings.setValue("bReindexSigma", DEFAULT_ZAP_WALLET); + if (!SoftSetBoolArg("-zapwalletmints", settings.value("bReindexSigma").toBool())) { + addOverriddenOption("-zapwalletmints"); + } else { + settings.setValue("bReindexSigma", false); + } + #endif // Network @@ -240,6 +249,9 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const #ifdef ENABLE_WALLET case SpendZeroConfChange: return settings.value("bSpendZeroConfChange"); + + case ReindexSigma: + return settings.value("bReindexSigma"); #endif case DisplayUnit: return nDisplayUnit; @@ -363,6 +375,13 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in setRestartRequired(true); } break; + + case ReindexSigma: + if (settings.value("bReindexSigma") != value) { + settings.setValue("bReindexSigma", value); + setRestartRequired(true); + } + break; #endif case DisplayUnit: setDisplayUnit(value); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 184a3a65f4..4b08139c19 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -45,6 +45,7 @@ class OptionsModel : public QAbstractListModel ThreadsScriptVerif, // int DatabaseCache, // int SpendZeroConfChange, // bool + ReindexSigma, // bool Listen, // bool TorSetup, // bool OptionIDRowCount, diff --git a/src/validation.h b/src/validation.h index 71ab76fd53..3277445f1b 100644 --- a/src/validation.h +++ b/src/validation.h @@ -146,6 +146,7 @@ static const bool DEFAULT_TIMESTAMPINDEX = false; static const bool DEFAULT_ADDRESSINDEX = false; static const bool DEFAULT_SPENTINDEX = false; static const bool DEFAULT_TOR_SETUP = false; +static const bool DEFAULT_ZAP_WALLET = false; static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100; /** Default for -mempoolreplacement */