aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/wallet.h2
-rw-r--r--src/qt/walletcontroller.cpp5
-rw-r--r--src/wallet/interfaces.cpp8
3 files changed, 9 insertions, 6 deletions
diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
index fe198c999b..e29fefae56 100644
--- a/src/interfaces/wallet.h
+++ b/src/interfaces/wallet.h
@@ -329,7 +329,7 @@ public:
virtual std::string getWalletDir() = 0;
//! Restore backup wallet
- virtual std::unique_ptr<Wallet> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, bilingual_str& error, std::vector<bilingual_str>& warnings) = 0;
+ virtual BResult<std::unique_ptr<Wallet>> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, std::vector<bilingual_str>& warnings) = 0;
//! Return available wallets in wallet directory.
virtual std::vector<std::string> listWalletDir() = 0;
diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp
index 11140c5da9..01d84624e8 100644
--- a/src/qt/walletcontroller.cpp
+++ b/src/qt/walletcontroller.cpp
@@ -391,9 +391,10 @@ void RestoreWalletActivity::restore(const fs::path& backup_file, const std::stri
tr("Restoring Wallet <b>%1</b>…").arg(name.toHtmlEscaped()));
QTimer::singleShot(0, worker(), [this, backup_file, wallet_name] {
- std::unique_ptr<interfaces::Wallet> wallet = node().walletLoader().restoreWallet(backup_file, wallet_name, m_error_message, m_warning_message);
+ auto wallet{node().walletLoader().restoreWallet(backup_file, wallet_name, m_warning_message)};
- if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
+ m_error_message = wallet ? bilingual_str{} : wallet.GetError();
+ if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(wallet.ReleaseObj());
QTimer::singleShot(0, this, &RestoreWalletActivity::finish);
});
diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp
index 547d972c8d..23f91d9b3a 100644
--- a/src/wallet/interfaces.cpp
+++ b/src/wallet/interfaces.cpp
@@ -569,11 +569,13 @@ public:
options.require_existing = true;
return MakeWallet(m_context, LoadWallet(m_context, name, true /* load_on_start */, options, status, error, warnings));
}
- std::unique_ptr<Wallet> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, bilingual_str& error, std::vector<bilingual_str>& warnings) override
+ BResult<std::unique_ptr<Wallet>> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, std::vector<bilingual_str>& warnings) override
{
DatabaseStatus status;
-
- return MakeWallet(m_context, RestoreWallet(m_context, backup_file, wallet_name, /*load_on_start=*/true, status, error, warnings));
+ bilingual_str error;
+ BResult<std::unique_ptr<Wallet>> wallet{MakeWallet(m_context, RestoreWallet(m_context, backup_file, wallet_name, /*load_on_start=*/true, status, error, warnings))};
+ if (!wallet) return error;
+ return wallet;
}
std::string getWalletDir() override
{