mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-12 12:52:35 -03:00
Merge #19919: bugfix: make LoadWallet assigns status always
8b39a87558
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-ACK8b39a87558
, that is the same as 1728059730abef04f3fa84de0b6e20044be7a9d6. ryanofsky: Code review ACK8b39a87558
(same as previous) meshcollider: utACK8b39a87558
Tree-SHA512: a75d8240f60325bfdb69a07d392269fec97de743f38fe108371eb63a0aba5d8ce3cc484ecc69e81febf8040f5ab64f3a9450b98f8e07a0c17803784bb6f342bf
This commit is contained in:
commit
be375b2206
2 changed files with 4 additions and 0 deletions
|
@ -212,6 +212,7 @@ enum class DatabaseStatus {
|
|||
FAILED_ALREADY_EXISTS,
|
||||
FAILED_NOT_FOUND,
|
||||
FAILED_CREATE,
|
||||
FAILED_LOAD,
|
||||
FAILED_VERIFY,
|
||||
FAILED_ENCRYPT,
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue