aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-06-11 12:33:20 +0800
committerfanquake <fanquake@gmail.com>2021-08-04 19:48:24 +0800
commit5ef2738089efd396186775ad23aaec71ea44ebb1 (patch)
tree78b1d357ae955c7481f6dee1d15217a7271b2ecd /src/init.cpp
parent3308c61091b6b7cb22569f3abadea6d001295c90 (diff)
downloadbitcoin-5ef2738089efd396186775ad23aaec71ea44ebb1.tar.xz
util: make ParseMoney return a std::optional<CAmount>
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/init.cpp b/src/init.cpp
index aee8b78999..b234ede437 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -915,10 +915,11 @@ bool AppInitParameterInteraction(const ArgsManager& args)
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
if (args.IsArgSet("-incrementalrelayfee")) {
- CAmount n = 0;
- if (!ParseMoney(args.GetArg("-incrementalrelayfee", ""), n))
+ if (std::optional<CAmount> inc_relay_fee = ParseMoney(args.GetArg("-incrementalrelayfee", ""))) {
+ ::incrementalRelayFee = CFeeRate{inc_relay_fee.value()};
+ } else {
return InitError(AmountErrMsg("incrementalrelayfee", args.GetArg("-incrementalrelayfee", "")));
- incrementalRelayFee = CFeeRate(n);
+ }
}
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
@@ -950,12 +951,12 @@ bool AppInitParameterInteraction(const ArgsManager& args)
}
if (args.IsArgSet("-minrelaytxfee")) {
- CAmount n = 0;
- if (!ParseMoney(args.GetArg("-minrelaytxfee", ""), n)) {
+ if (std::optional<CAmount> min_relay_fee = ParseMoney(args.GetArg("-minrelaytxfee", ""))) {
+ // High fee check is done afterward in CWallet::Create()
+ ::minRelayTxFee = CFeeRate{min_relay_fee.value()};
+ } else {
return InitError(AmountErrMsg("minrelaytxfee", args.GetArg("-minrelaytxfee", "")));
}
- // High fee check is done afterward in CWallet::Create()
- ::minRelayTxFee = CFeeRate(n);
} else if (incrementalRelayFee > ::minRelayTxFee) {
// Allow only setting incrementalRelayFee to control both
::minRelayTxFee = incrementalRelayFee;
@@ -965,18 +966,19 @@ bool AppInitParameterInteraction(const ArgsManager& args)
// Sanity check argument for min fee for including tx in block
// TODO: Harmonize which arguments need sanity checking and where that happens
if (args.IsArgSet("-blockmintxfee")) {
- CAmount n = 0;
- if (!ParseMoney(args.GetArg("-blockmintxfee", ""), n))
+ if (!ParseMoney(args.GetArg("-blockmintxfee", ""))) {
return InitError(AmountErrMsg("blockmintxfee", args.GetArg("-blockmintxfee", "")));
+ }
}
// Feerate used to define dust. Shouldn't be changed lightly as old
// implementations may inadvertently create non-standard transactions
if (args.IsArgSet("-dustrelayfee")) {
- CAmount n = 0;
- if (!ParseMoney(args.GetArg("-dustrelayfee", ""), n))
+ if (std::optional<CAmount> parsed = ParseMoney(args.GetArg("-dustrelayfee", ""))) {
+ dustRelayFee = CFeeRate{parsed.value()};
+ } else {
return InitError(AmountErrMsg("dustrelayfee", args.GetArg("-dustrelayfee", "")));
- dustRelayFee = CFeeRate(n);
+ }
}
fRequireStandard = !args.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());