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 path to load at startup. Can be used multiple times to "
113  "load multiple wallets. Path is to a directory containing wallet data "
114  "and log files. If the path is not absolute, it is interpreted "
115  "relative to <walletdir>. This only loads existing wallets and does "
116  "not create new ones. For backwards compatibility this also accepts "
117  "names of existing top-level 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)",
160  argsman.AddHiddenArgs({"-zapwallettxes"});
161 }
164  if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
165  for (const std::string &wallet : gArgs.GetArgs("-wallet")) {
166  LogPrintf("%s: parameter interaction: -disablewallet -> ignoring "
167  "-wallet=%s\n",
168  __func__, wallet);
169  }
171  return true;
172  }
174  if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) &&
175  gArgs.SoftSetBoolArg("-walletbroadcast", false)) {
176  LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting "
177  "-walletbroadcast=0\n",
178  __func__);
179  }
181  if (gArgs.IsArgSet("-zapwallettxes")) {
182  return InitError(
183  Untranslated("-zapwallettxes has been removed. If you are "
184  "attempting to remove a stuck transaction from your "
185  "wallet, please use abandontransaction instead."));
186  }
188  if (gArgs.GetBoolArg("-sysperms", false)) {
189  return InitError(
190  Untranslated("-sysperms is not allowed in combination with enabled "
191  "wallet functionality"));
192  }
194  return true;
195 }
198  ArgsManager &args = *Assert(node.args);
199  if (args.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
200  LogPrintf("Wallet disabled!\n");
201  return;
202  }
203  auto wallet_client = interfaces::MakeWalletClient(*node.chain, args);
204  node.wallet_client = wallet_client.get();
205  node.chain_clients.emplace_back(std::move(wallet_client));
206 }
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:84
Definition: system.h:166
Definition: system.h:159
Definition: system.h:160
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
Definition: system.cpp:480
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Definition: system.cpp:490
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
Definition: system.cpp:698
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:665
void AddHiddenArgs(const std::vector< std::string > &args)
Add many hidden arguments.
Definition: system.cpp:751
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:729
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:197
bool ParameterInteraction() const override
Wallets parameter interaction.
Definition: init.cpp:163
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:206
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:581
Definition: init.h:28
static const bool DEFAULT_BLOCKSONLY
Default for blocks only.
Definition: net.h:97
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
static const Currency & get()
Definition: amount.cpp:18
std::string ticker
Definition: amount.h:150
NodeContext struct containing references to chain state and connection state.
Definition: context.h:38
ArgsManager gArgs
Definition: system.cpp:80
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1202
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:105
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:107
maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled...
Definition: wallet.h:97
Definition: wallet.h:104
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
Definition: walletdb.h:33