void MainWindow::showRestoreHeightDialog() {
// settings custom restore height is only available for 25 word seeds
- auto seed = m_ctx->wallet->getCacheAttribute("feather.seed");
- if(!seed.isEmpty()) { // TODO: update this warning (import tx, delete cache, restore from seed)
- const auto msg = "This wallet has a 14 word mnemonic seed which has the restore height embedded.";
+ auto seedLength = m_ctx->wallet->seedLength();
+ if (seedLength == 14 || seedLength == 16) { // TODO: update this warning (import tx, delete cache, restore from seed)
+ const auto msg = "This wallet has a mnemonic seed with an embedded restore height.";
QMessageBox::warning(this, "Cannot set custom restore height", msg);
return;
}
Wallet *wallet = nullptr;
if (seed.type == Seed::Type::POLYSEED || 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);
}
else if (seed.type == Seed::Type::MONERO) {
wallet = m_walletManager->recoveryWallet(path, password, seed.mnemonic.join(" "), seedOffset, constants::networkType, seed.restoreHeight, constants::kdfRounds);
return;
}
+ wallet->setCacheAttribute("feather.seed", seed.mnemonic.join(" "));
+ wallet->setCacheAttribute("feather.seedoffset", seedOffset);
+
this->onWalletOpened(wallet);
}
}
void AppContext::onSetRestoreHeight(quint64 height){
- auto seed = this->wallet->getCacheAttribute("feather.seed");
- if(!seed.isEmpty()) {
- const auto msg = "This wallet has a 14 word mnemonic seed which has the restore height embedded.";
+ auto seedLength = this->wallet->seedLength();
+ if (seedLength == 14 || seedLength == 16) {
+ const auto msg = "This wallet has a mnemonic seed with an embedded restore height.";
emit setRestoreHeightError(msg);
return;
}
QString seedType = [this](){
if (m_ctx->wallet->isHwBacked())
- return "Hardware";
- if (m_ctx->wallet->getCacheAttribute("feather.seed").isEmpty())
- return "25 word";
- else
- return "14 word";
+ return QString("Hardware");
+ return QString("%1 word").arg(m_ctx->wallet->seedLength());
}();
QString deviceType = [this](){
}
QString seedOffset = m_ctx->wallet->getCacheAttribute("feather.seedoffset");
- QString seed_14_words = m_ctx->wallet->getCacheAttribute("feather.seed");
+ QString seed = m_ctx->wallet->getCacheAttribute("feather.seed");
+ auto seedLength = m_ctx->wallet->seedLength();
+
QString seed_25_words = m_ctx->wallet->getSeed(seedOffset);
- if (seed_14_words.isEmpty()) {
+ if (seedLength >= 24) {
ui->check_toggleSeedType->hide();
this->setSeed(seed_25_words);
} else {
- this->setSeed(seed_14_words);
+ this->setSeed(seed);
ui->frameRestoreHeight->setVisible(false);
}
ui->frameSeedOffset->setVisible(!seedOffset.isEmpty());
ui->line_seedOffset->setText(seedOffset);
- connect(ui->check_toggleSeedType, &QCheckBox::toggled, [this, seed_25_words, seed_14_words](bool toggled){
- this->setSeed(toggled ? seed_25_words : seed_14_words);
+ connect(ui->check_toggleSeedType, &QCheckBox::toggled, [this, seed_25_words, seed](bool toggled){
+ this->setSeed(toggled ? seed_25_words : seed);
ui->frameRestoreHeight->setVisible(toggled);
});
ui->label_walletName->setText(QFileInfo(m_ctx->wallet->cachePath()).fileName());
ui->label_netType->setText(Utils::QtEnumToString(m_ctx->wallet->nettype()));
- ui->label_seedType->setText(m_ctx->wallet->getCacheAttribute("feather.seed").isEmpty() ? "25 word" : "14 word");
+ ui->label_seedType->setText(QString("%1 word").arg(m_ctx->wallet->seedLength()));
ui->label_viewOnly->setText(m_ctx->wallet->viewOnly() ? "True" : "False");
ui->label_keysFile->setText(m_ctx->wallet->keysPath());
ui->label_cacheFile->setText(m_ctx->wallet->cachePath());
return QString::fromStdString(m_walletImpl->seed(seedOffset.toStdString()));
}
+qsizetype Wallet::seedLength() const
+{
+ auto seedLength = this->getCacheAttribute("feather.seed").split(" ").length();
+ return seedLength ? seedLength : 25;
+}
+
QString Wallet::getSeedLanguage() const
{
return QString::fromStdString(m_walletImpl->getSeedLanguage());
//! returns mnemonic seed
QString getSeed(const QString &seedOffset) const;
+ qsizetype seedLength() const;
+
//! returns seed language
QString getSeedLanguage() const;