12 #include "validation.h" 19 strUsage +=
HelpMessageOpt(
"-disablewallet",
_(
"Do not load the wallet and disable wallet RPC calls"));
20 strUsage +=
HelpMessageOpt(
"-keypool=<n>",
strprintf(
_(
"Set key pool size to <n> (default: %u)"), DEFAULT_KEYPOOL_SIZE));
21 strUsage +=
HelpMessageOpt(
"-fallbackfee=<amt>",
strprintf(
_(
"A fee rate (in %s/kB) that will be used when fee estimation has insufficient data (default: %s)"),
23 strUsage +=
HelpMessageOpt(
"-discardfee=<amt>",
strprintf(
_(
"The fee rate (in %s/kB) that indicates your tolerance for discarding change by adding it to the fee (default: %s). " 24 "Note: An output is discarded if it is dust at this rate, but we will always discard up to the dust relay fee and a discard fee above that is limited by the fee estimate for the longest target"),
26 strUsage +=
HelpMessageOpt(
"-mintxfee=<amt>",
strprintf(
_(
"Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)"),
28 strUsage +=
HelpMessageOpt(
"-paytxfee=<amt>",
strprintf(
_(
"Fee (in %s/kB) to add to transactions you send (default: %s)"),
30 strUsage +=
HelpMessageOpt(
"-rescan",
_(
"Rescan the block chain for missing wallet transactions on startup"));
31 strUsage +=
HelpMessageOpt(
"-salvagewallet",
_(
"Attempt to recover private keys from a corrupt wallet on startup"));
32 strUsage +=
HelpMessageOpt(
"-spendzeroconfchange",
strprintf(
_(
"Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE));
33 strUsage +=
HelpMessageOpt(
"-txconfirmtarget=<n>",
strprintf(
_(
"If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET));
34 strUsage +=
HelpMessageOpt(
"-walletrbf",
strprintf(
_(
"Send transactions with full-RBF opt-in enabled (default: %u)"), DEFAULT_WALLET_RBF));
35 strUsage +=
HelpMessageOpt(
"-upgradewallet",
_(
"Upgrade wallet to latest format on startup"));
37 strUsage +=
HelpMessageOpt(
"-walletbroadcast",
_(
"Make the wallet broadcast transactions") +
" " +
strprintf(
_(
"(default: %u)"), DEFAULT_WALLETBROADCAST));
38 strUsage +=
HelpMessageOpt(
"-walletnotify=<cmd>",
_(
"Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)"));
39 strUsage +=
HelpMessageOpt(
"-zapwallettxes=<mode>",
_(
"Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") +
40 " " +
_(
"(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)"));
46 strUsage +=
HelpMessageOpt(
"-dblogsize=<n>",
strprintf(
"Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE));
47 strUsage +=
HelpMessageOpt(
"-flushwallet",
strprintf(
"Run a thread to flush wallet periodically (default: %u)", DEFAULT_FLUSHWALLET));
48 strUsage +=
HelpMessageOpt(
"-privdb",
strprintf(
"Sets the DB_PRIVATE flag in the wallet db environment (default: %u)", DEFAULT_WALLET_PRIVDB));
49 strUsage +=
HelpMessageOpt(
"-walletrejectlongchains",
strprintf(
_(
"Wallet will not create transactions that violate mempool chain limits (default: %u)"), DEFAULT_WALLET_REJECT_LONG_CHAINS));
58 const bool is_multiwallet =
gArgs.
GetArgs(
"-wallet").size() > 1;
64 LogPrintf(
"%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
69 return InitError(
strprintf(
"%s is only allowed with a single wallet file",
"-salvagewallet"));
73 LogPrintf(
"%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
77 int zapwallettxes =
gArgs.
GetArg(
"-zapwallettxes", 0);
80 LogPrintf(
"%s: parameter interaction: -zapwallettxes=%s -> setting -persistmempool=0\n", __func__, zapwallettxes);
84 if (zapwallettxes != 0) {
86 return InitError(
strprintf(
"%s is only allowed with a single wallet file",
"-zapwallettxes"));
89 LogPrintf(
"%s: parameter interaction: -zapwallettxes=%s -> setting -rescan=1\n", __func__, zapwallettxes);
95 return InitError(
strprintf(
"%s is only allowed with a single wallet file",
"-upgradewallet"));
100 return InitError(
"-sysperms is not allowed in combination with enabled wallet functionality");
102 return InitError(
_(
"Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again."));
106 _(
"The wallet will avoid paying less than the minimum relay fee."));
113 if (n > HIGH_TX_FEE_PER_KB)
115 _(
"This is the minimum transaction fee you pay on every transaction."));
123 if (nFeePerK > HIGH_TX_FEE_PER_KB)
125 _(
"This is the transaction fee you may pay when fee estimates are not available."));
133 if (nFeePerK > HIGH_TX_FEE_PER_KB)
135 _(
"This is the transaction fee you may discard if change is smaller than dust at this level"));
143 if (nFeePerK > HIGH_TX_FEE_PER_KB)
145 _(
"This is the transaction fee you will pay if you send a transaction."));
150 return InitError(
strprintf(
_(
"Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)"),
159 if (nMaxFee > HIGH_MAX_TX_FEE)
160 InitWarning(
_(
"-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
164 return InitError(
strprintf(
_(
"Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"),
190 std::set<fs::path> wallet_paths;
192 for (
const std::string& walletFile :
gArgs.
GetArgs(
"-wallet")) {
193 if (boost::filesystem::path(walletFile).filename() != walletFile) {
194 return InitError(
strprintf(
_(
"Error loading wallet %s. -wallet parameter must only specify a filename (not a path)."), walletFile));
198 return InitError(
strprintf(
_(
"Error loading wallet %s. Invalid characters in -wallet filename."), walletFile));
201 fs::path wallet_path = fs::absolute(walletFile,
GetDataDir());
203 if (fs::exists(wallet_path) && (!fs::is_regular_file(wallet_path) || fs::is_symlink(wallet_path))) {
204 return InitError(
strprintf(
_(
"Error loading wallet %s. -wallet filename must be a regular file."), walletFile));
207 if (!wallet_paths.insert(wallet_path).second) {
208 return InitError(
strprintf(
_(
"Error loading wallet %s. Duplicate -wallet filename specified."), walletFile));
211 std::string strError;
219 std::string backup_filename;
225 std::string strWarning;
227 if (!strWarning.empty()) {
246 for (
const std::string& walletFile :
gArgs.
GetArgs(
"-wallet")) {
259 pwallet->postInitProcess(scheduler);
265 pwallet->Flush(
false);
271 pwallet->Flush(
true);
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
const char * DEFAULT_WALLET_DAT
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Raven RPC command dispatcher.
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
CAmount maxTxFee
Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendra...
bool bSpendZeroConfChange
bool OpenWallets()
Load wallet databases.
void CloseWallets()
Close all wallets.
std::vector< CWalletRef > vpwallets
const std::string CURRENCY_UNIT
std::string GetWalletHelpString(bool showDebug)
Return the wallets help message.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
void StopWallets()
Stop all wallets. Wallets will be flushed first.
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
static bool RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
int64_t CAmount
Amount in corbies (Can be negative)
unsigned int nTxConfirmTarget
static CFeeRate m_discard_rate
static bool VerifyEnvironment(const std::string &walletFile, const fs::path &dataDir, std::string &errorStr)
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
void RegisterWalletRPC(CRPCTable &t)
Register wallet RPCs.
static bool VerifyDatabaseFile(const std::string &walletFile, const fs::path &dataDir, std::string &warningStr, std::string &errorStr)
Chars allowed in filenames.
bool ParseMoney(const std::string &str, CAmount &nRet)
static bool Recover(const std::string &filename, void *callbackDataIn, bool(*recoverKVcallback)(void *callbackData, CDataStream ssKey, CDataStream ssValue), std::string &out_backup_filename)
bool WalletParameterInteraction()
Wallets parameter interaction.
std::string AmountHighWarn(const std::string &optname)
static CWallet * CreateWalletFromFile(const std::string walletFile)
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
void RegisterWalletRPCCommands(CRPCTable &t)
bool InitError(const std::string &str)
Show error message.
static CFeeRate fallbackFee
If fee estimation does not have enough data to provide estimates, use this fee instead.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
static CFeeRate minTxFee
Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) Override with ...
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Fee rate in satoshis per kilobyte: CAmount / kB.
void FlushWallets()
Flush all wallets in preparation for shutdown.
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE)
Transaction fee set by the user.
const fs::path & GetDataDir(bool fNetSpecific)
void StartWallets(CScheduler &scheduler)
Complete startup of wallets.
std::string ToString() const
void InitWarning(const std::string &str)
Show warning message.
CClientUIInterface uiInterface
bool VerifyWallets()
Responsible for reading and validating the -wallet arguments and verifying the wallet database...
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
std::string AmountErrMsg(const char *const optname, const std::string &strValue)
std::string SanitizeString(const std::string &str, int rule)
Remove unsafe chars.
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.