mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 03:03:22 -03:00
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.
This commit is contained in:
parent
564e1ab0f3
commit
8b39a87558
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…
Add table
Reference in a new issue