diff options
author | Samuel Dobson <dobsonsa68@gmail.com> | 2020-09-13 11:50:18 +1200 |
---|---|---|
committer | Samuel Dobson <dobsonsa68@gmail.com> | 2020-09-13 12:04:43 +1200 |
commit | be375b2206fef8a5b6860eed14daab5f82386da4 (patch) | |
tree | d47f89cc89541a9dbfddc9ea863a5d3d8babc794 | |
parent | f2d9934381bf89f1746f13cc5f86ae199eaa52bb (diff) | |
parent | 8b39a875581bed1c2f40a7d9616bdb7cc642bf59 (diff) |
Merge #19919: bugfix: make LoadWallet assigns status always
8b39a875581bed1c2f40a7d9616bdb7cc642bf59 bugfix: make LoadWallet assigns status always (Akio Nakamura)
Pull request description:
In my enviroment, ```test/functional/wallet_multiwallet.py``` failed in line 237 for master( 147d50d63 ).
It got an expected rpc-error-message, but error code was not (-4) but (-18).
This is because that although loadwallet() in rpcwallet.cpp assumes LoadWallet() always assign some value to the 'status', but LoadWallet() does not do so in some situation.
This PR intends to fix above and prevends loadwallet() returns ambiguous error code.
ACKs for top commit:
hebasto:
re-ACK 8b39a875581bed1c2f40a7d9616bdb7cc642bf59, that is the same as 1728059730abef04f3fa84de0b6e20044be7a9d6.
ryanofsky:
Code review ACK 8b39a875581bed1c2f40a7d9616bdb7cc642bf59 (same as previous)
meshcollider:
utACK 8b39a875581bed1c2f40a7d9616bdb7cc642bf59
Tree-SHA512: a75d8240f60325bfdb69a07d392269fec97de743f38fe108371eb63a0aba5d8ce3cc484ecc69e81febf8040f5ab64f3a9450b98f8e07a0c17803784bb6f342bf
-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); |