Fix: parse -maxtxfee outside of CWallet

This preserves the effect of -maxtxfee even when -disablewallet is active.
This commit is contained in:
junderw 2022-08-04 09:28:06 +09:00
parent 3a29ba6d49
commit 1372b1dbe2
No known key found for this signature in database
GPG Key ID: A9273B5AD3E47B45
2 changed files with 20 additions and 15 deletions

View File

@ -1016,7 +1016,6 @@ bool AppInitParameterInteraction()
CAmount n = 0;
if (!ParseMoney(GetArg("-minrelaytxfee", ""), n) || 0 == n)
return InitError(AmountErrMsg("minrelaytxfee", GetArg("-minrelaytxfee", "")));
// High fee check is done afterward in CWallet::ParameterInteraction()
::minRelayTxFeeRate = CFeeRate(n);
} else if (incrementalRelayFee > ::minRelayTxFeeRate) {
// Allow only setting incrementalRelayFee to control both
@ -1024,6 +1023,26 @@ bool AppInitParameterInteraction()
LogPrintf("Increasing minrelaytxfee to %s to match incrementalrelayfee\n",::minRelayTxFeeRate.ToString());
}
// This is the maximum absolute fee (in COIN, not satoshis)
// that is allowed for sendrawtransaction RPC and CWallet
// This must be parsed outside of CWallet code in order to
// keep its effect on the RPC even when -disablewallet is
// active.
if (IsArgSet("-maxtxfee"))
{
CAmount nMaxFee = 0;
if (!ParseMoney(GetArg("-maxtxfee", ""), nMaxFee))
return InitError(AmountErrMsg("maxtxfee", GetArg("-maxtxfee", "")));
if (nMaxFee > HIGH_MAX_TX_FEE)
InitWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
::maxTxFee = nMaxFee;
if (CFeeRate(::maxTxFee, 1000) < ::minRelayTxFeeRate)
{
return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"),
GetArg("-maxtxfee", ""), ::minRelayTxFeeRate.ToString()));
}
}
// Sanity check argument for min fee for including tx in block
// TODO: Harmonize which arguments need sanity checking and where that happens
if (IsArgSet("-blockmintxfee"))

View File

@ -3961,20 +3961,6 @@ bool CWallet::ParameterInteraction()
CWallet::minTxFee = CFeeRate(nFeePerK,1000);
}
}
if (IsArgSet("-maxtxfee"))
{
CAmount nMaxFee = 0;
if (!ParseMoney(GetArg("-maxtxfee", ""), nMaxFee))
return InitError(AmountErrMsg("maxtxfee", GetArg("-maxtxfee", "")));
if (nMaxFee > HIGH_MAX_TX_FEE)
InitWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
maxTxFee = nMaxFee;
if (CFeeRate(maxTxFee, 1000) < ::minRelayTxFeeRate)
{
return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"),
GetArg("-maxtxfee", ""), ::minRelayTxFeeRate.ToString()));
}
}
if (IsArgSet("-discardthreshold"))
{
CAmount nDiscardThreshold = 0;