diff options
author | Akio Nakamura <nakamura@dgtechnologies.co.jp> | 2020-09-09 01:11:20 +0900 |
---|---|---|
committer | Akio Nakamura <nakamura@dgtechnologies.co.jp> | 2020-09-10 00:47:31 +0900 |
commit | 8b39a875581bed1c2f40a7d9616bdb7cc642bf59 (patch) | |
tree | def8d93649f86b2e396f5426dad27b89cd0728b9 | |
parent | 564e1ab0f3dc573bd3ea60a80f6649c361243df9 (diff) |
bugfix: make LoadWallet assigns status always
Although loadwallet() in rpcwallet.cpp assumes LoadWallet() always
assign some value to the 'status', but LoadWallet() does not do so
in some situation.
This fixes above and prevends loadwallet() returns ambiguous error code.
-rw-r--r-- | src/wallet/db.h | 1 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/wallet/db.h b/src/wallet/db.h index 96d1f44d91..617ed46141 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -212,6 +212,7 @@ enum class DatabaseStatus { FAILED_ALREADY_EXISTS, FAILED_NOT_FOUND, FAILED_CREATE, + FAILED_LOAD, FAILED_VERIFY, FAILED_ENCRYPT, }; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e2a2503035..73e11a5b52 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -212,6 +212,7 @@ std::shared_ptr<CWallet> LoadWalletInternal(interfaces::Chain& chain, const std: std::shared_ptr<CWallet> wallet = CWallet::Create(chain, name, std::move(database), options.create_flags, error, warnings); if (!wallet) { error = Untranslated("Wallet loading failed.") + Untranslated(" ") + error; + status = DatabaseStatus::FAILED_LOAD; return nullptr; } AddWallet(wallet); @@ -223,6 +224,7 @@ std::shared_ptr<CWallet> LoadWalletInternal(interfaces::Chain& chain, const std: return wallet; } catch (const std::runtime_error& e) { error = Untranslated(e.what()); + status = DatabaseStatus::FAILED_LOAD; return nullptr; } } @@ -233,6 +235,7 @@ std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& auto result = WITH_LOCK(g_loading_wallet_mutex, return g_loading_wallet_set.insert(name)); if (!result.second) { error = Untranslated("Wallet already being loading."); + status = DatabaseStatus::FAILED_LOAD; return nullptr; } auto wallet = LoadWalletInternal(chain, name, load_on_start, options, status, error, warnings); |