mirror of
https://github.com/feather-wallet/feather.git
synced 2024-11-16 17:27:38 +00:00
Seed: fix misc UI
This commit is contained in:
parent
93a6a986e0
commit
6633353bf3
8 changed files with 27 additions and 19 deletions
|
@ -788,9 +788,9 @@ void MainWindow::updatePasswordIcon() {
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -266,8 +266,6 @@ void WindowManager::tryCreateWallet(Seed seed, const QString &path, const QStrin
|
|||
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);
|
||||
|
@ -278,6 +276,9 @@ void WindowManager::tryCreateWallet(Seed seed, const QString &path, const QStrin
|
|||
return;
|
||||
}
|
||||
|
||||
wallet->setCacheAttribute("feather.seed", seed.mnemonic.join(" "));
|
||||
wallet->setCacheAttribute("feather.seedoffset", seedOffset);
|
||||
|
||||
this->onWalletOpened(wallet);
|
||||
}
|
||||
|
||||
|
|
|
@ -200,9 +200,9 @@ void AppContext::onTorSettingsChanged() {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -67,11 +67,8 @@ void DebugInfoDialog::updateInfo() {
|
|||
|
||||
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](){
|
||||
|
|
|
@ -22,22 +22,24 @@ SeedDialog::SeedDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
|
|||
}
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ WalletInfoDialog::WalletInfoDialog(QSharedPointer<AppContext> ctx, QWidget *pare
|
|||
|
||||
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());
|
||||
|
|
|
@ -39,6 +39,12 @@ QString Wallet::getSeed(const QString &seedOffset) const
|
|||
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());
|
||||
|
|
|
@ -106,6 +106,8 @@ public:
|
|||
//! returns mnemonic seed
|
||||
QString getSeed(const QString &seedOffset) const;
|
||||
|
||||
qsizetype seedLength() const;
|
||||
|
||||
//! returns seed language
|
||||
QString getSeedLanguage() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue