Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/init.cpp
Show First 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | |||||
bool WalletInit::Verify(const CChainParams &chainParams) const { | bool WalletInit::Verify(const CChainParams &chainParams) const { | ||||
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | ||||
return true; | return true; | ||||
} | } | ||||
if (gArgs.IsArgSet("-walletdir")) { | if (gArgs.IsArgSet("-walletdir")) { | ||||
fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); | fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); | ||||
if (!fs::exists(wallet_dir)) { | boost::system::error_code error; | ||||
// The canonical path cleans the path, preventing >1 Berkeley | |||||
// environment instances for the same directory | |||||
fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error); | |||||
if (error || !fs::exists(wallet_dir)) { | |||||
return InitError( | return InitError( | ||||
strprintf(_("Specified -walletdir \"%s\" does not exist"), | strprintf(_("Specified -walletdir \"%s\" does not exist"), | ||||
wallet_dir.string())); | wallet_dir.string())); | ||||
} else if (!fs::is_directory(wallet_dir)) { | } else if (!fs::is_directory(wallet_dir)) { | ||||
return InitError( | return InitError( | ||||
strprintf(_("Specified -walletdir \"%s\" is not a directory"), | strprintf(_("Specified -walletdir \"%s\" is not a directory"), | ||||
wallet_dir.string())); | wallet_dir.string())); | ||||
// The canonical path transforms relative paths into absolute ones, | |||||
// so we check the non-canonical version | |||||
} else if (!wallet_dir.is_absolute()) { | } else if (!wallet_dir.is_absolute()) { | ||||
return InitError( | return InitError( | ||||
strprintf(_("Specified -walletdir \"%s\" is a relative path"), | strprintf(_("Specified -walletdir \"%s\" is a relative path"), | ||||
wallet_dir.string())); | wallet_dir.string())); | ||||
} | } | ||||
gArgs.ForceSetArg("-walletdir", canonical_wallet_dir.string()); | |||||
} | } | ||||
LogPrintf("Using wallet directory %s\n", GetWalletDir().string()); | LogPrintf("Using wallet directory %s\n", GetWalletDir().string()); | ||||
uiInterface.InitMessage(_("Verifying wallet(s)...")); | uiInterface.InitMessage(_("Verifying wallet(s)...")); | ||||
std::vector<std::string> wallet_files = gArgs.GetArgs("-wallet"); | std::vector<std::string> wallet_files = gArgs.GetArgs("-wallet"); | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |