Skip to content

Commit

Permalink
Add button to zap wallet mints in settings (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
riordant authored Jul 17, 2020
1 parent d49afcf commit d383ed8
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="reindexSigma">
<property name="toolTip">
<string>Restore all Sigma transactions following a reindex.</string>
</property>
<property name="text">
<string>&amp;Reindex Sigma</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
19 changes: 19 additions & 0 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -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 */
Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/qt/optionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
19 changes: 19 additions & 0 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/qt/optionsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class OptionsModel : public QAbstractListModel
ThreadsScriptVerif, // int
DatabaseCache, // int
SpendZeroConfChange, // bool
ReindexSigma, // bool
Listen, // bool
TorSetup, // bool
OptionIDRowCount,
Expand Down
1 change: 1 addition & 0 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit d383ed8

Please sign in to comment.