Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/init.cpp
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | gArgs.AddArg("-spendzeroconfchange", | ||||
false, OptionsCategory::WALLET); | false, OptionsCategory::WALLET); | ||||
gArgs.AddArg("-upgradewallet", | gArgs.AddArg("-upgradewallet", | ||||
_("Upgrade wallet to latest format on startup"), false, | _("Upgrade wallet to latest format on startup"), false, | ||||
OptionsCategory::WALLET); | OptionsCategory::WALLET); | ||||
gArgs.AddArg( | gArgs.AddArg( | ||||
"-wallet=<path>", | "-wallet=<path>", | ||||
_("Specify wallet database path. Can be specified multiple times to " | _("Specify wallet database path. Can be specified multiple times to " | ||||
"load multiple wallets. Path is interpreted relative to <walletdir> " | "load multiple wallets. Path is interpreted relative to <walletdir> " | ||||
"if it is not absolute, and will be created if it does not exist.") + | "if it is not absolute, and will be created if it does not exist (as " | ||||
" " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT), | "a directory containing a wallet.dat file and log files). For " | ||||
"backwards compatibility this will also accept names of existing " | |||||
"data files in <walletdir>.)"), | |||||
false, OptionsCategory::WALLET); | false, OptionsCategory::WALLET); | ||||
gArgs.AddArg("-walletbroadcast", | gArgs.AddArg("-walletbroadcast", | ||||
_("Make the wallet broadcast transactions") + " " + | _("Make the wallet broadcast transactions") + " " + | ||||
strprintf(_("(default: %d)"), DEFAULT_WALLETBROADCAST), | strprintf(_("(default: %d)"), DEFAULT_WALLETBROADCAST), | ||||
false, OptionsCategory::WALLET); | false, OptionsCategory::WALLET); | ||||
gArgs.AddArg("-walletdir=<dir>", | gArgs.AddArg("-walletdir=<dir>", | ||||
_("Specify directory to hold wallets (default: " | _("Specify directory to hold wallets (default: " | ||||
"<datadir>/wallets if it exists, otherwise <datadir>)"), | "<datadir>/wallets if it exists, otherwise <datadir>)"), | ||||
Show All 30 Lines | gArgs.AddArg("-walletrejectlongchains", | ||||
"mempool chain limits (default: %d)"), | "mempool chain limits (default: %d)"), | ||||
DEFAULT_WALLET_REJECT_LONG_CHAINS), | DEFAULT_WALLET_REJECT_LONG_CHAINS), | ||||
true, OptionsCategory::WALLET_DEBUG_TEST); | true, OptionsCategory::WALLET_DEBUG_TEST); | ||||
} | } | ||||
bool WalletInit::ParameterInteraction() const { | bool WalletInit::ParameterInteraction() const { | ||||
CFeeRate minRelayTxFee = GetConfig().GetMinFeePerKB(); | CFeeRate minRelayTxFee = GetConfig().GetMinFeePerKB(); | ||||
gArgs.SoftSetArg("-wallet", DEFAULT_WALLET_DAT); | gArgs.SoftSetArg("-wallet", ""); | ||||
const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1; | const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1; | ||||
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | ||||
return true; | return true; | ||||
} | } | ||||
if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && | if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && | ||||
gArgs.SoftSetBoolArg("-walletbroadcast", false)) { | gArgs.SoftSetBoolArg("-walletbroadcast", false)) { | ||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | bool WalletInit::Verify(const CChainParams &chainParams) const { | ||||
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)...")); | ||||
// Keep track of each wallet absolute path to detect duplicates. | // Keep track of each wallet absolute path to detect duplicates. | ||||
std::set<fs::path> wallet_paths; | std::set<fs::path> wallet_paths; | ||||
for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | ||||
// Do some checking on wallet path. It should be either a: | |||||
// | |||||
// 1. Path where a directory can be created. | |||||
// 2. Path to an existing directory. | |||||
// 3. Path to a symlink to a directory. | |||||
// 4. For backwards compatibility, the name of a data file in | |||||
// -walletdir. | |||||
fs::path wallet_path = fs::absolute(walletFile, GetWalletDir()); | fs::path wallet_path = fs::absolute(walletFile, GetWalletDir()); | ||||
fs::file_type path_type = fs::symlink_status(wallet_path).type(); | |||||
if (fs::exists(wallet_path) && (!fs::is_regular_file(wallet_path) || | if (!(path_type == fs::file_not_found || | ||||
fs::is_symlink(wallet_path))) { | path_type == fs::directory_file || | ||||
return InitError(strprintf(_("Error loading wallet %s. -wallet " | (path_type == fs::symlink_file && | ||||
"filename must be a regular file."), | fs::is_directory(wallet_path)) || | ||||
walletFile)); | (path_type == fs::regular_file && | ||||
fs::path(walletFile).filename() == walletFile))) { | |||||
return InitError(strprintf( | |||||
_("Invalid -wallet path '%s'. -wallet path should point to a " | |||||
"directory where wallet.dat and database/log.?????????? " | |||||
"files can be stored, a location where such a directory " | |||||
"could be created, or (for backwards compatibility) the name " | |||||
"of an existing data file in -walletdir (%s)"), | |||||
walletFile, GetWalletDir())); | |||||
} | } | ||||
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)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |