Skip to content

Commit 34b0531

Browse files
committed
GUI-only: Double confirmation dialog for dumpwallet command.
1 parent 0adce3c commit 34b0531

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/qt/pivx/settings/settingsconsolewidget.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ void SettingsConsoleWidget::clear(bool clearHistory)
423423
QString clsKey = "Ctrl-L";
424424
#endif
425425

426-
message(CMD_REPLY, (tr("Welcome to the PIVX RPC console.") + "<br>" +
426+
messageInternal(CMD_REPLY, (tr("Welcome to the PIVX RPC console.") + "<br>" +
427427
tr("Use up and down arrows to navigate history, and %1 to clear screen.").arg("<b>"+clsKey+"</b>") + "<br>" +
428428
tr("Type <b>help</b> for an overview of available commands.") +
429429
"<br><span class=\"secwarning\"><br>" +
@@ -432,7 +432,7 @@ void SettingsConsoleWidget::clear(bool clearHistory)
432432
true);
433433
}
434434

435-
void SettingsConsoleWidget::message(int category, const QString& message, bool html)
435+
void SettingsConsoleWidget::messageInternal(int category, const QString& message, bool html)
436436
{
437437
QTime time = QTime::currentTime();
438438
QString timeString = time.toString();
@@ -454,7 +454,13 @@ void SettingsConsoleWidget::on_lineEdit_returnPressed()
454454
ui->lineEdit->clear();
455455

456456
if (!cmd.isEmpty()) {
457-
message(CMD_REQUEST, cmd);
457+
458+
if ((cmd == "dumpwallet" || cmd == "dumpprivkey") &&
459+
!ask("DANGER!", "Your coins will be STOLEN if you give\nthe info to anyone!\n\nAre you sure?\n")) {
460+
return;
461+
}
462+
463+
messageInternal(CMD_REQUEST, cmd);
458464
Q_EMIT cmdCommandRequest(cmd);
459465
// Remove command, if already in history
460466
history.removeOne(cmd);
@@ -491,7 +497,7 @@ void SettingsConsoleWidget::startExecutor()
491497
executor->moveToThread(thread);
492498

493499
// Replies from executor object must go to this object
494-
connect(executor, &RPCExecutor::reply, this, static_cast<void (SettingsConsoleWidget::*)(int, const QString&)>(&SettingsConsoleWidget::message));
500+
connect(executor, &RPCExecutor::reply, this, &SettingsConsoleWidget::response);
495501
// Requests from this object must go to executor
496502
connect(this, &SettingsConsoleWidget::cmdCommandRequest, executor, &RPCExecutor::requestCommand);
497503

src/qt/pivx/settings/settingsconsolewidget.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class SettingsConsoleWidget : public PWidget
4444

4545
public Q_SLOTS:
4646
void clear(bool clearHistory = true);
47-
void message(int category, const QString &msg) { message(category, msg, false); }
48-
void message(int category, const QString &message, bool html);
47+
void response(int category, const QString &message) { messageInternal(category, message); };
48+
void messageInternal(int category, const QString &message, bool html = false);
4949
/** Go forward or back in history */
5050
void browseHistory(int offset);
5151
/** Scroll console view to end */

src/qt/pivx/settings/settingswidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ SettingsWidget::SettingsWidget(PIVXGUI* parent) :
165165
connect(settingsWalletOptionsWidget, &SettingsWalletOptionsWidget::saveSettings, this, &SettingsWidget::onSaveOptionsClicked);
166166
connect(settingsWalletOptionsWidget, &SettingsWalletOptionsWidget::discardSettings, this, &SettingsWidget::onDiscardChanges);
167167

168+
connect(settingsConsoleWidget, &SettingsConsoleWidget::message,this, &SettingsWidget::message);
169+
168170
/* Widget-to-option mapper */
169171
mapper = new QDataWidgetMapper(this);
170172
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);

0 commit comments

Comments
 (0)