Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

init.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2017 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include <init.h>
7 #include <keepass.h>
8 #include <net.h>
9 #include <scheduler.h>
10 #include <util.h>
11 #include <utilmoneystr.h>
12 #include <validation.h>
13 #include <walletinitinterface.h>
14 #include <wallet/rpcwallet.h>
15 #include <wallet/wallet.h>
16 #include <wallet/walletutil.h>
17 
19 
20 #include <functional>
21 
23 public:
24 
26  std::string GetHelpString(bool showDebug) override;
27 
29  bool ParameterInteraction() override;
30 
32  void RegisterRPC(CRPCTable &tableRPC) override;
33 
35  // This function will perform salvage on the wallet if requested, as long as only one wallet is
36  // being loaded (WalletParameterInteraction forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet).
37  bool Verify() override;
38 
40  bool Open() override;
41 
43  void Start(CScheduler& scheduler) override;
44 
46  void Flush() override;
47 
49  void Stop() override;
50 
52  void Close() override;
53 
54  // Dash Specific Wallet Init
55  void AutoLockMasternodeCollaterals() override;
56  void InitPrivateSendSettings() override;
57  void InitKeePass() override;
58  bool InitAutoBackup() override;
59 };
60 
63 
64 std::string WalletInit::GetHelpString(bool showDebug)
65 {
66  std::string strUsage = HelpMessageGroup(_("Wallet options:"));
67  strUsage += HelpMessageOpt("-disablewallet", _("Do not load the wallet and disable wallet RPC calls"));
68  strUsage += HelpMessageOpt("-keypool=<n>", strprintf(_("Set key pool size to <n> (default: %u)"), DEFAULT_KEYPOOL_SIZE));
69  strUsage += HelpMessageOpt("-fallbackfee=<amt>", strprintf(_("A fee rate (in %s/kB) that will be used when fee estimation has insufficient data (default: %s)"),
71  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). "
72  "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"),
74  strUsage += HelpMessageOpt("-mintxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)"),
76  strUsage += HelpMessageOpt("-paytxfee=<amt>", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"),
78  strUsage += HelpMessageOpt("-rescan", _("Rescan the block chain for missing wallet transactions on startup"));
79  strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet on startup"));
80  strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE));
81  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));
82  strUsage += HelpMessageOpt("-usehd", _("Use hierarchical deterministic key generation (HD) after BIP39/BIP44. Only has effect during wallet creation/first start") + " " + strprintf(_("(default: %u)"), DEFAULT_USE_HD_WALLET));
83  strUsage += HelpMessageOpt("-mnemonic=<text>", _("User defined mnemonic for HD wallet (bip39). Only has effect during wallet creation/first start (default: randomly generated)"));
84  strUsage += HelpMessageOpt("-mnemonicpassphrase=<text>", _("User defined mnemonic passphrase for HD wallet (BIP39). Only has effect during wallet creation/first start (default: empty string)"));
85  strUsage += HelpMessageOpt("-hdseed=<hex>", _("User defined seed for HD wallet (should be in hex). Only has effect during wallet creation/first start (default: randomly generated)"));
86  strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format on startup"));
87  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>.)"));
88  strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), DEFAULT_WALLETBROADCAST));
89  strUsage += HelpMessageOpt("-walletdir=<dir>", _("Specify directory to hold wallets (default: <datadir>/wallets if it exists, otherwise <datadir>)"));
90  strUsage += HelpMessageOpt("-walletnotify=<cmd>", _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)"));
91  strUsage += HelpMessageOpt("-zapwallettxes=<mode>", _("Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") +
92  " " + _("(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)"));
93  strUsage += HelpMessageOpt("-createwalletbackups=<n>", strprintf(_("Number of automatic wallet backups (default: %u)"), nWalletBackups));
94  strUsage += HelpMessageOpt("-walletbackupsdir=<dir>", _("Specify full path to directory for automatic wallet backups (must exist)"));
95  strUsage += HelpMessageOpt("-keepass", strprintf(_("Use KeePass 2 integration using KeePassHttp plugin (default: %u)"), 0));
96  strUsage += HelpMessageOpt("-keepassport=<port>", strprintf(_("Connect to KeePassHttp on port <port> (default: %u)"), DEFAULT_KEEPASS_HTTP_PORT));
97  strUsage += HelpMessageOpt("-keepasskey=<key>", _("KeePassHttp key for AES encrypted communication with KeePass"));
98  strUsage += HelpMessageOpt("-keepassid=<id>", _("KeePassHttp id for the established association"));
99  strUsage += HelpMessageOpt("-keepassname=<name>", _("Name to construct url for KeePass entry that stores the wallet passphrase"));
100 
101  strUsage += HelpMessageGroup(_("PrivateSend options:"));
102  strUsage += HelpMessageOpt("-enableprivatesend", strprintf(_("Enable use of PrivateSend for funds stored in this wallet (0-1, default: %u)"), 0));
103  strUsage += HelpMessageOpt("-privatesendautostart", strprintf(_("Start PrivateSend automatically (0-1, default: %u)"), DEFAULT_PRIVATESEND_AUTOSTART));
104  strUsage += HelpMessageOpt("-privatesendmultisession", strprintf(_("Enable multiple PrivateSend mixing sessions per block, experimental (0-1, default: %u)"), DEFAULT_PRIVATESEND_MULTISESSION));
105  strUsage += HelpMessageOpt("-privatesendsessions=<n>", strprintf(_("Use N separate masternodes in parallel to mix funds (%u-%u, default: %u)"), MIN_PRIVATESEND_SESSIONS, MAX_PRIVATESEND_SESSIONS, DEFAULT_PRIVATESEND_SESSIONS));
106  strUsage += HelpMessageOpt("-privatesendrounds=<n>", strprintf(_("Use N separate masternodes for each denominated input to mix funds (%u-%u, default: %u)"), MIN_PRIVATESEND_ROUNDS, MAX_PRIVATESEND_ROUNDS, DEFAULT_PRIVATESEND_ROUNDS));
107  strUsage += HelpMessageOpt("-privatesendamount=<n>", strprintf(_("Target PrivateSend balance (%u-%u, default: %u)"), MIN_PRIVATESEND_AMOUNT, MAX_PRIVATESEND_AMOUNT, DEFAULT_PRIVATESEND_AMOUNT));
108  strUsage += HelpMessageOpt("-privatesenddenomsgoal=<n>", strprintf(_("Try to create at least N inputs of each denominated amount (%u-%u, default: %u)"), MIN_PRIVATESEND_DENOMS_GOAL, MAX_PRIVATESEND_DENOMS_GOAL, DEFAULT_PRIVATESEND_DENOMS_GOAL));
109  strUsage += HelpMessageOpt("-privatesenddenomshardcap=<n>", strprintf(_("Create up to N inputs of each denominated amount (%u-%u, default: %u)"), MIN_PRIVATESEND_DENOMS_HARDCAP, MAX_PRIVATESEND_DENOMS_HARDCAP, DEFAULT_PRIVATESEND_DENOMS_HARDCAP));
110 
111  if (showDebug)
112  {
113  strUsage += HelpMessageGroup(_("Wallet debugging/testing options:"));
114 
115  strUsage += HelpMessageOpt("-dblogsize=<n>", strprintf("Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE));
116  strUsage += HelpMessageOpt("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", DEFAULT_FLUSHWALLET));
117  strUsage += HelpMessageOpt("-privdb", strprintf("Sets the DB_PRIVATE flag in the wallet db environment (default: %u)", DEFAULT_WALLET_PRIVDB));
118  strUsage += HelpMessageOpt("-walletrejectlongchains", strprintf(_("Wallet will not create transactions that violate mempool chain limits (default: %u)"), DEFAULT_WALLET_REJECT_LONG_CHAINS));
119  }
120 
121  return strUsage;
122 }
123 
125 {
126  if (gArgs.IsArgSet("-masternodeblsprivkey") && gArgs.SoftSetBoolArg("-disablewallet", true)) {
127  LogPrintf("%s: parameter interaction: -masternodeblsprivkey set -> setting -disablewallet=1\n", __func__);
128  }
129 
130  if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
131  for (const std::string& wallet : gArgs.GetArgs("-wallet")) {
132  LogPrintf("%s: parameter interaction: -disablewallet -> ignoring -wallet=%s\n", __func__, wallet);
133  }
134 
135  return true;
136  } else if (gArgs.IsArgSet("-masternodeblsprivkey")) {
137  return InitError(_("You can not start a masternode with wallet enabled."));
138  }
139 
140  gArgs.SoftSetArg("-wallet", "");
141  const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1;
142 
143  if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && gArgs.SoftSetBoolArg("-walletbroadcast", false)) {
144  LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
145  }
146 
147  if (gArgs.GetBoolArg("-salvagewallet", false)) {
148  if (is_multiwallet) {
149  return InitError(strprintf("%s is only allowed with a single wallet file", "-salvagewallet"));
150  }
151  // Rewrite just private keys: rescan to find transactions
152  if (gArgs.SoftSetBoolArg("-rescan", true)) {
153  LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
154  }
155  }
156 
157  int zapwallettxes = gArgs.GetArg("-zapwallettxes", 0);
158  // -zapwallettxes implies dropping the mempool on startup
159  if (zapwallettxes != 0 && gArgs.SoftSetBoolArg("-persistmempool", false)) {
160  LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -persistmempool=0\n", __func__, zapwallettxes);
161  }
162 
163  // -zapwallettxes implies a rescan
164  if (zapwallettxes != 0) {
165  if (is_multiwallet) {
166  return InitError(strprintf("%s is only allowed with a single wallet file", "-zapwallettxes"));
167  }
168  if (gArgs.SoftSetBoolArg("-rescan", true)) {
169  LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -rescan=1\n", __func__, zapwallettxes);
170  }
171  }
172 
173  if (is_multiwallet) {
174  if (gArgs.GetBoolArg("-upgradewallet", false)) {
175  return InitError(strprintf("%s is only allowed with a single wallet file", "-upgradewallet"));
176  }
177  }
178 
179  if (gArgs.GetBoolArg("-sysperms", false))
180  return InitError("-sysperms is not allowed in combination with enabled wallet functionality");
181  if (gArgs.GetArg("-prune", 0) && gArgs.GetBoolArg("-rescan", false))
182  return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again."));
183 
185  InitWarning(AmountHighWarn("-minrelaytxfee") + " " +
186  _("The wallet will avoid paying less than the minimum relay fee."));
187 
188  if (gArgs.IsArgSet("-mintxfee"))
189  {
190  CAmount n = 0;
191  if (!ParseMoney(gArgs.GetArg("-mintxfee", ""), n) || 0 == n)
192  return InitError(AmountErrMsg("mintxfee", gArgs.GetArg("-mintxfee", "")));
193  if (n > HIGH_TX_FEE_PER_KB)
194  InitWarning(AmountHighWarn("-mintxfee") + " " +
195  _("This is the minimum transaction fee you pay on every transaction."));
197  }
198  if (gArgs.IsArgSet("-fallbackfee"))
199  {
200  CAmount nFeePerK = 0;
201  if (!ParseMoney(gArgs.GetArg("-fallbackfee", ""), nFeePerK))
202  return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), gArgs.GetArg("-fallbackfee", "")));
203  if (nFeePerK > HIGH_TX_FEE_PER_KB)
204  InitWarning(AmountHighWarn("-fallbackfee") + " " +
205  _("This is the transaction fee you may pay when fee estimates are not available."));
206  CWallet::fallbackFee = CFeeRate(nFeePerK);
207  }
208  if (gArgs.IsArgSet("-discardfee"))
209  {
210  CAmount nFeePerK = 0;
211  if (!ParseMoney(gArgs.GetArg("-discardfee", ""), nFeePerK))
212  return InitError(strprintf(_("Invalid amount for -discardfee=<amount>: '%s'"), gArgs.GetArg("-discardfee", "")));
213  if (nFeePerK > HIGH_TX_FEE_PER_KB)
214  InitWarning(AmountHighWarn("-discardfee") + " " +
215  _("This is the transaction fee you may discard if change is smaller than dust at this level"));
216  CWallet::m_discard_rate = CFeeRate(nFeePerK);
217  }
218  if (gArgs.IsArgSet("-paytxfee"))
219  {
220  CAmount nFeePerK = 0;
221  if (!ParseMoney(gArgs.GetArg("-paytxfee", ""), nFeePerK))
222  return InitError(AmountErrMsg("paytxfee", gArgs.GetArg("-paytxfee", "")));
223  if (nFeePerK > HIGH_TX_FEE_PER_KB)
224  InitWarning(AmountHighWarn("-paytxfee") + " " +
225  _("This is the transaction fee you will pay if you send a transaction."));
226 
227  payTxFee = CFeeRate(nFeePerK, 1000);
228  if (payTxFee < ::minRelayTxFee)
229  {
230  return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)"),
231  gArgs.GetArg("-paytxfee", ""), ::minRelayTxFee.ToString()));
232  }
233  }
234  if (gArgs.IsArgSet("-maxtxfee"))
235  {
236  CAmount nMaxFee = 0;
237  if (!ParseMoney(gArgs.GetArg("-maxtxfee", ""), nMaxFee))
238  return InitError(AmountErrMsg("maxtxfee", gArgs.GetArg("-maxtxfee", "")));
239  if (nMaxFee > HIGH_MAX_TX_FEE)
240  InitWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
241  maxTxFee = nMaxFee;
242  if (CFeeRate(maxTxFee, 1000) < ::minRelayTxFee)
243  {
244  return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"),
245  gArgs.GetArg("-maxtxfee", ""), ::minRelayTxFee.ToString()));
246  }
247  }
250 
251  if (gArgs.IsArgSet("-walletbackupsdir")) {
252  if (!fs::is_directory(gArgs.GetArg("-walletbackupsdir", ""))) {
253  LogPrintf("%s: Warning: incorrect parameter -walletbackupsdir, path must exist! Using default path.\n", __func__);
254  InitWarning("Warning: incorrect parameter -walletbackupsdir, path must exist! Using default path.\n");
255 
256  gArgs.ForceRemoveArg("-walletbackupsdir");
257  }
258  }
259 
260  if (gArgs.IsArgSet("-hdseed") && IsHex(gArgs.GetArg("-hdseed", "not hex")) && (gArgs.IsArgSet("-mnemonic") || gArgs.IsArgSet("-mnemonicpassphrase"))) {
261  gArgs.ForceRemoveArg("-mnemonic");
262  gArgs.ForceRemoveArg("-mnemonicpassphrase");
263  LogPrintf("%s: parameter interaction: can't use -hdseed and -mnemonic/-mnemonicpassphrase together, will prefer -seed\n", __func__);
264  }
265 
266  if (gArgs.IsArgSet("-privatesenddenoms")) {
267  int nDenomsDeprecated = gArgs.GetArg("-privatesenddenoms", DEFAULT_PRIVATESEND_DENOMS_HARDCAP);
268  InitWarning("Warning: -privatesenddenoms is deprecated, please use -privatesenddenomshardcap or -privatesenddenomsgoal.\n");
269  if (gArgs.SoftSetArg("-privatesenddenomshardcap", itostr(nDenomsDeprecated))) {
270  LogPrintf("%s: parameter interaction: -privatesenddenoms=%d -> setting -privatesenddenomshardcap=%d\n", __func__, nDenomsDeprecated, nDenomsDeprecated);
271  }
272  gArgs.ForceRemoveArg("-privatesenddenoms");
273  }
274 
275  if (gArgs.GetArg("-privatesenddenomshardcap", DEFAULT_PRIVATESEND_DENOMS_HARDCAP) < gArgs.GetArg("-privatesenddenomsgoal", DEFAULT_PRIVATESEND_DENOMS_GOAL)) {
276  return InitError("-privatesenddenomshardcap can't be lower than -privatesenddenomsgoal");
277  }
278 
279  return true;
280 }
281 
283 {
284  if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
285  return;
286  }
287 
289 }
290 
292 {
293  if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
294  return true;
295  }
296 
297  if (gArgs.IsArgSet("-walletdir")) {
298  fs::path wallet_dir = gArgs.GetArg("-walletdir", "");
299  if (!fs::exists(wallet_dir)) {
300  return InitError(strprintf(_("Specified -walletdir \"%s\" does not exist"), wallet_dir.string()));
301  } else if (!fs::is_directory(wallet_dir)) {
302  return InitError(strprintf(_("Specified -walletdir \"%s\" is not a directory"), wallet_dir.string()));
303  } else if (!wallet_dir.is_absolute()) {
304  return InitError(strprintf(_("Specified -walletdir \"%s\" is a relative path"), wallet_dir.string()));
305  }
306  }
307 
308  LogPrintf("Using wallet directory %s\n", GetWalletDir().string());
309 
310  uiInterface.InitMessage(_("Verifying wallet(s)..."));
311 
312  std::vector<std::string> wallet_files = gArgs.GetArgs("-wallet");
313 
314  // Parameter interaction code should have thrown an error if -salvagewallet
315  // was enabled with more than wallet file, so the wallet_files size check
316  // here should have no effect.
317  bool salvage_wallet = gArgs.GetBoolArg("-salvagewallet", false) && wallet_files.size() <= 1;
318 
319  // Keep track of each wallet absolute path to detect duplicates.
320  std::set<fs::path> wallet_paths;
321 
322  for (const auto wallet_file : wallet_files) {
323  fs::path wallet_path = fs::absolute(wallet_file, GetWalletDir());
324 
325  if (!wallet_paths.insert(wallet_path).second) {
326  return InitError(strprintf(_("Error loading wallet %s. Duplicate -wallet filename specified."), wallet_file));
327  }
328 
329  std::string error_string;
330  std::string warning_string;
331  bool verify_success = CWallet::Verify(wallet_file, salvage_wallet, error_string, warning_string);
332  if (!error_string.empty()) InitError(error_string);
333  if (!warning_string.empty()) InitWarning(warning_string);
334  if (!verify_success) return false;
335  }
336 
337  return true;
338 }
339 
341 {
342  if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
343  LogPrintf("Wallet disabled!\n");
344  return true;
345  }
346 
347  for (const std::string& walletFile : gArgs.GetArgs("-wallet")) {
348  CWallet * const pwallet = CWallet::CreateWalletFromFile(walletFile, fs::absolute(walletFile, GetWalletDir()));
349  if (!pwallet) {
350  return false;
351  }
352  AddWallet(pwallet);
353  }
354 
355  return true;
356 }
357 
359 {
360  for (CWallet* pwallet : GetWallets()) {
361  pwallet->postInitProcess();
362  }
363 
364  // Run a thread to flush wallet periodically
366 
369  std::ref(*g_connman)), 1 * 1000);
370  }
371 }
372 
374 {
376  // Stop PrivateSend, release keys
379  }
380  for (CWallet* pwallet : GetWallets()) {
381  pwallet->Flush(false);
382  }
383 }
384 
386 {
387  for (CWallet* pwallet : GetWallets()) {
388  pwallet->Flush(true);
389  }
390 }
391 
393 {
394  for (CWallet* pwallet : GetWallets()) {
395  RemoveWallet(pwallet);
396  delete pwallet;
397  }
398 }
399 
401 {
402  // we can't do this before DIP3 is fully initialized
403  for (CWallet* pwallet : GetWallets()) {
404  pwallet->AutoLockMasternodeCollaterals();
405  }
406 }
407 
409 {
410  if (!HasWallets()) {
412  } else {
413  privateSendClient.fEnablePrivateSend = gArgs.GetBoolArg("-enableprivatesend", true);
415  }
422 
424  LogPrintf("PrivateSend: autostart=%d, multisession=%d," /* Continued */
425  "sessions=%d, rounds=%d, amount=%d, denoms_goal=%d, denoms_hardcap=%d\n",
430  }
431 
432 }
433 
435 {
436  keePassInt.init();
437 }
438 
440 {
441  return CWallet::InitAutoBackup();
442 }
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
Definition: util.cpp:884
static const bool DEFAULT_PRIVATESEND_AUTOSTART
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
Definition: wallet.h:70
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Definition: util.cpp:784
static const unsigned int DEFAULT_TX_CONFIRM_TARGET
-txconfirmtarget default
Definition: wallet.h:74
static const CAmount DEFAULT_DISCARD_FEE
-m_discard_rate default
Definition: wallet.h:60
static bool Verify(std::string wallet_file, bool salvage_wallet, std::string &error_string, std::string &warning_string)
Verify wallet naming and perform salvage on the wallet if required.
Definition: wallet.cpp:5024
Dash RPC command dispatcher.
Definition: server.h:140
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn&#39;t already have a value.
Definition: util.cpp:840
static const unsigned int DEFAULT_KEEPASS_HTTP_PORT
Definition: keepass.h:14
static const int DEFAULT_PRIVATESEND_DENOMS_HARDCAP
#define strprintf
Definition: tinyformat.h:1066
CAmount maxTxFee
Absolute maximum transaction fee (in duffs) used by wallet and mempool (rejects high fee in sendrawtr...
Definition: validation.cpp:247
WalletInitInterface *const g_wallet_init_interface
Definition: init.cpp:122
bool RemoveWallet(CWallet *wallet)
Definition: wallet.cpp:63
bool bSpendZeroConfChange
Definition: wallet.cpp:97
static const int DEFAULT_PRIVATESEND_AMOUNT
static const bool DEFAULT_WALLETBROADCAST
Definition: wallet.h:75
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:76
static const CAmount DEFAULT_TRANSACTION_MINFEE
-mintxfee default
Definition: wallet.h:62
void InitKeePass() override
Definition: init.cpp:434
void scheduleEvery(Function f, int64_t deltaMilliSeconds)
Definition: scheduler.cpp:126
const std::string CURRENCY_UNIT
Definition: feerate.cpp:10
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: util.cpp:824
static CWallet * CreateWalletFromFile(const std::string &name, const fs::path &path)
Definition: wallet.cpp:5075
void RegisterRPC(CRPCTable &tableRPC) override
Register wallet RPCs.
Definition: init.cpp:282
static CScheduler scheduler
Definition: init.cpp:213
static const int MAX_PRIVATESEND_DENOMS_HARDCAP
bool Verify() override
Responsible for reading and validating the -wallet arguments and verifying the wallet database...
Definition: init.cpp:291
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn&#39;t already have a value.
Definition: util.cpp:832
static const unsigned int DEFAULT_KEYPOOL_SIZE
Definition: wallet.h:54
static WalletInit g_wallet_init
Definition: init.cpp:61
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS
Default for -walletrejectlongchains.
Definition: wallet.h:72
std::vector< CWallet * > GetWallets()
Definition: wallet.cpp:79
bool fMasternodeMode
Definition: util.cpp:93
false
Definition: bls_dkg.cpp:168
CRPCTable tableRPC
Definition: server.cpp:616
unsigned int nTxConfirmTarget
Definition: wallet.cpp:96
static const int DEFAULT_PRIVATESEND_ROUNDS
int nWalletBackups
nWalletBackups: 1..10 - number of automatic backups to keep 0 - disabled by command-line -1 - disable...
Definition: util.cpp:102
#define LogPrintf(...)
Definition: util.h:203
static CFeeRate m_discard_rate
Definition: wallet.h:1107
fs::path GetWalletDir()
Get the path of the wallet directory.
Definition: walletutil.cpp:7
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
Definition: validation.cpp:246
static const int DEFAULT_PRIVATESEND_SESSIONS
bool IsHex(const std::string &str)
bool AddWallet(CWallet *wallet)
Definition: wallet.cpp:53
void MaybeCompactWalletDB()
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
Definition: walletdb.cpp:789
static const bool DEFAULT_USE_HD_WALLET
if set, all keys will be derived by using BIP39/BIP44
Definition: wallet.h:81
bool ParseMoney(const std::string &str, CAmount &nRet)
void InitPrivateSendSettings() override
Definition: init.cpp:408
bool Open() override
Load wallet databases.
Definition: init.cpp:340
static const int MAX_PRIVATESEND_ROUNDS
std::string AmountHighWarn(const std::string &optname)
static const unsigned int DEFAULT_WALLET_DBLOGSIZE
Definition: db.h:25
void Close() override
Close all wallets.
Definition: init.cpp:392
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
void ForceRemoveArg(const std::string &strArg)
Definition: util.cpp:854
static const int MAX_PRIVATESEND_AMOUNT
void RegisterWalletRPCCommands(CRPCTable &t)
Definition: rpcwallet.cpp:3588
static const int MAX_PRIVATESEND_SESSIONS
ArgsManager gArgs
Definition: util.cpp:108
static bool InitAutoBackup()
Definition: wallet.cpp:5309
bool InitError(const std::string &str)
Show error message.
CPrivateSendClientManager privateSendClient
static CFeeRate fallbackFee
If fee estimation does not have enough data to provide estimates, use this fee instead.
Definition: wallet.h:1106
static const int DEFAULT_PRIVATESEND_DENOMS_GOAL
CKeePassIntegrator keePassInt
Definition: keepass.cpp:33
void Start(CScheduler &scheduler) override
Complete startup of wallets.
Definition: init.cpp:358
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: util.cpp:808
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
Definition: walletdb.h:32
static const int MIN_PRIVATESEND_DENOMS_GOAL
void DoMaintenance(CConnman &connman)
static const CAmount HIGH_TX_FEE_PER_KB
Discourage users to set fees higher than this amount (in duffs) per kB.
Definition: validation.h:60
static const int MIN_PRIVATESEND_DENOMS_HARDCAP
static const int MIN_PRIVATESEND_ROUNDS
static CFeeRate minTxFee
Fees smaller than this (in duffs) are considered zero fee (for transaction creation) Override with -m...
Definition: wallet.h:1105
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:715
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:19
std::unique_ptr< CConnman > g_connman
Definition: init.cpp:97
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE)
Transaction fee set by the user.
static const bool DEFAULT_BLOCKSONLY
Default for blocks only.
Definition: net.h:92
static const int MAX_PRIVATESEND_DENOMS_GOAL
static const int MIN_PRIVATESEND_SESSIONS
static const bool DEFAULT_WALLET_PRIVDB
Definition: db.h:26
std::string ToString() const
Definition: feerate.cpp:40
void InitWarning(const std::string &str)
Show warning message.
CClientUIInterface uiInterface
Definition: ui_interface.cpp:8
bool ParameterInteraction() override
Wallets parameter interaction.
Definition: init.cpp:124
static const int MIN_PRIVATESEND_AMOUNT
bool InitAutoBackup() override
Definition: init.cpp:439
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
Definition: util.cpp:765
void AutoLockMasternodeCollaterals() override
Definition: init.cpp:400
bool HasWallets()
Definition: wallet.cpp:73
std::string AmountErrMsg(const char *const optname, const std::string &strValue)
std::string GetHelpString(bool showDebug) override
Return the wallets help message.
Definition: init.cpp:64
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
Definition: util.cpp:880
static const bool DEFAULT_PRIVATESEND_MULTISESSION
static const CAmount DEFAULT_FALLBACK_FEE
-fallbackfee default
Definition: wallet.h:58
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
Definition: feerate.h:41
void Flush() override
Flush all wallets in preparation for shutdown.
Definition: init.cpp:373
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
Definition: util.h:92
std::string itostr(int n)
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
Definition: ui_interface.h:82
static const CAmount HIGH_MAX_TX_FEE
-maxtxfee will warn if called with a higher fee than this amount (in duffs)
Definition: validation.h:62
void Stop() override
Stop all wallets. Wallets will be flushed first.
Definition: init.cpp:385
Released under the MIT license