Bugfix: RPC/mining: Fail properly in estimatesmartfee if smart fee data is unavailable

This commit is contained in:
Luke Dashjr committed 2021-11-18 18:35:45 +00:00
1 parent ea31caf6b4
commit cd8d156354
1 file changed
+1 -1
+1 -1
View File
@@ -1121,10 +1121,10 @@ static RPCHelpMan estimatesmartfee()
UniValue errors(UniValue::VARR); UniValue errors(UniValue::VARR);
FeeCalculation feeCalc; FeeCalculation feeCalc;
CFeeRate feeRate{fee_estimator.estimateSmartFee(conf_target, &feeCalc, conservative)}; CFeeRate feeRate{fee_estimator.estimateSmartFee(conf_target, &feeCalc, conservative)};
if (feeRate != CFeeRate(0)) {
CFeeRate min_mempool_feerate{mempool.GetMinFee(gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000)}; CFeeRate min_mempool_feerate{mempool.GetMinFee(gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000)};
CFeeRate min_relay_feerate{::minRelayTxFee}; CFeeRate min_relay_feerate{::minRelayTxFee};
feeRate = std::max({feeRate, min_mempool_feerate, min_relay_feerate}); feeRate = std::max({feeRate, min_mempool_feerate, min_relay_feerate});
if (feeRate != CFeeRate(0)) {
result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK())); result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
} else { } else {
errors.push_back("Insufficient data or no feerate found"); errors.push_back("Insufficient data or no feerate found");