wallet: Return util::Result from WalletLoader methods

This commit is contained in:
w0xlt committed 2022-08-10 11:14:53 -03:00
1 parent a6fc293c0a
commit 07df6cda14
4 files changed
+47 -35

No files matched your search

+17 -6
View File
@@ -262,9 +262,13 @@ void CreateWalletActivity::createWallet()
}
QTimer::singleShot(500ms, worker(), [this, name, flags] {
std::unique_ptr<interfaces::Wallet> wallet = node().walletLoader().createWallet(name, m_passphrase, flags, m_error_message, m_warning_message);
auto wallet{node().walletLoader().createWallet(name, m_passphrase, flags, m_warning_message)};
if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
if (wallet) {
m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(*wallet));
} else {
m_error_message = util::ErrorString(wallet);
}
QTimer::singleShot(500ms, this, &CreateWalletActivity::finish);
});
@@ -343,9 +347,13 @@ void OpenWalletActivity::open(const std::string& path)
tr("Opening Wallet <b>%1</b>…").arg(name.toHtmlEscaped()));
QTimer::singleShot(0, worker(), [this, path] {
std::unique_ptr<interfaces::Wallet> wallet = node().walletLoader().loadWallet(path, m_error_message, m_warning_message);
auto wallet{node().walletLoader().loadWallet(path, m_warning_message)};
if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
if (wallet) {
m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(*wallet));
} else {
m_error_message = util::ErrorString(wallet);
}
QTimer::singleShot(0, this, &OpenWalletActivity::finish);
});
@@ -393,8 +401,11 @@ void RestoreWalletActivity::restore(const fs::path& backup_file, const std::stri
QTimer::singleShot(0, worker(), [this, backup_file, wallet_name] {
auto wallet{node().walletLoader().restoreWallet(backup_file, wallet_name, m_warning_message)};
m_error_message = util::ErrorString(wallet);
if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(*wallet));
if (wallet) {
m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(*wallet));
} else {
m_error_message = util::ErrorString(wallet);
}
QTimer::singleShot(0, this, &RestoreWalletActivity::finish);
});