mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
Bugfix: Wallet: Return util::Error rather than non-error nullptr when CreateWallet/LoadWallet/RestoreWallet fail
This commit is contained in:
parent
335ff98c8a
commit
c3e536555a
1 changed files with 18 additions and 6 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue