Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 4,133 Lines • ▼ Show 20 Lines | if (IsWalletLoaded(wallet_path)) { | ||||
"Error loading wallet %s. Duplicate -wallet filename specified.", | "Error loading wallet %s. Duplicate -wallet filename specified.", | ||||
location.GetName())); | location.GetName())); | ||||
return false; | return false; | ||||
} | } | ||||
// Keep same database environment instance across Verify/Recover calls | // Keep same database environment instance across Verify/Recover calls | ||||
// below. | // below. | ||||
std::unique_ptr<WalletDatabase> database = | std::unique_ptr<WalletDatabase> database = | ||||
WalletDatabase::Create(wallet_path); | CreateWalletDatabase(wallet_path); | ||||
try { | try { | ||||
return database->Verify(error_string); | return database->Verify(error_string); | ||||
} catch (const fs::filesystem_error &e) { | } catch (const fs::filesystem_error &e) { | ||||
error_string = Untranslated( | error_string = Untranslated( | ||||
strprintf("Error loading wallet %s. %s", location.GetName(), | strprintf("Error loading wallet %s. %s", location.GetName(), | ||||
fsbridge::get_filesystem_error_message(e))); | fsbridge::get_filesystem_error_message(e))); | ||||
return false; | return false; | ||||
Show All 10 Lines | std::shared_ptr<CWallet> CWallet::CreateWalletFromFile( | ||||
// Needed to restore wallet transaction meta data after -zapwallettxes | // Needed to restore wallet transaction meta data after -zapwallettxes | ||||
std::list<CWalletTx> vWtx; | std::list<CWalletTx> vWtx; | ||||
if (gArgs.GetBoolArg("-zapwallettxes", false)) { | if (gArgs.GetBoolArg("-zapwallettxes", false)) { | ||||
chain.initMessage( | chain.initMessage( | ||||
_("Zapping all transactions from wallet...").translated); | _("Zapping all transactions from wallet...").translated); | ||||
std::unique_ptr<CWallet> tempWallet = std::make_unique<CWallet>( | std::unique_ptr<CWallet> tempWallet = std::make_unique<CWallet>( | ||||
&chain, location, WalletDatabase::Create(location.GetPath())); | &chain, location, CreateWalletDatabase(location.GetPath())); | ||||
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx); | DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx); | ||||
if (nZapWalletRet != DBErrors::LOAD_OK) { | if (nZapWalletRet != DBErrors::LOAD_OK) { | ||||
error = | error = | ||||
strprintf(_("Error loading %s: Wallet corrupted"), walletFile); | strprintf(_("Error loading %s: Wallet corrupted"), walletFile); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
} | } | ||||
chain.initMessage(_("Loading wallet...").translated); | chain.initMessage(_("Loading wallet...").translated); | ||||
int64_t nStart = GetTimeMillis(); | int64_t nStart = GetTimeMillis(); | ||||
bool fFirstRun = true; | bool fFirstRun = true; | ||||
// TODO: Can't use std::make_shared because we need a custom deleter but | // TODO: Can't use std::make_shared because we need a custom deleter but | ||||
// should be possible to use std::allocate_shared. | // should be possible to use std::allocate_shared. | ||||
std::shared_ptr<CWallet> walletInstance( | std::shared_ptr<CWallet> walletInstance( | ||||
new CWallet(&chain, location, | new CWallet(&chain, location, CreateWalletDatabase(location.GetPath())), | ||||
WalletDatabase::Create(location.GetPath())), | |||||
ReleaseWallet); | ReleaseWallet); | ||||
DBErrors nLoadWalletRet = walletInstance->LoadWallet(fFirstRun); | DBErrors nLoadWalletRet = walletInstance->LoadWallet(fFirstRun); | ||||
if (nLoadWalletRet != DBErrors::LOAD_OK) { | if (nLoadWalletRet != DBErrors::LOAD_OK) { | ||||
if (nLoadWalletRet == DBErrors::CORRUPT) { | if (nLoadWalletRet == DBErrors::CORRUPT) { | ||||
error = | error = | ||||
strprintf(_("Error loading %s: Wallet corrupted"), walletFile); | strprintf(_("Error loading %s: Wallet corrupted"), walletFile); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 844 Lines • Show Last 20 Lines |