Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 516 Lines • ▼ Show 20 Lines | |||||
bool CWallet::Verify() { | bool CWallet::Verify() { | ||||
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | ||||
return true; | return true; | ||||
} | } | ||||
uiInterface.InitMessage(_("Verifying wallet(s)...")); | uiInterface.InitMessage(_("Verifying wallet(s)...")); | ||||
// Keep track of each wallet absolute path to detect duplicates. | |||||
std::set<fs::path> wallet_paths; | |||||
for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | ||||
if (fs::path(walletFile).filename() != walletFile) { | if (fs::path(walletFile).filename() != walletFile) { | ||||
return InitError(_( | return InitError( | ||||
"-wallet parameter must only specify a filename (not a path)")); | strprintf(_("Error loading wallet %s. -wallet parameter must " | ||||
} else if (SanitizeString(walletFile, SAFE_CHARS_FILENAME) != | "only specify a filename (not a path)."), | ||||
walletFile) { | walletFile)); | ||||
return InitError(_("Invalid characters in -wallet filename")); | } | ||||
if (SanitizeString(walletFile, SAFE_CHARS_FILENAME) != walletFile) { | |||||
return InitError(strprintf(_("Error loading wallet %s. Invalid " | |||||
"characters in -wallet filename."), | |||||
walletFile)); | |||||
} | |||||
fs::path wallet_path = fs::absolute(walletFile, GetDataDir()); | |||||
if (fs::exists(wallet_path) && (!fs::is_regular_file(wallet_path) || | |||||
fs::is_symlink(wallet_path))) { | |||||
return InitError(strprintf(_("Error loading wallet %s. -wallet " | |||||
"filename must be a regular file."), | |||||
walletFile)); | |||||
} | |||||
if (!wallet_paths.insert(wallet_path).second) { | |||||
return InitError(strprintf(_("Error loading wallet %s. Duplicate " | |||||
"-wallet filename specified."), | |||||
walletFile)); | |||||
} | } | ||||
std::string strError; | std::string strError; | ||||
if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), | if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), | ||||
strError)) { | strError)) { | ||||
return InitError(strError); | return InitError(strError); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,973 Lines • Show Last 20 Lines |