33 "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
34 "confirmation within conf_target blocks if possible and return the number of blocks\n"
35 "for which the estimate is valid. Uses virtual transaction size as defined\n"
36 "in BIP 141 (witness data is discounted).\n",
46 {
RPCResult::Type::ARR,
"errors",
true,
"Errors encountered during processing (if there are any)",
51 "The request target will be clamped between 2 and the highest target\n"
52 "fee estimation is able to return based on how long it has been running.\n"
53 "An error is returned if not enough transactions and blocks\n"
54 "have been observed to make an estimate for any number of blocks."},
69 bool conservative =
false;
70 if (!request.params[1].isNull()) {
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));
100 "\nWARNING: This interface is unstable and may disappear or change!\n"
101 "\nWARNING: This is an advanced API call that is tightly coupled to the specific\n"
102 "implementation of fee estimation. The parameters it can be called with\n"
103 "and the results it returns will change if the internal implementation changes.\n"
104 "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
105 "confirmation within conf_target blocks if possible. Uses virtual transaction size as\n"
106 "defined in BIP 141 (witness data is discounted).\n",
110 "confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n"
114 RPCResult::Type::OBJ,
"",
"Results are returned for any horizon which tracks blocks up to the confirmation target",
119 {
RPCResult::Type::NUM,
"decay",
"exponential decay (per block) for historical moving average of confirmation data"},
121 {
RPCResult::Type::OBJ,
"pass",
true,
"information about the lowest range of feerates to succeed in meeting the threshold",
125 {
RPCResult::Type::NUM,
"withintarget",
"number of txs over history horizon in the feerate range that were confirmed within target"},
126 {
RPCResult::Type::NUM,
"totalconfirmed",
"number of txs over history horizon in the feerate range that were confirmed at any point"},
127 {
RPCResult::Type::NUM,
"inmempool",
"current number of txs in mempool in the feerate range unconfirmed for at least target blocks"},
128 {
RPCResult::Type::NUM,
"leftmempool",
"number of txs over history horizon in the feerate range that left mempool unconfirmed after target"},
130 {
RPCResult::Type::OBJ,
"fail",
true,
"information about the highest range of feerates to fail to meet the threshold",
134 {
RPCResult::Type::ARR,
"errors",
true,
"Errors encountered during processing (if there are any)",
159 double threshold = 0.95;
160 if (!request.params[1].isNull()) {
161 threshold = request.params[1].get_real();
163 if (threshold < 0 || threshold > 1) {
176 feeRate = fee_estimator.
estimateRawFee(conf_target, threshold, horizon, &buckets);
198 horizon_result.
pushKV(
"scale", (
int)buckets.
scale);
199 horizon_result.
pushKV(
"pass", std::move(passbucket));
201 if (buckets.
fail.
start != -1) horizon_result.
pushKV(
"fail", std::move(failbucket));
205 horizon_result.
pushKV(
"scale", (
int)buckets.
scale);
206 horizon_result.
pushKV(
"fail", std::move(failbucket));
207 errors.
push_back(
"Insufficient data or no feerate found which meets threshold");
208 horizon_result.
pushKV(
"errors", std::move(errors));
223 for (
const auto& c : commands) {
224 t.appendCommand(c.name, &c);
#define CHECK_NONFATAL(condition)
Identity function.
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
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.
unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator)
Calculation of highest target that estimates are tracked for.
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,...
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
CFeeRate GetMinFee(size_t sizelimit) const
void push_back(UniValue val)
void pushKV(std::string key, UniValue val)
UniValue ValueFromAmount(const CAmount amount)
const std::string CURRENCY_UNIT
@ CONSERVATIVE
Force estimateSmartFee to use conservative estimates.
is a home for simple string functions returning descriptive messages that are used in RPC and GUI int...
bool FeeModeFromString(const std::string &mode_string, FeeEstimateMode &fee_estimate_mode)
std::string FeeModesDetail(std::string default_info)
std::string InvalidEstimateModeErrorMessage()
std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon)
static constexpr auto ALL_FEE_ESTIMATE_HORIZONS
UniValue JSONRPCError(int code, const std::string &message)
static RPCHelpMan estimatesmartfee()
void RegisterFeeRPCCommands(CRPCTable &t)
static RPCHelpMan estimaterawfee()
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
unsigned int ParseConfirmTarget(const UniValue &value, unsigned int max_target)
Parse a confirm target option and raise an RPC error if it is invalid.
NodeContext & EnsureAnyNodeContext(const std::any &context)
CTxMemPool & EnsureMemPool(const NodeContext &node)
CBlockPolicyEstimator & EnsureAnyFeeEstimator(const std::any &context)
@ ELISION
Special type to denote elision (...)
ValidationSignals * signals
CFeeRate min_relay_feerate
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)
NodeContext struct containing references to chain state and connection state.