Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/init.cpp
Show First 20 Lines • Show All 349 Lines • ▼ Show 20 Lines | for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | ||||
if (!wallet_paths.insert(wallet_path).second) { | if (!wallet_paths.insert(wallet_path).second) { | ||||
return InitError(strprintf(_("Error loading wallet %s. Duplicate " | return InitError(strprintf(_("Error loading wallet %s. Duplicate " | ||||
"-wallet filename specified."), | "-wallet filename specified."), | ||||
walletFile)); | walletFile)); | ||||
} | } | ||||
std::string strError; | std::string strError; | ||||
if (!CWalletDB::VerifyEnvironment(walletFile, GetWalletDir().string(), | if (!CWalletDB::VerifyEnvironment(wallet_path, strError)) { | ||||
strError)) { | |||||
return InitError(strError); | return InitError(strError); | ||||
} | } | ||||
if (gArgs.GetBoolArg("-salvagewallet", false)) { | if (gArgs.GetBoolArg("-salvagewallet", false)) { | ||||
// Recover readable keypairs: | // Recover readable keypairs: | ||||
CWallet dummyWallet(chainParams); | CWallet dummyWallet(chainParams, "dummy", | ||||
CWalletDBWrapper::CreateDummy()); | |||||
std::string backup_filename; | std::string backup_filename; | ||||
if (!CWalletDB::Recover(walletFile, (void *)&dummyWallet, | if (!CWalletDB::Recover(wallet_path, (void *)&dummyWallet, | ||||
CWalletDB::RecoverKeysOnlyFilter, | CWalletDB::RecoverKeysOnlyFilter, | ||||
backup_filename)) { | backup_filename)) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
std::string strWarning; | std::string strWarning; | ||||
bool dbV = CWalletDB::VerifyDatabaseFile( | bool dbV = | ||||
walletFile, GetWalletDir().string(), strWarning, strError); | CWalletDB::VerifyDatabaseFile(wallet_path, strWarning, strError); | ||||
if (!strWarning.empty()) { | if (!strWarning.empty()) { | ||||
InitWarning(strWarning); | InitWarning(strWarning); | ||||
} | } | ||||
if (!dbV) { | if (!dbV) { | ||||
InitError(strError); | InitError(strError); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool WalletInit::Open(const CChainParams &chainParams) const { | bool WalletInit::Open(const CChainParams &chainParams) const { | ||||
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | ||||
LogPrintf("Wallet disabled!\n"); | LogPrintf("Wallet disabled!\n"); | ||||
return true; | return true; | ||||
} | } | ||||
for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | ||||
CWallet *const pwallet = | CWallet *const pwallet = CWallet::CreateWalletFromFile( | ||||
CWallet::CreateWalletFromFile(chainParams, walletFile); | chainParams, walletFile, fs::absolute(walletFile, GetWalletDir())); | ||||
if (!pwallet) { | if (!pwallet) { | ||||
return false; | return false; | ||||
} | } | ||||
vpwallets.push_back(pwallet); | vpwallets.push_back(pwallet); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
Show All 25 Lines |