Skip to content

Commit

Permalink
[Qt] Sanitize restart params when saving settings
Browse files Browse the repository at this point in the history
In the event that the wallet was started with one of the repair options,
remove those options from the restarted session.
  • Loading branch information
Fuzzbawls committed Nov 12, 2019
1 parent b0ed86e commit 22836a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/qt/pivx/qtutils.h
Expand Up @@ -19,6 +19,15 @@
#include <initializer_list>
#include "qt/pivx/pivxgui.h"

// Repair parameters
const QString SALVAGEWALLET("-salvagewallet");
const QString RESCAN("-rescan");
const QString ZAPTXES1("-zapwallettxes=1");
const QString ZAPTXES2("-zapwallettxes=2");
const QString UPGRADEWALLET("-upgradewallet");
const QString REINDEX("-reindex");
const QString RESYNC("-resync");

extern Qt::Modifier SHORT_KEY;

bool openDialog(QDialog *widget, QWidget *gui);
Expand Down
9 changes: 0 additions & 9 deletions src/qt/pivx/settings/settingswalletrepairwidget.cpp
Expand Up @@ -6,15 +6,6 @@
#include "qt/pivx/settings/forms/ui_settingswalletrepairwidget.h"
#include "qt/pivx/qtutils.h"

// Repair parameters
const QString SALVAGEWALLET("-salvagewallet");
const QString RESCAN("-rescan");
const QString ZAPTXES1("-zapwallettxes=1");
const QString ZAPTXES2("-zapwallettxes=2");
const QString UPGRADEWALLET("-upgradewallet");
const QString REINDEX("-reindex");
const QString RESYNC("-resync");

SettingsWalletRepairWidget::SettingsWalletRepairWidget(PIVXGUI* _window, QWidget *parent) :
PWidget(_window, parent),
ui(new Ui::SettingsWalletRepairWidget)
Expand Down
8 changes: 8 additions & 0 deletions src/qt/pivx/settings/settingswidget.cpp
Expand Up @@ -210,6 +210,14 @@ void SettingsWidget::onSaveOptionsClicked(){
QStringList args = QApplication::arguments();
args.removeFirst();

// Remove existing repair-options
args.removeAll(SALVAGEWALLET);
args.removeAll(RESCAN);
args.removeAll(ZAPTXES1);
args.removeAll(ZAPTXES2);
args.removeAll(UPGRADEWALLET);
args.removeAll(REINDEX);

openStandardDialog(tr("Restart required"), tr("You wallet will be restarted to apply the changes\n"), tr("OK"));
emit handleRestart(args);
} else {
Expand Down

0 comments on commit 22836a7

Please sign in to comment.