aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2022-09-04 21:29:07 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2022-09-16 23:28:21 +0000
commitc3e536555aa3a7db773170671da1256a2ace2094 (patch)
tree166408e67a5c65327b44e2e0a6a5fabca9f59bdd
parent335ff98c8a64eda38a2a2334102bd253f108c253 (diff)
downloadbitcoin-c3e536555aa3a7db773170671da1256a2ace2094.tar.xz
Bugfix: Wallet: Return util::Error rather than non-error nullptr when CreateWallet/LoadWallet/RestoreWallet fail
-rw-r--r--src/wallet/interfaces.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp
index 4fbc519e39..1650a9e5ee 100644
--- a/src/wallet/interfaces.cpp
+++ b/src/wallet/interfaces.cpp
@@ -560,8 +560,12 @@ public:
options.create_flags = wallet_creation_flags;
options.create_passphrase = passphrase;
bilingual_str error;
- util::Result<std::unique_ptr<Wallet>> wallet{MakeWallet(m_context, CreateWallet(m_context, name, /*load_on_start=*/true, options, status, error, warnings))};
- return wallet ? std::move(wallet) : util::Error{error};
+ std::unique_ptr<Wallet> wallet{MakeWallet(m_context, CreateWallet(m_context, name, /*load_on_start=*/true, options, status, error, warnings))};
+ if (wallet) {
+ return {std::move(wallet)};
+ } else {
+ return util::Error{error};
+ }
}
util::Result<std::unique_ptr<Wallet>> loadWallet(const std::string& name, std::vector<bilingual_str>& warnings) override
{
@@ -570,15 +574,23 @@ public:
ReadDatabaseArgs(*m_context.args, options);
options.require_existing = true;
bilingual_str error;
- util::Result<std::unique_ptr<Wallet>> wallet{MakeWallet(m_context, LoadWallet(m_context, name, /*load_on_start=*/true, options, status, error, warnings))};
- return wallet ? std::move(wallet) : util::Error{error};
+ std::unique_ptr<Wallet> wallet{MakeWallet(m_context, LoadWallet(m_context, name, /*load_on_start=*/true, options, status, error, warnings))};
+ if (wallet) {
+ return {std::move(wallet)};
+ } else {
+ return util::Error{error};
+ }
}
util::Result<std::unique_ptr<Wallet>> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, std::vector<bilingual_str>& warnings) override
{
DatabaseStatus status;
bilingual_str error;
- util::Result<std::unique_ptr<Wallet>> wallet{MakeWallet(m_context, RestoreWallet(m_context, backup_file, wallet_name, /*load_on_start=*/true, status, error, warnings))};
- return wallet ? std::move(wallet) : util::Error{error};
+ 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 {std::move(wallet)};
+ } else {
+ return util::Error{error};
+ }
}
std::string getWalletDir() override
{