diff options
author | pranabp-bit <pranabp@iitk.ac.in> | 2021-08-14 08:22:43 +0530 |
---|---|---|
committer | pranabp-bit <pranabp@iitk.ac.in> | 2021-09-28 18:36:38 +0530 |
commit | ea31caf6b4c182c6f10f136548f84e603800511c (patch) | |
tree | 7f4087d38fa130756d3aae719b4f334598f946dd /src | |
parent | dccf3d25f9e78909eb7b3143e89a7c87fac25ab5 (diff) | |
download | bitcoin-ea31caf6b4c182c6f10f136548f84e603800511c.tar.xz |
update estimatesmartfee rpc to return max of estimateSmartFee, mempoolMinFee and minRelayTxFee.
This will provide better estimates which would be closer to fee paid in actual
transactions.
The test has also been changed such that when the node is restarted with a
high mempoolMinFee, the estimatesmartfee still returns a feeRate greater
than or equal to the mempoolMinFee, minRelayTxFee.(just like the feeRate of actual transactions)
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/mining.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index eb2d5b9c5f..066a60b71b 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1103,6 +1103,8 @@ static RPCHelpMan estimatesmartfee() RPCTypeCheckArgument(request.params[0], UniValue::VNUM); CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context); + const NodeContext& node = EnsureAnyNodeContext(request.context); + const CTxMemPool& mempool = EnsureMemPool(node); unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE); unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target); @@ -1118,7 +1120,10 @@ static RPCHelpMan estimatesmartfee() UniValue result(UniValue::VOBJ); UniValue errors(UniValue::VARR); FeeCalculation feeCalc; - CFeeRate feeRate = fee_estimator.estimateSmartFee(conf_target, &feeCalc, conservative); + CFeeRate feeRate{fee_estimator.estimateSmartFee(conf_target, &feeCalc, conservative)}; + CFeeRate min_mempool_feerate{mempool.GetMinFee(gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000)}; + CFeeRate min_relay_feerate{::minRelayTxFee}; + feeRate = std::max({feeRate, min_mempool_feerate, min_relay_feerate}); if (feeRate != CFeeRate(0)) { result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK())); } else { |