13 #include "validation.h"
20 strUsage +=
HelpMessageOpt(
"-createwalletbackups=<n>",
strprintf(
"Number of automatic wallet backups (default: %d)", DEFAULT_CREATEWALLETBACKUPS));
21 strUsage +=
HelpMessageOpt(
"-disablewallet",
strprintf(
"Do not load the wallet and disable wallet RPC calls (default: %u)", DEFAULT_DISABLE_WALLET));
22 strUsage +=
HelpMessageOpt(
"-keypool=<n>",
strprintf(
"Set key pool size to <n> (default: %u)", DEFAULT_KEYPOOL_SIZE));
23 strUsage +=
HelpMessageOpt(
"-legacywallet",
"On first run, create a legacy wallet instead of a HD wallet");
27 strUsage +=
HelpMessageOpt(
"-rescan",
"Rescan the block chain for missing wallet transactions on startup");
28 strUsage +=
HelpMessageOpt(
"-salvagewallet",
"Attempt to recover private keys from a corrupt wallet file on startup");
29 strUsage +=
HelpMessageOpt(
"-spendzeroconfchange",
strprintf(
"Spend unconfirmed change when sending transactions (default: %u)", DEFAULT_SPEND_ZEROCONF_CHANGE));
30 strUsage +=
HelpMessageOpt(
"-txconfirmtarget=<n>",
strprintf(
"If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)", 1));
31 strUsage +=
HelpMessageOpt(
"-upgradewallet",
"Upgrade wallet to latest format on startup");
32 strUsage +=
HelpMessageOpt(
"-wallet=<path>",
"Specify wallet database path. Can be specified multiple times to load multiple wallets. Path is interpreted relative to <walletdir> if it is not absolute, and will be created if it does not exist (as a directory containing a wallet.dat file and log files). For backwards compatibility this will also accept names of existing data files in <walletdir>.)");
33 strUsage +=
HelpMessageOpt(
"-walletdir=<dir>",
"Specify directory to hold wallets (default: <datadir>/wallets if it exists, otherwise <datadir>)");
34 strUsage +=
HelpMessageOpt(
"-walletnotify=<cmd>",
"Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)");
35 strUsage +=
HelpMessageOpt(
"-zapwallettxes=<mode>",
"Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup"
36 "(1 = keep tx meta data e.g. payment request information, 2 = drop tx meta data)");
38 strUsage +=
HelpMessageOpt(
"-coldstaking=<n>",
strprintf(
"Enable cold staking functionality (0-1, default: %u). Disabled if staking=0", DEFAULT_COLDSTAKING));
40 strUsage +=
HelpMessageOpt(
"-genproclimit=<n>",
strprintf(
"Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)", DEFAULT_GENERATE_PROCLIMIT));
41 strUsage +=
HelpMessageOpt(
"-minstakesplit=<amt>",
strprintf(
"Minimum positive amount (in PIV) allowed by GUI and RPC for the stake split threshold (default: %s)",
FormatMoney(DEFAULT_MIN_STAKE_SPLIT_THRESHOLD)));
42 strUsage +=
HelpMessageOpt(
"-staking=<n>",
strprintf(
"Enable staking functionality (0-1, default: %u)", DEFAULT_STAKING));
45 strUsage +=
HelpMessageOpt(
"-dblogsize=<n>",
strprintf(
"Flush database activity from memory pool to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE));
46 strUsage +=
HelpMessageOpt(
"-flushwallet",
strprintf(
"Run a thread to flush wallet periodically (default: %u)", DEFAULT_FLUSHWALLET));
47 strUsage +=
HelpMessageOpt(
"-privdb",
strprintf(
"Sets the DB_PRIVATE flag in the wallet db environment (default: %u)", DEFAULT_WALLET_PRIVDB));
60 return UIError(
strprintf(
_(
"%s is not allowed in combination with enabled wallet functionality"),
"-sysperms"));
64 const bool is_multiwallet =
gArgs.
GetArgs(
"-wallet").size() > 1;
68 return UIError(
strprintf(
_(
"%s is only allowed with a single wallet file"),
"-salvagewallet"));
72 LogPrintf(
"%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
79 LogPrintf(
"%s: parameter interaction: -zapwallettxes=%s -> setting -persistmempool=0\n", __func__, zapwallettxes);
85 return UIError(
strprintf(
_(
"%s is only allowed with a single wallet file"),
"-zapwallettxes"));
88 LogPrintf(
"%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
94 return UIError(
strprintf(
_(
"%s is only allowed with a single wallet file"),
"-upgradewallet"));
103 return UIError(AmountErrMsg(
"mintxfee",
gArgs.
GetArg(
"-mintxfee",
"")));
108 return UIError(AmountErrMsg(
"paytxfee",
gArgs.
GetArg(
"-paytxfee",
"")));
109 if (nFeePerK > nHighTransactionFeeWarning)
110 UIWarning(
strprintf(
_(
"Warning: %s is set very high! This is the transaction fee you will pay if you send a transaction."),
"-paytxfee"));
113 return UIError(
strprintf(
_(
"Invalid amount for %s: '%s' (must be at least %s)"),
"-paytxfee",
120 return UIError(AmountErrMsg(
"maxtxfee",
gArgs.
GetArg(
"-maxtxfee",
"")));
121 if (nMaxFee > nHighTransactionMaxFeeWarning)
122 UIWarning(
strprintf(
_(
"Warning: %s is set very high! Fees this large could be paid on a single transaction."),
"-maxtxfee"));
125 return UIError(
strprintf(
_(
"Invalid amount for %s: '%s' (must be at least the minimum relay fee of %s to prevent stuck transactions)"),
134 return UIError(AmountErrMsg(
"minstakesplit",
gArgs.
GetArg(
"-minstakesplit",
"")));
150 fs::path wallet_dir =
gArgs.
GetArg(
"-walletdir",
"");
151 if (!fs::exists(wallet_dir)) {
152 return UIError(
strprintf(
_(
"Specified -walletdir \"%s\" does not exist"), wallet_dir.string()));
153 }
else if (!fs::is_directory(wallet_dir)) {
154 return UIError(
strprintf(
_(
"Specified -walletdir \"%s\" is not a directory"), wallet_dir.string()));
155 }
else if (!wallet_dir.is_absolute()) {
156 return UIError(
strprintf(
_(
"Specified -walletdir \"%s\" is a relative path"), wallet_dir.string()));
160 LogPrintf(
"Using wallet directory %s\n",
GetWalletDir().
string());
165 std::set<fs::path> wallet_paths;
167 for (
const std::string& walletFile :
gArgs.
GetArgs(
"-wallet")) {
169 if (!opRes)
return UIError(opRes.getError());
171 fs::path wallet_path = fs::absolute(walletFile,
GetWalletDir());
172 if (!wallet_paths.insert(wallet_path).second) {
173 return UIError(
strprintf(
_(
"Error loading wallet %s. Duplicate %s filename specified."), walletFile,
"-wallet"));
176 std::string strError;
178 return UIError(strError);
184 std::string backup_filename;
195 std::string strWarning;
197 if (!strWarning.empty()) {
198 UIWarning(strWarning);
201 return UIError(strError);
211 LogPrintf(
"Wallet disabled!\n");
215 for (
const std::string& walletFile :
gArgs.
GetArgs(
"-wallet")) {
229 std::string strWarning, strError;
231 if (!strWarning.empty()) {
232 UIWarning(
strprintf(
"%s: %s", pwallet->GetName(), strWarning));
234 if (!strError.empty()) {
235 return UIError(
strprintf(
"%s: %s", pwallet->GetName(), strError));
int64_t CAmount
Amount in PIV (Can be negative)
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
static std::unique_ptr< BerkeleyDatabase > CreateDummy()
Return object for accessing dummy database with no read/write capabilities.
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
Fee rate in PIV per kilobyte: CAmount / kB.
std::string ToString() const
CAmount GetFeePerK() const
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
static CWallet * CreateWalletFromFile(const std::string &name, const fs::path &path)
static CAmount minStakeSplitThreshold
minimum accpeted value for stake split threshold
static CFeeRate minTxFee
Fees smaller than this (in upiv) are considered zero fee (for transaction creation) We are ~100 times...
static bool RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
static bool Recover(const fs::path &wallet_path, void *callbackDataIn, bool(*recoverKVcallback)(void *callbackData, CDataStream ssKey, CDataStream ssValue), std::string &out_backup_filename)
static bool VerifyEnvironment(const fs::path &wallet_path, std::string &errorStr)
static bool VerifyDatabaseFile(const fs::path &wallet_path, std::string &warningStr, std::string &errorStr)
const std::string CURRENCY_UNIT
CClientUIInterface uiInterface
RecursiveMutex cs_main
Global state.
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a Optional result.
bool ParseMoney(const std::string &str, CAmount &nRet)
std::string FormatMoney(const CAmount &n, bool fPlus)
Money parsing/formatting utilities.
CFeeRate minRelayTxFee
Fees smaller than this (in upiv) are considered zero fee (for relaying, mining and transaction creati...
bool WalletVerify()
Responsible for reading and validating the -wallet arguments and verifying the wallet database.
std::string GetWalletHelpString(bool showDebug)
Return the wallets help message.
bool InitLoadWallet()
Load wallet databases.
bool WalletParameterInteraction()
Wallets parameter interaction.
std::vector< CWalletRef > vpwallets
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE)
Settings.
bool bSpendZeroConfChange
unsigned int nTxConfirmTarget
bool bdisableSystemnotifications
bool AutoBackupWallet(CWallet &wallet, std::string &strBackupWarning, std::string &strBackupError)
Called during init: Automatic backups.
fs::path GetWalletDir()
Get the path of the wallet directory.
OperationResult VerifyWalletPath(const std::string &walletFile)
Verify the wallet db's path.