|
|
@ -806,13 +806,13 @@ UniValue estimatesmartfee(const JSONRPCRequest& request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) |
|
|
|
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) |
|
|
|
throw std::runtime_error( |
|
|
|
throw std::runtime_error( |
|
|
|
"estimatesmartfee nblocks (\"estimate_mode\")\n" |
|
|
|
"estimatesmartfee conf_target (\"estimate_mode\")\n" |
|
|
|
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n" |
|
|
|
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n" |
|
|
|
"confirmation within nblocks blocks if possible and return the number of blocks\n" |
|
|
|
"confirmation within conf_target blocks if possible and return the number of blocks\n" |
|
|
|
"for which the estimate is valid. Uses virtual transaction size as defined\n" |
|
|
|
"for which the estimate is valid. Uses virtual transaction size as defined\n" |
|
|
|
"in BIP 141 (witness data is discounted).\n" |
|
|
|
"in BIP 141 (witness data is discounted).\n" |
|
|
|
"\nArguments:\n" |
|
|
|
"\nArguments:\n" |
|
|
|
"1. nblocks (numeric) Confirmation target in blocks (1 - 1008)\n" |
|
|
|
"1. conf_target (numeric) Confirmation target in blocks (1 - 1008)\n" |
|
|
|
"2. \"estimate_mode\" (string, optional, default=CONSERVATIVE) The fee estimate mode.\n" |
|
|
|
"2. \"estimate_mode\" (string, optional, default=CONSERVATIVE) The fee estimate mode.\n" |
|
|
|
" Whether to return a more conservative estimate which also satisfies\n" |
|
|
|
" Whether to return a more conservative estimate which also satisfies\n" |
|
|
|
" a longer history. A conservative estimate potentially returns a\n" |
|
|
|
" a longer history. A conservative estimate potentially returns a\n" |
|
|
@ -839,10 +839,7 @@ UniValue estimatesmartfee(const JSONRPCRequest& request) |
|
|
|
|
|
|
|
|
|
|
|
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR}); |
|
|
|
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR}); |
|
|
|
RPCTypeCheckArgument(request.params[0], UniValue::VNUM); |
|
|
|
RPCTypeCheckArgument(request.params[0], UniValue::VNUM); |
|
|
|
int nBlocks = request.params[0].get_int(); |
|
|
|
unsigned int conf_target = ParseConfirmTarget(request.params[0]); |
|
|
|
if (nBlocks < 1 || (unsigned int)nBlocks > ::feeEstimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE)) { |
|
|
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid nblocks"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bool conservative = true; |
|
|
|
bool conservative = true; |
|
|
|
if (request.params.size() > 1 && !request.params[1].isNull()) { |
|
|
|
if (request.params.size() > 1 && !request.params[1].isNull()) { |
|
|
|
FeeEstimateMode fee_mode; |
|
|
|
FeeEstimateMode fee_mode; |
|
|
@ -855,7 +852,7 @@ UniValue estimatesmartfee(const JSONRPCRequest& request) |
|
|
|
UniValue result(UniValue::VOBJ); |
|
|
|
UniValue result(UniValue::VOBJ); |
|
|
|
UniValue errors(UniValue::VARR); |
|
|
|
UniValue errors(UniValue::VARR); |
|
|
|
FeeCalculation feeCalc; |
|
|
|
FeeCalculation feeCalc; |
|
|
|
CFeeRate feeRate = ::feeEstimator.estimateSmartFee(nBlocks, &feeCalc, conservative); |
|
|
|
CFeeRate feeRate = ::feeEstimator.estimateSmartFee(conf_target, &feeCalc, conservative); |
|
|
|
if (feeRate != CFeeRate(0)) { |
|
|
|
if (feeRate != CFeeRate(0)) { |
|
|
|
result.push_back(Pair("feerate", ValueFromAmount(feeRate.GetFeePerK()))); |
|
|
|
result.push_back(Pair("feerate", ValueFromAmount(feeRate.GetFeePerK()))); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -870,18 +867,18 @@ UniValue estimaterawfee(const JSONRPCRequest& request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) |
|
|
|
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) |
|
|
|
throw std::runtime_error( |
|
|
|
throw std::runtime_error( |
|
|
|
"estimaterawfee nblocks (threshold)\n" |
|
|
|
"estimaterawfee conf_target (threshold)\n" |
|
|
|
"\nWARNING: This interface is unstable and may disappear or change!\n" |
|
|
|
"\nWARNING: This interface is unstable and may disappear or change!\n" |
|
|
|
"\nWARNING: This is an advanced API call that is tightly coupled to the specific\n" |
|
|
|
"\nWARNING: This is an advanced API call that is tightly coupled to the specific\n" |
|
|
|
" implementation of fee estimation. The parameters it can be called with\n" |
|
|
|
" implementation of fee estimation. The parameters it can be called with\n" |
|
|
|
" and the results it returns will change if the internal implementation changes.\n" |
|
|
|
" and the results it returns will change if the internal implementation changes.\n" |
|
|
|
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n" |
|
|
|
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n" |
|
|
|
"confirmation within nblocks blocks if possible. Uses virtual transaction size as defined\n" |
|
|
|
"confirmation within conf_target blocks if possible. Uses virtual transaction size as\n" |
|
|
|
"in BIP 141 (witness data is discounted).\n" |
|
|
|
"defined in BIP 141 (witness data is discounted).\n" |
|
|
|
"\nArguments:\n" |
|
|
|
"\nArguments:\n" |
|
|
|
"1. nblocks (numeric) Confirmation target in blocks (1 - 1008)\n" |
|
|
|
"1. conf_target (numeric) Confirmation target in blocks (1 - 1008)\n" |
|
|
|
"2. threshold (numeric, optional) The proportion of transactions in a given feerate range that must have been\n" |
|
|
|
"2. threshold (numeric, optional) The proportion of transactions in a given feerate range that must have been\n" |
|
|
|
" confirmed within nblocks in order to consider those feerates as high enough and proceed to check\n" |
|
|
|
" confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n" |
|
|
|
" lower buckets. Default: 0.95\n" |
|
|
|
" lower buckets. Default: 0.95\n" |
|
|
|
"\nResult:\n" |
|
|
|
"\nResult:\n" |
|
|
|
"{\n" |
|
|
|
"{\n" |
|
|
@ -911,10 +908,7 @@ UniValue estimaterawfee(const JSONRPCRequest& request) |
|
|
|
|
|
|
|
|
|
|
|
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true); |
|
|
|
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true); |
|
|
|
RPCTypeCheckArgument(request.params[0], UniValue::VNUM); |
|
|
|
RPCTypeCheckArgument(request.params[0], UniValue::VNUM); |
|
|
|
int nBlocks = request.params[0].get_int(); |
|
|
|
unsigned int conf_target = ParseConfirmTarget(request.params[0]); |
|
|
|
if (nBlocks < 1 || (unsigned int)nBlocks > ::feeEstimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE)) { |
|
|
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid nblocks"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
double threshold = 0.95; |
|
|
|
double threshold = 0.95; |
|
|
|
if (!request.params[1].isNull()) { |
|
|
|
if (!request.params[1].isNull()) { |
|
|
|
threshold = request.params[1].get_real(); |
|
|
|
threshold = request.params[1].get_real(); |
|
|
@ -930,9 +924,9 @@ UniValue estimaterawfee(const JSONRPCRequest& request) |
|
|
|
EstimationResult buckets; |
|
|
|
EstimationResult buckets; |
|
|
|
|
|
|
|
|
|
|
|
// Only output results for horizons which track the target
|
|
|
|
// Only output results for horizons which track the target
|
|
|
|
if ((unsigned int)nBlocks > ::feeEstimator.HighestTargetTracked(horizon)) continue; |
|
|
|
if (conf_target > ::feeEstimator.HighestTargetTracked(horizon)) continue; |
|
|
|
|
|
|
|
|
|
|
|
feeRate = ::feeEstimator.estimateRawFee(nBlocks, threshold, horizon, &buckets); |
|
|
|
feeRate = ::feeEstimator.estimateRawFee(conf_target, threshold, horizon, &buckets); |
|
|
|
UniValue horizon_result(UniValue::VOBJ); |
|
|
|
UniValue horizon_result(UniValue::VOBJ); |
|
|
|
UniValue errors(UniValue::VARR); |
|
|
|
UniValue errors(UniValue::VARR); |
|
|
|
UniValue passbucket(UniValue::VOBJ); |
|
|
|
UniValue passbucket(UniValue::VOBJ); |
|
|
@ -983,9 +977,9 @@ static const CRPCCommand commands[] = |
|
|
|
{ "generating", "generatetoaddress", &generatetoaddress, true, {"nblocks","address","maxtries"} }, |
|
|
|
{ "generating", "generatetoaddress", &generatetoaddress, true, {"nblocks","address","maxtries"} }, |
|
|
|
|
|
|
|
|
|
|
|
{ "util", "estimatefee", &estimatefee, true, {"nblocks"} }, |
|
|
|
{ "util", "estimatefee", &estimatefee, true, {"nblocks"} }, |
|
|
|
{ "util", "estimatesmartfee", &estimatesmartfee, true, {"nblocks", "estimate_mode"} }, |
|
|
|
{ "util", "estimatesmartfee", &estimatesmartfee, true, {"conf_target", "estimate_mode"} }, |
|
|
|
|
|
|
|
|
|
|
|
{ "hidden", "estimaterawfee", &estimaterawfee, true, {"nblocks", "threshold"} }, |
|
|
|
{ "hidden", "estimaterawfee", &estimaterawfee, true, {"conf_target", "threshold"} }, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
void RegisterMiningRPCCommands(CRPCTable &t) |
|
|
|
void RegisterMiningRPCCommands(CRPCTable &t) |
|
|
|