From c6264ed3a0ae32389bc61c402e6d43864aee2926 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Fri, 25 Feb 2022 16:29:33 +0100 Subject: [PATCH] Seed: refactor --- src/WindowManager.cpp | 6 +- src/WindowManager.h | 2 +- src/appcontext.h | 2 +- src/utils/FeatherSeed.h | 117 --- src/utils/RestoreHeightLookup.h | 51 +- src/utils/Seed.cpp | 106 +++ src/utils/Seed.h | 62 ++ src/wizard/PageWalletRestoreSeed.cpp | 9 +- src/wizard/PageWalletSeed.cpp | 19 +- src/wizard/PageWalletSeed.h | 2 + src/wizard/PageWalletSeed.ui | 1098 ++++++++++++++------------ src/wizard/WalletWizard.cpp | 8 +- src/wizard/WalletWizard.h | 4 +- 13 files changed, 830 insertions(+), 656 deletions(-) delete mode 100644 src/utils/FeatherSeed.h create mode 100644 src/utils/Seed.cpp create mode 100644 src/utils/Seed.h diff --git a/src/WindowManager.cpp b/src/WindowManager.cpp index ef406c80..05a6d509 100644 --- a/src/WindowManager.cpp +++ b/src/WindowManager.cpp @@ -204,7 +204,7 @@ bool WindowManager::autoOpenWallet() { // ######################## WALLET CREATION ######################## -void WindowManager::tryCreateWallet(FeatherSeed seed, const QString &path, const QString &password, const QString &seedLanguage, +void WindowManager::tryCreateWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset) { if(Utils::fileExists(path)) { auto err = QString("Failed to write wallet to path: \"%1\"; file already exists.").arg(path); @@ -218,12 +218,12 @@ void WindowManager::tryCreateWallet(FeatherSeed seed, const QString &path, const } Wallet *wallet = nullptr; - if (seed.seedType == SeedType::TEVADOR) { + if (seed.type == Seed::Type::TEVADOR) { wallet = m_walletManager->createDeterministicWalletFromSpendKey(path, password, seed.language, constants::networkType, seed.spendKey, seed.restoreHeight, constants::kdfRounds, seedOffset); wallet->setCacheAttribute("feather.seed", seed.mnemonic.join(" ")); wallet->setCacheAttribute("feather.seedoffset", seedOffset); } - if (seed.seedType == SeedType::MONERO) { + if (seed.type == Seed::Type::MONERO) { wallet = m_walletManager->recoveryWallet(path, password, seed.mnemonic.join(" "), seedOffset, constants::networkType, seed.restoreHeight, constants::kdfRounds); } diff --git a/src/WindowManager.h b/src/WindowManager.h index 6b555aeb..f8355679 100644 --- a/src/WindowManager.h +++ b/src/WindowManager.h @@ -45,7 +45,7 @@ private slots: void onWalletPassphraseNeeded(bool on_device); private: - void tryCreateWallet(FeatherSeed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset); + void tryCreateWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset); void tryCreateWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight); void tryCreateWalletFromKeys(const QString &path, const QString &password, const QString &address, const QString &viewkey, const QString &spendkey, quint64 restoreHeight); diff --git a/src/appcontext.h b/src/appcontext.h index c3eb1800..9fb7a101 100644 --- a/src/appcontext.h +++ b/src/appcontext.h @@ -9,7 +9,7 @@ #include "utils/os/whonix.h" #include "utils/networking.h" -#include "utils/FeatherSeed.h" +#include "utils/Seed.h" #include "utils/daemonrpc.h" #include "utils/RestoreHeightLookup.h" #include "utils/nodes.h" diff --git a/src/utils/FeatherSeed.h b/src/utils/FeatherSeed.h deleted file mode 100644 index e8bb9d17..00000000 --- a/src/utils/FeatherSeed.h +++ /dev/null @@ -1,117 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project - -#ifndef FEATHER_FEATHERSEED_H -#define FEATHER_FEATHERSEED_H - -#include "libwalletqt/WalletManager.h" -#include "libwalletqt/Wallet.h" -#include "utils/AppData.h" - -#include -#include "RestoreHeightLookup.h" - -enum SeedType { - MONERO = 0, // 25 word seeds - TEVADOR // 14 word seeds -}; - -struct FeatherSeed { - // TODO: this is spaghetti, needs refactor - - NetworkType::Type netType; - - QString coin; - QString language; - SeedType seedType; - - QStringList mnemonic; - QString spendKey; - QString correction; - - time_t time; - int restoreHeight = 0; - - QString errorString; - - explicit FeatherSeed(NetworkType::Type networkType = NetworkType::MAINNET, - const QString &coin = "monero", - const QString &language = "English", - const QStringList &mnemonic = {}) - : netType(networkType), coin(coin), language(language), mnemonic(mnemonic) - { - // Generate a new mnemonic if none was given - if (mnemonic.length() == 0) { - this->time = std::time(nullptr); - monero_seed seed(this->time, coin.toStdString()); - - std::stringstream buffer; - buffer << seed; - this->mnemonic = QString::fromStdString(buffer.str()).split(" "); - - buffer.str(std::string()); - buffer << seed.key(); - this->spendKey = QString::fromStdString(buffer.str()); - - this->setRestoreHeight(); - } - - if (mnemonic.length() == 25) { - this->seedType = SeedType::MONERO; - } - else if (mnemonic.length() == 14) { - this->seedType = SeedType::TEVADOR; - } else { - this->errorString = "Mnemonic seed does not match known type"; - return; - } - - if (seedType == SeedType::TEVADOR) { - try { - monero_seed seed(mnemonic.join(" ").toStdString(), coin.toStdString()); - - this->time = seed.date(); - this->setRestoreHeight(); - - std::stringstream buffer; - buffer << seed.key(); - this->spendKey = QString::fromStdString(buffer.str()); - - this->correction = QString::fromStdString(seed.correction()); - if (!this->correction.isEmpty()) { - buffer.str(std::string()); - buffer << seed; - int index = this->mnemonic.indexOf("xxxx"); - this->mnemonic.replace(index, this->correction); - } - } - catch (const std::exception &e) { - this->errorString = e.what(); - return; - } - } - } - - void setRestoreHeight() { - if (this->time == 0) - this->restoreHeight = 1; - - this->restoreHeight = appData()->restoreHeights[netType]->dateToHeight(this->time); - } - - int setRestoreHeight(int height) { - auto now = std::time(nullptr); - auto nowClearance = 3600 * 24; - auto currentBlockHeight = appData()->restoreHeights[netType]->dateToHeight(now - nowClearance); - if (height >= currentBlockHeight + nowClearance) { - qCritical() << "unrealistic restore height detected, setting to current blockheight instead: " << currentBlockHeight; - this->restoreHeight = currentBlockHeight; - } else { - this->restoreHeight = height; - } - - return this->restoreHeight; - } -}; - -#endif //FEATHER_FEATHERSEED_H diff --git a/src/utils/RestoreHeightLookup.h b/src/utils/RestoreHeightLookup.h index 7695efc8..48f448b8 100644 --- a/src/utils/RestoreHeightLookup.h +++ b/src/utils/RestoreHeightLookup.h @@ -14,10 +14,10 @@ struct RestoreHeightLookup { NetworkType::Type type; - QMap data; + QMap data; explicit RestoreHeightLookup(NetworkType::Type type) : type(type) {} - int dateToHeight(int date) { + int dateToHeight(time_t date) { // restore height based on a given timestamp using a lookup // table. If it cannot find the date in the lookup table, it // will calculate the blockheight based off the last known @@ -28,34 +28,43 @@ struct RestoreHeightLookup { } int blockTime = 120; - int blocksPerDay = 86400 / blockTime; + int blocksPerDay = 720; int blockCalcClearance = blocksPerDay * 5; - QList values = this->data.keys(); - if (date <= values.at(0)) - return this->data[values.at(0)]; + + QList values = this->data.keys(); + + // If timestamp is before epoch, return genesis height. + if (date <= values.at(0)) { + return 1; + } + for (int i = 0; i != values.count(); i++) { - if(values[i] > date) { - return i - 1 < 0 ? this->data[values[i]] : this->data[values[i-1]] - blockCalcClearance; + if (values[i] > date) { + if (i == 0) { + return 1; + } + return this->data[values[i-1]] - blockCalcClearance; } } // lookup failed, calculate blockheight from last known checkpoint - int lastBlockHeightTime = values.at(values.count() - 1); + time_t lastBlockHeightTime = values.last(); int lastBlockHeight = this->data[lastBlockHeightTime]; - int deltaTime = date - lastBlockHeightTime; + + time_t deltaTime = date - lastBlockHeightTime; int deltaBlocks = deltaTime / blockTime; + int blockHeight = (lastBlockHeight + deltaBlocks) - blockCalcClearance; - qDebug() << "Calculated blockheight: " << blockHeight << " from epoch " << date; return blockHeight; } - int heightToTimestamp(int height) { + time_t heightToTimestamp(int height) { // @TODO: most likely inefficient, refactor - QMap::iterator i; - int timestamp = 0; + QMap::iterator i; + time_t timestamp = 0; int heightData = 1; for (i = this->data.begin(); i != this->data.end(); ++i) { - int ts = i.key(); + time_t ts = i.key(); if (i.value() > height) return timestamp; timestamp = ts; @@ -77,12 +86,14 @@ struct RestoreHeightLookup { static RestoreHeightLookup *fromFile(const QString &fn, NetworkType::Type type) { // initialize this class using a lookup table, e.g `:/assets/restore_heights_monero_mainnet.txt`/ auto rtn = new RestoreHeightLookup(type); - auto data = Utils::barrayToString(Utils::fileOpen(fn)); - QMap _data; - for(const auto &line: data.split('\n')) { - if(line.trimmed().isEmpty()) continue; + auto data= Utils::barrayToString(Utils::fileOpen(fn)); + + for (const auto &line: data.split('\n')) { + if (line.trimmed().isEmpty()) { + continue; + } auto spl = line.trimmed().split(':'); - rtn->data[spl.at(0).toInt()] = spl.at(1).toInt(); + rtn->data[(time_t)spl.at(0).toInt()] = spl.at(1).toInt(); } return rtn; } diff --git a/src/utils/Seed.cpp b/src/utils/Seed.cpp new file mode 100644 index 00000000..1e4eb05a --- /dev/null +++ b/src/utils/Seed.cpp @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2020-2022 The Monero Project + +#include "Seed.h" + +Seed::Seed(Type type, NetworkType::Type networkType, QString language) + : type(type), networkType(networkType), language(std::move(language)) +{ + // We only support the creation of Tevador-style seeds for now. + if (this->type != Type::TEVADOR) { + this->errorString = "Unsupported seed type"; + return; + } + + // We only support the creation of English language seeds for now. + if (this->language != "English") { + this->errorString = "Unsupported seed language"; + return; + } + + this->time = std::time(nullptr); + + try { + monero_seed seed(this->time, constants::coinName); + + std::stringstream buffer; + buffer << seed; + this->mnemonic = QString::fromStdString(buffer.str()).split(" "); + + buffer.str(std::string()); + buffer << seed.key(); + this->spendKey = QString::fromStdString(buffer.str()); + } + catch (const std::exception &e) { + this->errorString = QString::fromStdString(e.what()); + return; + } + + // Basic check against seed library implementation issues + if (m_insecureSeeds.contains(this->spendKey)) { + this->errorString = "Insecure spendkey"; + return; + } + + this->setRestoreHeight(); +} + +Seed::Seed(Type type, QStringList mnemonic, NetworkType::Type networkType) + : type(type), mnemonic(std::move(mnemonic)), networkType(networkType) +{ + if (m_seedLength[this->type] != this->mnemonic.length()) { + this->errorString = "Invalid seed length"; + return; + } + + if (this->type == Type::POLYSEED) { + this->errorString = "Unsupported seed type"; + return; + } + + if (this->type == Type::TEVADOR) { + try { + monero_seed seed(this->mnemonic.join(" ").toStdString(), constants::coinName); + + this->time = seed.date(); + this->setRestoreHeight(); + + std::stringstream buffer; + buffer << seed.key(); + this->spendKey = QString::fromStdString(buffer.str()); + + // Tevador style seeds have built-in error correction + // Any word can be replaced with 'xxxx' to recover the original word + this->correction = QString::fromStdString(seed.correction()); + if (!this->correction.isEmpty()) { + buffer.str(std::string()); + buffer << seed; + int index = this->mnemonic.indexOf("xxxx"); + this->mnemonic.replace(index, this->correction); + } + } + catch (const std::exception &e) { + this->errorString = e.what(); + return; + } + } +} + +void Seed::setRestoreHeight(int height) { + auto now = std::time(nullptr); + auto nowClearance = 3600 * 24; + auto currentBlockHeight = appData()->restoreHeights[this->networkType]->dateToHeight(now - nowClearance); + if (height >= currentBlockHeight + nowClearance) { + qWarning() << "unrealistic restore height detected, setting to current blockheight instead: " << currentBlockHeight; + this->restoreHeight = currentBlockHeight; + } else { + this->restoreHeight = height; + } +} + +void Seed::setRestoreHeight() { + // Ignore the embedded restore date, new wallets should sync from the current block height. + this->restoreHeight = appData()->restoreHeights[networkType]->dateToHeight(this->time); +} + +Seed::Seed() = default; \ No newline at end of file diff --git a/src/utils/Seed.h b/src/utils/Seed.h new file mode 100644 index 00000000..5318a66a --- /dev/null +++ b/src/utils/Seed.h @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2020-2022 The Monero Project + +#ifndef FEATHER_SEED_H +#define FEATHER_SEED_H + +#include "constants.h" +#include "libwalletqt/Wallet.h" +#include "monero_seed/monero_seed.hpp" +#include "utils/AppData.h" + +#include +#include + +#include +#include + +struct Seed { + enum Type { + MONERO = 0, // 25 word seeds + TEVADOR, // 14 word seeds + POLYSEED, // 16 word seeds + }; + + NetworkType::Type networkType = NetworkType::MAINNET; + + QString coin; + QString language; + Type type = Type::TEVADOR; + + QStringList mnemonic; + QString spendKey; + QString correction; + + time_t time{}; + int restoreHeight = 0; + + QString errorString; + + explicit Seed(); + explicit Seed(Type type, NetworkType::Type networkType = NetworkType::MAINNET, QString language = "English"); + explicit Seed(Type type, QStringList mnemonic, NetworkType::Type networkType = NetworkType::MAINNET); + void setRestoreHeight(int height); + +private: + void setRestoreHeight(); + + QStringList m_insecureSeeds = { + "0000000000000000000000000000000000000000000000000000000000000000", + "1111111111111111111111111111111111111111111111111111111111111111", + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + }; + + QMap m_seedLength { + {Type::MONERO, 25}, + {Type::TEVADOR, 14}, + {Type::POLYSEED, 16} + }; +}; + + +#endif //FEATHER_SEED_H diff --git a/src/wizard/PageWalletRestoreSeed.cpp b/src/wizard/PageWalletRestoreSeed.cpp index fa89a257..3c8eaa29 100644 --- a/src/wizard/PageWalletRestoreSeed.cpp +++ b/src/wizard/PageWalletRestoreSeed.cpp @@ -9,7 +9,7 @@ #include #include // tevador 14 word -#include "utils/FeatherSeed.h" +#include "utils/Seed.h" #include "constants.h" #include @@ -60,13 +60,13 @@ PageWalletRestoreSeed::PageWalletRestoreSeed(WizardFields *fields, QWidget *pare void PageWalletRestoreSeed::onSeedTypeToggled() { if (ui->radio14->isChecked()) { m_mode = &m_tevador; - m_fields->seedType = SeedType::TEVADOR; + m_fields->seedType = Seed::Type::TEVADOR; ui->seedEdit->setPlaceholderText("Enter 14 word seed.."); ui->group_seedLanguage->hide(); } else if (ui->radio25->isChecked()) { m_mode = &m_legacy; - m_fields->seedType = SeedType::MONERO; + m_fields->seedType = Seed::Type::MONERO; ui->seedEdit->setPlaceholderText("Enter 25 word seed.."); ui->group_seedLanguage->show(); } @@ -128,7 +128,8 @@ bool PageWalletRestoreSeed::validatePage() { } } - auto _seed = FeatherSeed(constants::networkType, QString::fromStdString(constants::coinName), constants::seedLanguage, seedSplit); + Seed _seed = Seed(m_mode->length == 14 ? Seed::Type::TEVADOR : Seed::Type::MONERO, seedSplit, constants::networkType); + if (!_seed.errorString.isEmpty()) { QMessageBox::warning(this, "Invalid seed", QString("Invalid seed:\n\n%1").arg(_seed.errorString)); ui->seedEdit->setStyleSheet(errStyle); diff --git a/src/wizard/PageWalletSeed.cpp b/src/wizard/PageWalletSeed.cpp index 1cd852cf..0008cee5 100644 --- a/src/wizard/PageWalletSeed.cpp +++ b/src/wizard/PageWalletSeed.cpp @@ -5,6 +5,7 @@ #include "PageWalletSeed.h" #include "ui_PageWalletSeed.h" #include "constants.h" +#include "Seed.h" #include @@ -15,6 +16,10 @@ PageWalletSeed::PageWalletSeed(WizardFields *fields, QWidget *parent) { ui->setupUi(this); + ui->frame_invalidSeed->hide(); + QPixmap warningIcon = QPixmap(":/assets/images/warning.png"); + ui->warningIcon->setPixmap(warningIcon.scaledToWidth(32, Qt::SmoothTransformation)); + QPixmap pixmap = QPixmap(":/assets/images/seed.png"); ui->seedIcon->setPixmap(pixmap.scaledToWidth(32, Qt::SmoothTransformation)); @@ -48,13 +53,21 @@ void PageWalletSeed::seedRoulette(int count) { } void PageWalletSeed::generateSeed() { + Seed seed; + do { - FeatherSeed seed = FeatherSeed(constants::networkType, QString::fromStdString(constants::coinName), constants::seedLanguage); + seed = Seed(Seed::Type::TEVADOR); m_mnemonic = seed.mnemonic.join(" "); m_restoreHeight = seed.restoreHeight; } while (m_mnemonic.split(" ").length() != 14); // https://github.com/tevador/monero-seed/issues/2 this->displaySeed(m_mnemonic); + + if (!seed.errorString.isEmpty()) { + ui->frame_invalidSeed->show(); + ui->frame_seedDisplay->hide(); + m_seedError = true; + } } void PageWalletSeed::displaySeed(const QString &seed){ @@ -101,4 +114,8 @@ bool PageWalletSeed::validatePage() { m_fields->seed = m_mnemonic; return true; +} + +bool PageWalletSeed::isComplete() const { + return !m_seedError; } \ No newline at end of file diff --git a/src/wizard/PageWalletSeed.h b/src/wizard/PageWalletSeed.h index 145a4ab4..ffe4fbf0 100644 --- a/src/wizard/PageWalletSeed.h +++ b/src/wizard/PageWalletSeed.h @@ -22,6 +22,7 @@ public: explicit PageWalletSeed(WizardFields *fields, QWidget *parent = nullptr); void initializePage() override; bool validatePage() override; + bool isComplete() const override; int nextId() const override; public slots: @@ -42,6 +43,7 @@ private: QString m_mnemonic; int m_restoreHeight; + bool m_seedError = false; bool m_roulette = false; int m_rouletteSpin = 15; }; diff --git a/src/wizard/PageWalletSeed.ui b/src/wizard/PageWalletSeed.ui index 291f48a3..f962d61f 100644 --- a/src/wizard/PageWalletSeed.ui +++ b/src/wizard/PageWalletSeed.ui @@ -7,7 +7,7 @@ 0 0 877 - 408 + 625 @@ -79,6 +79,72 @@ + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 0 + 0 + + + + icon + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 20 + + + + + + + + + + Feather was unable to generate a valid seed. + + + + + + + This should never happen. + + + + + + + Please contact the developers immediately. + + + + + + + + @@ -96,559 +162,583 @@ - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - - 0 - 0 - - - - 1. - - - - - - - TextLabel - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - - 0 - 0 - - - - 4. - - - - - - - TextLabel - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - - 0 - 0 - - - - 7. - - - - - - - TextLabel - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - - 0 - 0 - - - - 10. - - - - - - - TextLabel - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - - 0 - 0 - - - - 13. - - - - - - - TextLabel - - - - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - - 0 - 0 - - - - 2. - - - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + - - - TextLabel - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 1. + + + + + + + TextLabel + + + + - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - 0 - 0 - - - - 5. - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 4. + + + + + + + TextLabel + + + + - - - TextLabel - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 7. + + + + + + + TextLabel + + + + - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - 0 - 0 - - - - 8. - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 10. + + + + + + + TextLabel + + + + - - - TextLabel - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 13. + + + + + + + TextLabel + + + + - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - - 0 - 0 - - - - 11. - - - + + + - - - TextLabel - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 2. + + + + + + + TextLabel + + + + - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - 0 - 0 - - - - 14. - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 5. + + + + + + + TextLabel + + + + - - - TextLabel - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 8. + + + + + + + TextLabel + + + + - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - 0 - 0 - - - - 3. - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 11. + + + + + + + TextLabel + + + + - - - TextLabel - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 14. + + + + + + + TextLabel + + + + - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - - 0 - 0 - - - - 6. - - - + + + - - - TextLabel - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 3. + + + + + + + TextLabel + + + + - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - 0 - 0 - - - - 9. - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 6. + + + + + + + TextLabel + + + + - - - TextLabel - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 9. + + + + + + + TextLabel + + + + - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 7 - - - 7 - - - - - 0 - 0 - - - - 12. - + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 7 + + + 7 + + + + + + 0 + 0 + + + + 12. + + + + + + + TextLabel + + + + - + - TextLabel + - - - - - - - - - - - - + + + + + diff --git a/src/wizard/WalletWizard.cpp b/src/wizard/WalletWizard.cpp index b696d5fe..cfae8c1c 100644 --- a/src/wizard/WalletWizard.cpp +++ b/src/wizard/WalletWizard.cpp @@ -117,15 +117,17 @@ void WalletWizard::onCreateWallet() { return; } - auto seed = FeatherSeed(constants::networkType, QString::fromStdString(constants::coinName), constants::seedLanguage, m_wizardFields.seed.split(" ")); + auto seed = Seed(m_wizardFields.seedType, m_wizardFields.seed.split(" "), constants::networkType); + // If we're connected to the websocket, use the reported height for new wallets to skip initial synchronization. if (m_wizardFields.mode == WizardMode::CreateWallet && currentBlockHeight > 0) { qInfo() << "New wallet, setting restore height to latest blockheight: " << currentBlockHeight; - seed.setRestoreHeight(currentBlockHeight); + seed.restoreHeight = currentBlockHeight; } - if (m_wizardFields.mode == WizardMode::RestoreFromSeed && m_wizardFields.seedType == SeedType::MONERO) + if (m_wizardFields.mode == WizardMode::RestoreFromSeed && m_wizardFields.seedType == Seed::Type::MONERO) { seed.setRestoreHeight(m_wizardFields.restoreHeight); + } emit createWallet(seed, walletPath, m_wizardFields.password, m_wizardFields.seedLanguage, m_wizardFields.seedOffsetPassphrase); } diff --git a/src/wizard/WalletWizard.h b/src/wizard/WalletWizard.h index 13ab39d2..81c682d1 100644 --- a/src/wizard/WalletWizard.h +++ b/src/wizard/WalletWizard.h @@ -41,7 +41,7 @@ struct WizardFields { QString secretSpendKey; WizardMode mode; int restoreHeight = 0; - SeedType seedType; + Seed::Type seedType; DeviceType deviceType; }; @@ -74,7 +74,7 @@ signals: void createWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight); void createWalletFromKeys(const QString &path, const QString &password, const QString &address, const QString &viewkey, const QString &spendkey, quint64 restoreHeight, bool deterministic = false); - void createWallet(FeatherSeed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset = ""); + void createWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset = ""); private slots: void onCreateWallet(); -- 2.52.0