From 0f3c005b60ade80d09cf643661ea473ae270eee4 Mon Sep 17 00:00:00 2001
From: tobtoht
Date: Wed, 11 Nov 2020 23:09:35 +0100
Subject: [PATCH] SeedDialog: add 25 word seed toggle
---
src/dialog/seeddialog.cpp | 40 +++++++++++++++++++++++++++------------
src/dialog/seeddialog.h | 5 ++++-
src/dialog/seeddialog.ui | 9 ++++++++-
src/mainwindow.cpp | 7 +------
4 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/src/dialog/seeddialog.cpp b/src/dialog/seeddialog.cpp
index bd1a537..b9918d5 100644
--- a/src/dialog/seeddialog.cpp
+++ b/src/dialog/seeddialog.cpp
@@ -4,27 +4,43 @@
#include "ui_seeddialog.h"
#include "seeddialog.h"
-SeedDialog::SeedDialog(const QString &seed, QWidget *parent)
+SeedDialog::SeedDialog(Wallet *wallet, QWidget *parent)
: QDialog(parent)
, ui(new Ui::SeedDialog)
{
ui->setupUi(this);
ui->label_seedIcon->setPixmap(QPixmap(":/assets/images/seed.png").scaledToWidth(64, Qt::SmoothTransformation));
+
+ QString seed_14_words = wallet->getCacheAttribute("feather.seed");
+ QString seed_25_words = wallet->getSeed();
+
+ if (seed_14_words.isEmpty()) {
+ ui->check_toggleSeedType->hide();
+ this->setSeed(seed_25_words);
+ } else {
+ this->setSeed(seed_14_words);
+ connect(ui->check_toggleSeedType, &QCheckBox::toggled, [this, seed_25_words, seed_14_words](bool toggled){
+ this->setSeed(toggled ? seed_25_words : seed_14_words);
+ });
+ }
+
+ this->adjustSize();
+}
+
+void SeedDialog::setSeed(const QString &seed) {
ui->seed->setPlainText(seed);
int words = seed.split(" ").size();
ui->label_warning->setText(QString("Please save these %1 words on paper (order is important). "
- "This seed will allow you to recover your wallet in case "
- "of computer failure."
- "
"
- "WARNING:"
- ""
- "- Never disclose your seed.
"
- "- Never type it on a website
"
- "- Do not store it electronically
"
- "
").arg(words));
-
- this->adjustSize();
+ "This seed will allow you to recover your wallet in case "
+ "of computer failure."
+ "
"
+ "WARNING:"
+ ""
+ "- Never disclose your seed.
"
+ "- Never type it on a website
"
+ "- Do not store it electronically
"
+ "
").arg(words));
}
SeedDialog::~SeedDialog()
diff --git a/src/dialog/seeddialog.h b/src/dialog/seeddialog.h
index a26fee4..71a6c63 100644
--- a/src/dialog/seeddialog.h
+++ b/src/dialog/seeddialog.h
@@ -5,6 +5,7 @@
#define FEATHER_SEEDDIALOG_H
#include
+#include "libwalletqt/Wallet.h"
namespace Ui {
class SeedDialog;
@@ -15,10 +16,12 @@ class SeedDialog : public QDialog
Q_OBJECT
public:
- explicit SeedDialog(const QString& seed, QWidget *parent = nullptr);
+ explicit SeedDialog(Wallet *wallet, QWidget *parent = nullptr);
~SeedDialog() override;
private:
+ void setSeed(const QString &seed);
+
Ui::SeedDialog *ui;
};
diff --git a/src/dialog/seeddialog.ui b/src/dialog/seeddialog.ui
index 1288fac..2167bff 100644
--- a/src/dialog/seeddialog.ui
+++ b/src/dialog/seeddialog.ui
@@ -7,7 +7,7 @@
0
0
542
- 244
+ 259
@@ -57,6 +57,13 @@
+ -
+
+
+ Show 25 word seed
+
+
+
-
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 8ab6dd8..7cfeadb 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -851,12 +851,7 @@ void MainWindow::showWalletInfoDialog() {
}
void MainWindow::showSeedDialog() {
- QString seed = m_ctx->currentWallet->getCacheAttribute("feather.seed");
- if (seed.isEmpty()) {
- seed = m_ctx->currentWallet->getSeed();
- }
-
- auto *dialog = new SeedDialog(seed, this);
+ auto *dialog = new SeedDialog(m_ctx->currentWallet, this);
dialog->exec();
dialog->deleteLater();
}