Policy: warn if -minrelaytxfee is too high
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 13 native, x86_64, no depends, sqlite only, gui (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled

This commit is contained in:
Léo Haf 2025-03-28 15:39:52 +01:00
parent 5f8256608f
commit 915068945f
Signed by: Retropex
GPG Key ID: F5073C4F4882FFFC
2 changed files with 10 additions and 4 deletions

View File

@ -110,7 +110,10 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& argsman, const CChainP
} }
if (argsman.IsArgSet("-minrelaytxfee")) { if (argsman.IsArgSet("-minrelaytxfee")) {
if (std::optional<CAmount> min_relay_feerate = ParseMoney(argsman.GetArg("-minrelaytxfee", ""))) { std::optional<CAmount> min_relay_feerate = ParseMoney(argsman.GetArg("-minrelaytxfee", ""));
if (min_relay_feerate >= 100000000 && (std::string(1, std::string(argsman.GetArg("-minrelaytxfee", "")).at(0)) != "f")) {
return util::Error{_("-minrelaytxfee is very high! Prefix with f to force this fee rate")};
} else if (min_relay_feerate) {
// High fee check is done afterward in CWallet::Create() // High fee check is done afterward in CWallet::Create()
mempool_opts.min_relay_feerate = CFeeRate{min_relay_feerate.value()}; mempool_opts.min_relay_feerate = CFeeRate{min_relay_feerate.value()};
} else { } else {

View File

@ -55,7 +55,8 @@ std::optional<CAmount> ParseMoney(const std::string& money_string)
std::string strWhole; std::string strWhole;
int64_t nUnits = 0; int64_t nUnits = 0;
const char* p = str.c_str(); const char* p = str.c_str();
for (; *p; p++) int position =0;
for (; *p; p++, position++)
{ {
if (*p == '.') if (*p == '.')
{ {
@ -70,10 +71,12 @@ std::optional<CAmount> ParseMoney(const std::string& money_string)
} }
if (IsSpace(*p)) if (IsSpace(*p))
return std::nullopt; return std::nullopt;
if (!(position == 0 && *p == 'f')) {
if (!IsDigit(*p)) if (!IsDigit(*p))
return std::nullopt; return std::nullopt;
strWhole.insert(strWhole.end(), *p); strWhole.insert(strWhole.end(), *p);
} }
}
if (*p) { if (*p) {
return std::nullopt; return std::nullopt;
} }