From 43d4a7afcc0811e077b4642da70aa7a5ba167bd2 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Fri, 3 Mar 2023 23:15:06 +0100 Subject: [PATCH] WindowManager: only setNewWallet if wallet is actually new --- src/WindowManager.cpp | 8 +++++--- src/WindowManager.h | 2 +- src/wizard/WalletWizard.cpp | 4 +++- src/wizard/WalletWizard.h | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/WindowManager.cpp b/src/WindowManager.cpp index 610e9ae..ebd3976 100644 --- a/src/WindowManager.cpp +++ b/src/WindowManager.cpp @@ -282,7 +282,7 @@ bool WindowManager::autoOpenWallet() { // ######################## WALLET CREATION ######################## void WindowManager::tryCreateWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, - const QString &seedOffset, const QString &subaddressLookahead) { + const QString &seedOffset, const QString &subaddressLookahead, bool newWallet) { if(Utils::fileExists(path)) { auto err = QString("Failed to write wallet to path: \"%1\"; file already exists.").arg(path); this->handleWalletError(err); @@ -309,7 +309,10 @@ void WindowManager::tryCreateWallet(Seed seed, const QString &path, const QStrin wallet->setCacheAttribute("feather.seed", seed.mnemonic.join(" ")); wallet->setCacheAttribute("feather.seedoffset", seedOffset); - wallet->setNewWallet(); + + if (newWallet) { + wallet->setNewWallet(); + } this->onWalletOpened(wallet); } @@ -368,7 +371,6 @@ void WindowManager::onWalletCreated(Wallet *wallet) { // Currently only called when a wallet is created from device. auto state = wallet->status(); if (state != Wallet::Status_Ok) { - wallet->setNewWallet(); qDebug() << Q_FUNC_INFO << QString("Wallet open error: %1").arg(wallet->errorString()); this->displayWalletErrorMessage(wallet->errorString()); m_splashDialog->hide(); diff --git a/src/WindowManager.h b/src/WindowManager.h index d8dc074..89c0a22 100644 --- a/src/WindowManager.h +++ b/src/WindowManager.h @@ -55,7 +55,7 @@ private slots: void onChangeTheme(const QString &themeName); private: - void tryCreateWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset, const QString &subaddressLookahead); + void tryCreateWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset, const QString &subaddressLookahead, bool newWallet); void tryCreateWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight, const QString &subaddressLookahead); void tryCreateWalletFromKeys(const QString &path, const QString &password, const QString &address, const QString &viewkey, const QString &spendkey, quint64 restoreHeight, const QString &subaddressLookahead); diff --git a/src/wizard/WalletWizard.cpp b/src/wizard/WalletWizard.cpp index 8d62dbe..d876b59 100644 --- a/src/wizard/WalletWizard.cpp +++ b/src/wizard/WalletWizard.cpp @@ -135,5 +135,7 @@ void WalletWizard::onCreateWallet() { m_wizardFields.seed.setRestoreHeight(m_wizardFields.restoreHeight); } - emit createWallet(m_wizardFields.seed, walletPath, m_wizardFields.password, m_wizardFields.seedLanguage, m_wizardFields.seedOffsetPassphrase, m_wizardFields.subaddressLookahead); + bool newWallet = m_wizardFields.mode == WizardMode::CreateWallet; + + emit createWallet(m_wizardFields.seed, walletPath, m_wizardFields.password, m_wizardFields.seedLanguage, m_wizardFields.seedOffsetPassphrase, m_wizardFields.subaddressLookahead, newWallet); } \ No newline at end of file diff --git a/src/wizard/WalletWizard.h b/src/wizard/WalletWizard.h index 975cac8..4cb2284 100644 --- a/src/wizard/WalletWizard.h +++ b/src/wizard/WalletWizard.h @@ -97,7 +97,7 @@ signals: void createWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight, const QString &subaddressLookahead); void createWalletFromKeys(const QString &path, const QString &password, const QString &address, const QString &viewkey, const QString &spendkey, quint64 restoreHeight, const QString subaddressLookahead = ""); - void createWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset = "", const QString &subaddressLookahead = ""); + void createWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset, const QString &subaddressLookahead, bool newWallet); private slots: void onCreateWallet();