Bitcoin ABC  0.26.3
P2P Digital Currency
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2017 The Bitcoin Core developers
3 // Copyright (c) 2018-2020 The Bitcoin developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or
7 #include <config.h>
8 #include <init.h>
9 #include <interfaces/chain.h>
10 #include <interfaces/wallet.h>
11 #include <net.h>
12 #include <node/context.h>
13 #include <node/ui_interface.h>
14 #include <univalue.h>
15 #include <util/check.h>
16 #include <util/moneystr.h>
17 #include <util/system.h>
18 #include <util/translation.h>
19 #include <wallet/coincontrol.h>
20 #include <wallet/rpc/backup.h>
21 #include <wallet/wallet.h>
22 #include <walletinitinterface.h>
24 using node::NodeContext;
27 public:
29  bool HasWalletSupport() const override { return true; }
32  void AddWalletOptions(ArgsManager &argsman) const override;
35  bool ParameterInteraction() const override;
38  void Construct(NodeContext &node) const override;
39 };
44  argsman.AddArg(
45  "-avoidpartialspends",
46  strprintf("Group outputs by address, selecting all or none, instead of "
47  "selecting on a per-output basis. Privacy is improved as an "
48  "address is only used once (unless someone sends to it after "
49  "spending from it), but may result in slightly higher fees "
50  "as suboptimal coin selection may result due to the added "
51  "limitation (default: %u (always enabled for wallets with "
52  "\"avoid_reuse\" enabled))",
56  argsman.AddArg("-disablewallet",
57  "Do not load the wallet and disable wallet RPC calls",
59  const auto &ticker = Currency::get().ticker;
60  argsman.AddArg("-fallbackfee=<amt>",
61  strprintf("A fee rate (in %s/kB) that will be used when fee "
62  "estimation has insufficient data. 0 to entirely "
63  "disable the fallbackfee feature. (default: %s)",
66  argsman.AddArg(
67  "-keypool=<n>",
68  strprintf("Set key pool size to <n> (default: %u). Warning: Smaller "
69  "sizes may increase the risk of losing funds when restoring "
70  "from an old backup, if none of the addresses in the "
71  "original keypool have been used.",
74  argsman.AddArg(
75  "-maxapsfee=<n>",
76  strprintf(
77  "Spend up to this amount in additional (absolute) fees (in %s) if "
78  "it allows the use of partial spend avoidance (default: %s)",
81  argsman.AddArg(
82  "-maxtxfee=<amt>",
83  strprintf("Maximum total fees (in %s) to use in a single wallet "
84  "transaction or raw transaction; setting this too low may "
85  "abort large transactions (default: %s)",
88  argsman.AddArg("-mintxfee=<amt>",
89  strprintf("Fees (in %s/kB) smaller than this are considered "
90  "zero fee for transaction creation (default: %s)",
91  ticker,
94  argsman.AddArg(
95  "-paytxfee=<amt>",
96  strprintf(
97  "Fee (in %s/kB) to add to transactions you send (default: %s)",
98  ticker, FormatMoney(CFeeRate{DEFAULT_PAY_TX_FEE}.GetFeePerK())),
100  argsman.AddArg(
101  "-rescan",
102  "Rescan the block chain for missing wallet transactions on startup",
104  argsman.AddArg(
105  "-spendzeroconfchange",
106  strprintf(
107  "Spend unconfirmed change when sending transactions (default: %d)",
110  argsman.AddArg(
111  "-wallet=<path>",
112  "Specify wallet database path. Can be specified multiple "
113  "times to load multiple wallets. Path is interpreted relative "
114  "to <walletdir> if it is not absolute, and will be created if "
115  "it does not exist (as a directory containing a wallet.dat "
116  "file and log files). For backwards compatibility this will "
117  "also accept names of existing data files in <walletdir>.)",
120  argsman.AddArg(
121  "-walletbroadcast",
122  strprintf("Make the wallet broadcast transactions (default: %d)",
125  argsman.AddArg("-walletdir=<dir>",
126  "Specify directory to hold wallets (default: "
127  "<datadir>/wallets if it exists, otherwise <datadir>)",
130 #if defined(HAVE_SYSTEM)
131  argsman.AddArg(
132  "-walletnotify=<cmd>",
133  "Execute command when a wallet transaction changes. %s in cmd "
134  "is replaced by TxID and %w is replaced by wallet name. %w is "
135  "not currently implemented on windows. On systems where %w is "
136  "supported, it should NOT be quoted because this would break "
137  "shell escaping used to invoke the command.",
139 #endif
140  argsman.AddArg(
141  "-dblogsize=<n>",
142  strprintf("Flush wallet database activity from memory to disk "
143  "log every <n> megabytes (default: %u)",
147  argsman.AddArg(
148  "-flushwallet",
149  strprintf("Run a thread to flush wallet periodically (default: %d)",
153  argsman.AddArg("-privdb",
154  strprintf("Sets the DB_PRIVATE flag in the wallet db "
155  "environment (default: %d)",
159  argsman.AddArg("-walletrejectlongchains",
160  strprintf("Wallet will not create transactions that violate "
161  "mempool chain limits (default: %d)",
166  argsman.AddHiddenArgs({"-zapwallettxes"});
167 }
170  if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
171  for (const std::string &wallet : gArgs.GetArgs("-wallet")) {
172  LogPrintf("%s: parameter interaction: -disablewallet -> ignoring "
173  "-wallet=%s\n",
174  __func__, wallet);
175  }
177  return true;
178  }
180  if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) &&
181  gArgs.SoftSetBoolArg("-walletbroadcast", false)) {
182  LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting "
183  "-walletbroadcast=0\n",
184  __func__);
185  }
187  if (gArgs.IsArgSet("-zapwallettxes")) {
188  return InitError(
189  Untranslated("-zapwallettxes has been removed. If you are "
190  "attempting to remove a stuck transaction from your "
191  "wallet, please use abandontransaction instead."));
192  }
194  if (gArgs.GetBoolArg("-sysperms", false)) {
195  return InitError(
196  Untranslated("-sysperms is not allowed in combination with enabled "
197  "wallet functionality"));
198  }
200  return true;
201 }
204  ArgsManager &args = *Assert(node.args);
205  if (args.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
206  LogPrintf("Wallet disabled!\n");
207  return;
208  }
209  auto wallet_client = interfaces::MakeWalletClient(*node.chain, args);
210  node.wallet_client = wallet_client.get();
211  node.chain_clients.emplace_back(std::move(wallet_client));
212 }
static const unsigned int DEFAULT_WALLET_DBLOGSIZE
Definition: bdb.h:27
static const bool DEFAULT_WALLET_PRIVDB
Definition: bdb.h:28
#define Assert(val)
Identity function.
Definition: check.h:65
Definition: system.h:160
Definition: system.h:153
Definition: system.h:154
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
Definition: system.cpp:474
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Definition: system.cpp:484
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
Definition: system.cpp:620
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:603
void AddHiddenArgs(const std::vector< std::string > &args)
Add many hidden arguments.
Definition: system.cpp:673
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:651
Fee rate in satoshis per kilobyte: Amount / kB.
Definition: feerate.h:21
void Construct(NodeContext &node) const override
Add wallets that should be opened to list of chain clients.
Definition: init.cpp:203
bool ParameterInteraction() const override
Wallets parameter interaction.
Definition: init.cpp:169
void AddWalletOptions(ArgsManager &argsman) const override
Return the wallets help message.
Definition: init.cpp:43
bool HasWalletSupport() const override
Was the wallet component compiled in.
Definition: init.cpp:29
Default for -avoidpartialspends.
Definition: coincontrol.h:18
#define LogPrintf(...)
Definition: logging.h:204
std::string FormatMoney(const Amount amt)
Do not use these functions to represent or parse monetary amounts to or from JSON but use AmountFromV...
Definition: moneystr.cpp:13
std::unique_ptr< WalletClient > MakeWalletClient(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet client.
Definition: interfaces.cpp:585
Definition: init.h:28
static const bool DEFAULT_BLOCKSONLY
Default for blocks only.
Definition: net.h:95
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
static const Currency & get()
Definition: amount.cpp:18
std::string ticker
Definition: amount.h:160
NodeContext struct containing references to chain state and connection state.
Definition: context.h:38
ArgsManager gArgs
Definition: system.cpp:77
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1201
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:36
bool InitError(const bilingual_str &str)
Show error message.
const WalletInitInterface & g_wallet_init_interface
Definition: init.cpp:41
constexpr Amount DEFAULT_PAY_TX_FEE
-paytxfee default
Definition: wallet.h:82
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:107
static const Amount DEFAULT_FALLBACK_FEE
-fallbackfee default
Definition: wallet.h:84
-mintxfee default
Definition: wallet.h:86
Default for -spendzeroconfchange.
Definition: wallet.h:103
-maxtxfee default
Definition: wallet.h:109
maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled...
Definition: wallet.h:97
Definition: wallet.h:106
Default for -walletrejectlongchains.
Definition: wallet.h:105
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
Definition: walletdb.h:33