Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
mempool_args.cpp
Go to the documentation of this file.
1// Copyright (c) 2022 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <mempool_args.h>
6
8
9#include <common/args.h>
10#include <consensus/amount.h>
11#include <kernel/chainparams.h>
12#include <policy/policy.h>
13#include <tinyformat.h>
14#include <util/error.h>
15#include <util/moneystr.h>
16#include <util/translation.h>
17
18#include <chrono>
19#include <memory>
20
22
23std::optional<bilingual_str>
26 mempool_opts.check_ratio =
27 argsman.GetIntArg("-checkmempool", mempool_opts.check_ratio);
28
29 if (auto mb = argsman.GetIntArg("-maxmempool")) {
30 mempool_opts.max_size_bytes = *mb * 1'000'000;
31 }
32
33 if (auto hours = argsman.GetIntArg("-mempoolexpiry")) {
34 mempool_opts.expiry = std::chrono::hours{*hours};
35 }
36
37 if (argsman.IsArgSet("-minrelaytxfee")) {
38 Amount n = Amount::zero();
39 auto parsed = ParseMoney(argsman.GetArg("-minrelaytxfee", ""), n);
40 if (!parsed || n == Amount::zero()) {
41 return AmountErrMsg("minrelaytxfee",
42 argsman.GetArg("-minrelaytxfee", ""));
43 }
44 // High fee check is done afterward in CWallet::Create()
45 mempool_opts.min_relay_feerate = CFeeRate(n);
46 }
47
48 // Feerate used to define dust. Shouldn't be changed lightly as old
49 // implementations may inadvertently create non-standard transactions.
50 if (argsman.IsArgSet("-dustrelayfee")) {
51 Amount n = Amount::zero();
52 auto parsed = ParseMoney(argsman.GetArg("-dustrelayfee", ""), n);
53 if (!parsed || Amount::zero() == n) {
54 return AmountErrMsg("dustrelayfee",
55 argsman.GetArg("-dustrelayfee", ""));
56 }
57 mempool_opts.dust_relay_feerate = CFeeRate(n);
58 }
59
60 mempool_opts.permit_bare_multisig =
61 argsman.GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG);
62
63 mempool_opts.max_datacarrier_bytes =
64 argsman.GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER)
65 ? std::optional<unsigned>{argsman.GetIntArg("-datacarriersize",
67 : std::nullopt;
68
69 mempool_opts.require_standard =
70 !argsman.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
71 if (!chainparams.IsTestChain() && !mempool_opts.require_standard) {
72 return strprintf(
74 "acceptnonstdtxn is not currently supported for %s chain"),
75 chainparams.NetworkIDString());
76 }
77
78 return std::nullopt;
79}
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition chainparams.h:80
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
bool IsTestChain() const
If this chain is exclusively used for testing.
Fee rate in satoshis per kilobyte: Amount / kB.
Definition feerate.h:21
bilingual_str AmountErrMsg(const std::string &optname, const std::string &strValue)
Definition error.cpp:53
std::optional< bilingual_str > ApplyArgsManOptions(const ArgsManager &argsman, const CChainParams &chainparams, MemPoolOptions &mempool_opts)
Overlay the options set in argsman on top of corresponding members in mempool_opts.
bool ParseMoney(const std::string &money_string, Amount &nRet)
Parse an amount denoted in full coins.
Definition moneystr.cpp:37
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG
Default for -permitbaremultisig.
Definition policy.h:56
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
static const unsigned int MAX_OP_RETURN_RELAY
Default setting for nMaxDatacarrierBytes.
Definition standard.h:36
static const bool DEFAULT_ACCEPT_DATACARRIER
Definition standard.h:17
static constexpr Amount zero() noexcept
Definition amount.h:32
Options struct containing options for constructing a CTxMemPool.
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition translation.h:36