2020-10-07 10:36:04 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-12-26 19:56:06 +00:00
|
|
|
// Copyright (c) 2020-2021, The Monero Project.
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
#include "ui_seeddialog.h"
|
|
|
|
#include "seeddialog.h"
|
|
|
|
|
2020-11-11 22:09:35 +00:00
|
|
|
SeedDialog::SeedDialog(Wallet *wallet, QWidget *parent)
|
2020-10-07 10:36:04 +00:00
|
|
|
: QDialog(parent)
|
|
|
|
, ui(new Ui::SeedDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->label_seedIcon->setPixmap(QPixmap(":/assets/images/seed.png").scaledToWidth(64, Qt::SmoothTransformation));
|
2020-11-11 22:09:35 +00:00
|
|
|
|
2020-11-25 11:34:14 +00:00
|
|
|
ui->label_restoreHeight->setText(QString::number(wallet->getWalletCreationHeight()));
|
|
|
|
|
2020-11-11 22:09:35 +00:00
|
|
|
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);
|
2020-12-12 16:19:37 +00:00
|
|
|
ui->frameRestoreHeight->setVisible(false);
|
2020-11-11 22:09:35 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 11:34:14 +00:00
|
|
|
connect(ui->check_toggleSeedType, &QCheckBox::toggled, [this, seed_25_words, seed_14_words](bool toggled){
|
|
|
|
this->setSeed(toggled ? seed_25_words : seed_14_words);
|
2020-12-12 16:19:37 +00:00
|
|
|
ui->frameRestoreHeight->setVisible(toggled);
|
2020-11-25 11:34:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
ui->label_restoreHeightHelp->setHelpText("Should you restore your wallet in the future, "
|
|
|
|
"specifying this block number will recover your wallet quicker.");
|
|
|
|
|
2020-11-11 22:09:35 +00:00
|
|
|
this->adjustSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeedDialog::setSeed(const QString &seed) {
|
2020-10-07 10:36:04 +00:00
|
|
|
ui->seed->setPlainText(seed);
|
|
|
|
|
|
|
|
int words = seed.split(" ").size();
|
|
|
|
ui->label_warning->setText(QString("<p>Please save these %1 words on paper (order is important). "
|
2020-11-11 22:09:35 +00:00
|
|
|
"This seed will allow you to recover your wallet in case "
|
|
|
|
"of computer failure."
|
|
|
|
"</p>"
|
|
|
|
"<b>WARNING:</b>"
|
|
|
|
"<ul>"
|
|
|
|
"<li>Never disclose your seed.</li>"
|
|
|
|
"<li>Never type it on a website</li>"
|
|
|
|
"<li>Do not store it electronically</li>"
|
|
|
|
"</ul>").arg(words));
|
2020-10-07 10:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SeedDialog::~SeedDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|