@@ -838,9 +838,9 @@ UniValue estimatesmartfee(const JSONRPCRequest& request)
838
838
839
839
UniValue estimaterawfee (const JSONRPCRequest& request)
840
840
{
841
- if (request.fHelp || request.params .size () < 1 || request.params .size () > 3 )
841
+ if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
842
842
throw std::runtime_error (
843
- " estimaterawfee nblocks (threshold horizon )\n "
843
+ " estimaterawfee nblocks (threshold)\n "
844
844
" \n WARNING: This interface is unstable and may disappear or change!\n "
845
845
" \n WARNING: This is an advanced API call that is tightly coupled to the specific\n "
846
846
" implementation of fee estimation. The parameters it can be called with\n "
@@ -853,68 +853,70 @@ UniValue estimaterawfee(const JSONRPCRequest& request)
853
853
" 2. threshold (numeric, optional) The proportion of transactions in a given feerate range that must have been\n "
854
854
" confirmed within nblocks in order to consider those feerates as high enough and proceed to check\n "
855
855
" lower buckets. Default: 0.95\n "
856
- " 3. horizon (numeric, optional) How long a history of estimates to consider. 0=short, 1=medium, 2=long.\n "
857
- " Default: 1\n "
858
856
" \n Result:\n "
859
857
" {\n "
860
- " \" feerate\" : x.x, (numeric) estimate fee-per-kilobyte (in BTC)\n "
861
- " \" decay\" : x.x, (numeric) exponential decay (per block) for historical moving average of confirmation data\n "
862
- " \" scale\" : x, (numeric) The resolution of confirmation targets at this time horizon\n "
863
- " \" pass\" : { (json object) information about the lowest range of feerates to succeed in meeting the threshold\n "
864
- " \" startrange\" : x.x, (numeric) start of feerate range\n "
865
- " \" endrange\" : x.x, (numeric) end of feerate range\n "
866
- " \" withintarget\" : x.x, (numeric) number of txs over history horizon in the feerate range that were confirmed within target\n "
867
- " \" totalconfirmed\" : x.x, (numeric) number of txs over history horizon in the feerate range that were confirmed at any point\n "
868
- " \" inmempool\" : x.x, (numeric) current number of txs in mempool in the feerate range unconfirmed for at least target blocks\n "
869
- " \" leftmempool\" : x.x, (numeric) number of txs over history horizon in the feerate range that left mempool unconfirmed after target\n "
870
- " }\n "
871
- " \" fail\" : { ... } (json object) information about the highest range of feerates to fail to meet the threshold\n "
858
+ " \" short\" : { (json object) estimate for short time horizon\n "
859
+ " \" feerate\" : x.x, (numeric) estimate fee-per-kilobyte (in BTC)\n "
860
+ " \" decay\" : x.x, (numeric) exponential decay (per block) for historical moving average of confirmation data\n "
861
+ " \" scale\" : x, (numeric) The resolution of confirmation targets at this time horizon\n "
862
+ " \" pass\" : { (json object) information about the lowest range of feerates to succeed in meeting the threshold\n "
863
+ " \" startrange\" : x.x, (numeric) start of feerate range\n "
864
+ " \" endrange\" : x.x, (numeric) end of feerate range\n "
865
+ " \" withintarget\" : x.x, (numeric) number of txs over history horizon in the feerate range that were confirmed within target\n "
866
+ " \" totalconfirmed\" : x.x, (numeric) number of txs over history horizon in the feerate range that were confirmed at any point\n "
867
+ " \" inmempool\" : x.x, (numeric) current number of txs in mempool in the feerate range unconfirmed for at least target blocks\n "
868
+ " \" leftmempool\" : x.x, (numeric) number of txs over history horizon in the feerate range that left mempool unconfirmed after target\n "
869
+ " },\n "
870
+ " \" fail\" : { ... }, (json object) information about the highest range of feerates to fail to meet the threshold\n "
871
+ " },\n "
872
+ " \" medium\" : { ... }, (json object) estimate for medium time horizon\n "
873
+ " \" long\" : { ... } (json object) estimate for long time horizon\n "
872
874
" }\n "
873
875
" \n "
874
876
" A negative feerate is returned if no answer can be given.\n "
875
877
" \n Example:\n "
876
- + HelpExampleCli (" estimaterawfee" , " 6 0.9 1 " )
878
+ + HelpExampleCli (" estimaterawfee" , " 6 0.9" )
877
879
);
878
880
879
881
RPCTypeCheck (request.params , {UniValue::VNUM, UniValue::VNUM, UniValue::VNUM}, true );
880
882
RPCTypeCheckArgument (request.params [0 ], UniValue::VNUM);
881
883
int nBlocks = request.params [0 ].get_int ();
882
884
double threshold = 0.95 ;
883
- if (!request.params [1 ].isNull ())
885
+ if (!request.params [1 ].isNull ()) {
884
886
threshold = request.params [1 ].get_real ();
885
- FeeEstimateHorizon horizon = FeeEstimateHorizon::MED_HALFLIFE;
886
- if (!request.params [2 ].isNull ()) {
887
- int horizonInt = request.params [2 ].get_int ();
888
- if (horizonInt < 0 || horizonInt > 2 ) {
889
- throw JSONRPCError (RPC_TYPE_ERROR, " Invalid horizon for fee estimates" );
890
- } else {
891
- horizon = (FeeEstimateHorizon)horizonInt;
892
- }
893
887
}
888
+
894
889
UniValue result (UniValue::VOBJ);
895
- CFeeRate feeRate;
896
- EstimationResult buckets;
897
- feeRate = ::feeEstimator.estimateRawFee (nBlocks, threshold, horizon, &buckets);
898
890
899
- result.push_back (Pair (" feerate" , feeRate == CFeeRate (0 ) ? -1.0 : ValueFromAmount (feeRate.GetFeePerK ())));
900
- result.push_back (Pair (" decay" , buckets.decay ));
901
- result.push_back (Pair (" scale" , (int )buckets.scale ));
902
- UniValue passbucket (UniValue::VOBJ);
903
- passbucket.push_back (Pair (" startrange" , round (buckets.pass .start )));
904
- passbucket.push_back (Pair (" endrange" , round (buckets.pass .end )));
905
- passbucket.push_back (Pair (" withintarget" , round (buckets.pass .withinTarget * 100.0 ) / 100.0 ));
906
- passbucket.push_back (Pair (" totalconfirmed" , round (buckets.pass .totalConfirmed * 100.0 ) / 100.0 ));
907
- passbucket.push_back (Pair (" inmempool" , round (buckets.pass .inMempool * 100.0 ) / 100.0 ));
908
- passbucket.push_back (Pair (" leftmempool" , round (buckets.pass .leftMempool * 100.0 ) / 100.0 ));
909
- result.push_back (Pair (" pass" , passbucket));
910
- UniValue failbucket (UniValue::VOBJ);
911
- failbucket.push_back (Pair (" startrange" , round (buckets.fail .start )));
912
- failbucket.push_back (Pair (" endrange" , round (buckets.fail .end )));
913
- failbucket.push_back (Pair (" withintarget" , round (buckets.fail .withinTarget * 100.0 ) / 100.0 ));
914
- failbucket.push_back (Pair (" totalconfirmed" , round (buckets.fail .totalConfirmed * 100.0 ) / 100.0 ));
915
- failbucket.push_back (Pair (" inmempool" , round (buckets.fail .inMempool * 100.0 ) / 100.0 ));
916
- failbucket.push_back (Pair (" leftmempool" , round (buckets.fail .leftMempool * 100.0 ) / 100.0 ));
917
- result.push_back (Pair (" fail" , failbucket));
891
+ for (FeeEstimateHorizon horizon : {FeeEstimateHorizon::SHORT_HALFLIFE, FeeEstimateHorizon::MED_HALFLIFE, FeeEstimateHorizon::LONG_HALFLIFE}) {
892
+ CFeeRate feeRate;
893
+ EstimationResult buckets;
894
+ feeRate = ::feeEstimator.estimateRawFee (nBlocks, threshold, horizon, &buckets);
895
+
896
+ UniValue horizon_result (UniValue::VOBJ);
897
+ horizon_result.push_back (Pair (" feerate" , feeRate == CFeeRate (0 ) ? -1.0 : ValueFromAmount (feeRate.GetFeePerK ())));
898
+ if (!(feeRate == CFeeRate (0 ))) {
899
+ horizon_result.push_back (Pair (" decay" , buckets.decay ));
900
+ horizon_result.push_back (Pair (" scale" , (int )buckets.scale ));
901
+ UniValue passbucket (UniValue::VOBJ);
902
+ passbucket.push_back (Pair (" startrange" , round (buckets.pass .start )));
903
+ passbucket.push_back (Pair (" endrange" , round (buckets.pass .end )));
904
+ passbucket.push_back (Pair (" withintarget" , round (buckets.pass .withinTarget * 100.0 ) / 100.0 ));
905
+ passbucket.push_back (Pair (" totalconfirmed" , round (buckets.pass .totalConfirmed * 100.0 ) / 100.0 ));
906
+ passbucket.push_back (Pair (" inmempool" , round (buckets.pass .inMempool * 100.0 ) / 100.0 ));
907
+ passbucket.push_back (Pair (" leftmempool" , round (buckets.pass .leftMempool * 100.0 ) / 100.0 ));
908
+ horizon_result.push_back (Pair (" pass" , passbucket));
909
+ UniValue failbucket (UniValue::VOBJ);
910
+ failbucket.push_back (Pair (" startrange" , round (buckets.fail .start )));
911
+ failbucket.push_back (Pair (" endrange" , round (buckets.fail .end )));
912
+ failbucket.push_back (Pair (" withintarget" , round (buckets.fail .withinTarget * 100.0 ) / 100.0 ));
913
+ failbucket.push_back (Pair (" totalconfirmed" , round (buckets.fail .totalConfirmed * 100.0 ) / 100.0 ));
914
+ failbucket.push_back (Pair (" inmempool" , round (buckets.fail .inMempool * 100.0 ) / 100.0 ));
915
+ failbucket.push_back (Pair (" leftmempool" , round (buckets.fail .leftMempool * 100.0 ) / 100.0 ));
916
+ horizon_result.push_back (Pair (" fail" , failbucket));
917
+ }
918
+ result.push_back (Pair (StringForFeeEstimateHorizon (horizon), horizon_result));
919
+ }
918
920
return result;
919
921
}
920
922
@@ -932,7 +934,7 @@ static const CRPCCommand commands[] =
932
934
{ " util" , " estimatefee" , &estimatefee, true , {" nblocks" } },
933
935
{ " util" , " estimatesmartfee" , &estimatesmartfee, true , {" nblocks" , " conservative" } },
934
936
935
- { " hidden" , " estimaterawfee" , &estimaterawfee, true , {" nblocks" , " threshold" , " horizon " } },
937
+ { " hidden" , " estimaterawfee" , &estimaterawfee, true , {" nblocks" , " threshold" } },
936
938
};
937
939
938
940
void RegisterMiningRPCCommands (CRPCTable &t)
0 commit comments