| 942 | } |
| 943 | |
| 944 | static UniValue estimaterawfee(const JSONRPCRequest& request) |
| 945 | { |
| 946 | if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) |
| 947 | throw std::runtime_error( |
| 948 | "estimaterawfee conf_target (threshold)\n" |
| 949 | "\nWARNING: This interface is unstable and may disappear or change!\n" |
| 950 | "\nWARNING: This is an advanced API call that is tightly coupled to the specific\n" |
| 951 | " implementation of fee estimation. The parameters it can be called with\n" |
| 952 | " and the results it returns will change if the internal implementation changes.\n" |
| 953 | "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n" |
| 954 | "confirmation within conf_target blocks if possible. Uses virtual transaction size as\n" |
| 955 | "defined in BIP 141 (witness data is discounted).\n" |
| 956 | "\nArguments:\n" |
| 957 | "1. conf_target (numeric) Confirmation target in blocks (1 - 1008)\n" |
| 958 | "2. threshold (numeric, optional) The proportion of transactions in a given feerate range that must have been\n" |
| 959 | " confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n" |
| 960 | " lower buckets. Default: 0.95\n" |
| 961 | "\nResult:\n" |
| 962 | "{\n" |
| 963 | " \"short\" : { (json object, optional) estimate for short time horizon\n" |
| 964 | " \"feerate\" : x.x, (numeric, optional) estimate fee rate in " + CURRENCY_UNIT + "/kB\n" |
| 965 | " \"decay\" : x.x, (numeric) exponential decay (per block) for historical moving average of confirmation data\n" |
| 966 | " \"scale\" : x, (numeric) The resolution of confirmation targets at this time horizon\n" |
| 967 | " \"pass\" : { (json object, optional) information about the lowest range of feerates to succeed in meeting the threshold\n" |
| 968 | " \"startrange\" : x.x, (numeric) start of feerate range\n" |
| 969 | " \"endrange\" : x.x, (numeric) end of feerate range\n" |
| 970 | " \"withintarget\" : x.x, (numeric) number of txs over history horizon in the feerate range that were confirmed within target\n" |
| 971 | " \"totalconfirmed\" : x.x, (numeric) number of txs over history horizon in the feerate range that were confirmed at any point\n" |
| 972 | " \"inmempool\" : x.x, (numeric) current number of txs in mempool in the feerate range unconfirmed for at least target blocks\n" |
| 973 | " \"leftmempool\" : x.x, (numeric) number of txs over history horizon in the feerate range that left mempool unconfirmed after target\n" |
| 974 | " },\n" |
| 975 | " \"fail\" : { ... }, (json object, optional) information about the highest range of feerates to fail to meet the threshold\n" |
| 976 | " \"errors\": [ str... ] (json array of strings, optional) Errors encountered during processing\n" |
| 977 | " },\n" |
| 978 | " \"medium\" : { ... }, (json object, optional) estimate for medium time horizon\n" |
| 979 | " \"long\" : { ... } (json object) estimate for long time horizon\n" |
| 980 | "}\n" |
| 981 | "\n" |
| 982 | "Results are returned for any horizon which tracks blocks up to the confirmation target.\n" |
| 983 | "\nExample:\n" |
| 984 | + HelpExampleCli("estimaterawfee", "6 0.9") |
| 985 | ); |
| 986 | |
| 987 | RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true); |
| 988 | RPCTypeCheckArgument(request.params[0], UniValue::VNUM); |
| 989 | unsigned int conf_target = ParseConfirmTarget(request.params[0]); |
| 990 | double threshold = 0.95; |
| 991 | if (!request.params[1].isNull()) { |
| 992 | threshold = request.params[1].get_real(); |
| 993 | } |
| 994 | if (threshold < 0 || threshold > 1) { |
| 995 | throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid threshold"); |
| 996 | } |
| 997 | |
| 998 | UniValue result(UniValue::VOBJ); |
| 999 | |
| 1000 | for (FeeEstimateHorizon horizon : {FeeEstimateHorizon::SHORT_HALFLIFE, FeeEstimateHorizon::MED_HALFLIFE, FeeEstimateHorizon::LONG_HALFLIFE}) { |
| 1001 | CFeeRate feeRate; |
nothing calls this directly
no test coverage detected