16 #include <txmempool.h> 25 #include <string_view> 36 "Estimates the approximate fee per kilobyte needed for a transaction to begin\n" 37 "confirmation within conf_target blocks if possible and return the number of blocks\n" 38 "for which the estimate is valid. Uses virtual transaction size as defined\n" 39 "in BIP 141 (witness data is discounted).\n",
49 {
RPCResult::Type::ARR,
"errors",
true,
"Errors encountered during processing (if there are any)",
54 "The request target will be clamped between 2 and the highest target\n" 55 "fee estimation is able to return based on how long it has been running.\n" 56 "An error is returned if not enough transactions and blocks\n" 57 "have been observed to make an estimate for any number of blocks."},
85 feeRate = std::max({feeRate, min_mempool_feerate, min_relay_feerate});
88 errors.
push_back(
"Insufficient data or no feerate found");
89 result.pushKV(
"errors", std::move(errors));
101 "WARNING: This interface is unstable and may disappear or change!\n" 102 "\nWARNING: This is an advanced API call that is tightly coupled to the specific\n" 103 "implementation of fee estimation. The parameters it can be called with\n" 104 "and the results it returns will change if the internal implementation changes.\n" 105 "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n" 106 "confirmation within conf_target blocks if possible. Uses virtual transaction size as\n" 107 "defined in BIP 141 (witness data is discounted).\n",
111 "confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n" 115 RPCResult::Type::OBJ,
"",
"Results are returned for any horizon which tracks blocks up to the confirmation target",
120 {
RPCResult::Type::NUM,
"decay",
"exponential decay (per block) for historical moving average of confirmation data"},
122 {
RPCResult::Type::OBJ,
"pass",
true,
"information about the lowest range of feerates to succeed in meeting the threshold",
126 {
RPCResult::Type::NUM,
"withintarget",
"number of txs over history horizon in the feerate range that were confirmed within target"},
127 {
RPCResult::Type::NUM,
"totalconfirmed",
"number of txs over history horizon in the feerate range that were confirmed at any point"},
128 {
RPCResult::Type::NUM,
"inmempool",
"current number of txs in mempool in the feerate range unconfirmed for at least target blocks"},
129 {
RPCResult::Type::NUM,
"leftmempool",
"number of txs over history horizon in the feerate range that left mempool unconfirmed after target"},
131 {
RPCResult::Type::OBJ,
"fail",
true,
"information about the highest range of feerates to fail to meet the threshold",
135 {
RPCResult::Type::ARR,
"errors",
true,
"Errors encountered during processing (if there are any)",
160 double threshold = 0.95;
161 if (!request.params[1].isNull()) {
162 threshold = request.params[1].get_real();
164 if (threshold < 0 || threshold > 1) {
177 feeRate = fee_estimator.
estimateRawFee(conf_target, threshold, horizon, &buckets);
200 horizon_result.
pushKV(
"pass", std::move(passbucket));
202 if (buckets.
fail.
start != -1) horizon_result.
pushKV(
"fail", std::move(failbucket));
207 horizon_result.
pushKV(
"fail", std::move(failbucket));
208 errors.
push_back(
"Insufficient data or no feerate found which meets threshold");
209 horizon_result.
pushKV(
"errors", std::move(errors));
224 for (
const auto& c : commands) {
225 t.appendCommand(c.name, &c);
void push_back(UniValue val)
UniValue ValueFromAmount(const CAmount amount)
CTxMemPool & EnsureMemPool(const NodeContext &node)
is a home for simple string functions returning descriptive messages that are used in RPC and GUI int...
ValidationSignals * signals
#define CHECK_NONFATAL(condition)
Identity function.
static constexpr auto ALL_FEE_ESTIMATE_HORIZONS
std::string InvalidEstimateModeErrorMessage()
unsigned int ParseConfirmTarget(const UniValue &value, unsigned int max_target)
Parse a confirm target option and raise an RPC error if it is invalid.
Force estimateSmartFee to use conservative estimates.
Invalid, missing or duplicate parameter.
bool FeeModeFromString(std::string_view mode_string, FeeEstimateMode &fee_estimate_mode)
NodeContext struct containing references to chain state and connection state.
void RegisterFeeRPCCommands(CRPCTable &t)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon)
UniValue JSONRPCError(int code, const std::string &message)
static RPCHelpMan estimaterawfee()
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
CBlockPolicyEstimator & EnsureAnyFeeEstimator(const std::any &context)
virtual CFeeRate estimateSmartFee(int confTarget, FeeCalculation *feeCalc, bool conservative) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator)
Estimate feerate needed to get be included in a block within confTarget blocks.
const std::string CURRENCY_UNIT
CFeeRate min_relay_feerate
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
CFeeRate GetMinFee(size_t sizelimit) const
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void pushKV(std::string key, UniValue val)
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac...
CFeeRate estimateRawFee(int confTarget, double successThreshold, FeeEstimateHorizon horizon, EstimationResult *result=nullptr) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator)
Return a specific fee estimate calculation with a given success threshold and time horizon...
virtual unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator)
Calculation of highest target that estimates are tracked for.
std::string FeeModesDetail(std::string default_info)
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
static RPCHelpMan estimatesmartfee()
NodeContext & EnsureAnyNodeContext(const std::any &context)
Special type to denote elision (...)