@@ -806,13 +806,13 @@ UniValue estimatesmartfee(const JSONRPCRequest& request)
806
806
{
807
807
if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
808
808
throw std::runtime_error (
809
- " estimatesmartfee nblocks (\" estimate_mode\" )\n "
809
+ " estimatesmartfee conf_target (\" estimate_mode\" )\n "
810
810
" \n Estimates the approximate fee per kilobyte needed for a transaction to begin\n "
811
- " confirmation within nblocks blocks if possible and return the number of blocks\n "
811
+ " confirmation within conf_target blocks if possible and return the number of blocks\n "
812
812
" for which the estimate is valid. Uses virtual transaction size as defined\n "
813
813
" in BIP 141 (witness data is discounted).\n "
814
814
" \n Arguments:\n "
815
- " 1. nblocks (numeric) Confirmation target in blocks (1 - 1008)\n "
815
+ " 1. conf_target (numeric) Confirmation target in blocks (1 - 1008)\n "
816
816
" 2. \" estimate_mode\" (string, optional, default=CONSERVATIVE) The fee estimate mode.\n "
817
817
" Whether to return a more conservative estimate which also satisfies\n "
818
818
" a longer history. A conservative estimate potentially returns a\n "
@@ -839,10 +839,7 @@ UniValue estimatesmartfee(const JSONRPCRequest& request)
839
839
840
840
RPCTypeCheck (request.params , {UniValue::VNUM, UniValue::VSTR});
841
841
RPCTypeCheckArgument (request.params [0 ], UniValue::VNUM);
842
- int nBlocks = request.params [0 ].get_int ();
843
- if (nBlocks < 1 || (unsigned int )nBlocks > ::feeEstimator.HighestTargetTracked (FeeEstimateHorizon::LONG_HALFLIFE)) {
844
- throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid nblocks" );
845
- }
842
+ unsigned int conf_target = ParseConfirmTarget (request.params [0 ]);
846
843
bool conservative = true ;
847
844
if (request.params .size () > 1 && !request.params [1 ].isNull ()) {
848
845
FeeEstimateMode fee_mode;
@@ -855,7 +852,7 @@ UniValue estimatesmartfee(const JSONRPCRequest& request)
855
852
UniValue result (UniValue::VOBJ);
856
853
UniValue errors (UniValue::VARR);
857
854
FeeCalculation feeCalc;
858
- CFeeRate feeRate = ::feeEstimator.estimateSmartFee (nBlocks , &feeCalc, conservative);
855
+ CFeeRate feeRate = ::feeEstimator.estimateSmartFee (conf_target , &feeCalc, conservative);
859
856
if (feeRate != CFeeRate (0 )) {
860
857
result.push_back (Pair (" feerate" , ValueFromAmount (feeRate.GetFeePerK ())));
861
858
} else {
@@ -870,18 +867,18 @@ UniValue estimaterawfee(const JSONRPCRequest& request)
870
867
{
871
868
if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
872
869
throw std::runtime_error (
873
- " estimaterawfee nblocks (threshold)\n "
870
+ " estimaterawfee conf_target (threshold)\n "
874
871
" \n WARNING: This interface is unstable and may disappear or change!\n "
875
872
" \n WARNING: This is an advanced API call that is tightly coupled to the specific\n "
876
873
" implementation of fee estimation. The parameters it can be called with\n "
877
874
" and the results it returns will change if the internal implementation changes.\n "
878
875
" \n Estimates the approximate fee per kilobyte needed for a transaction to begin\n "
879
- " confirmation within nblocks blocks if possible. Uses virtual transaction size as defined \n "
880
- " in BIP 141 (witness data is discounted).\n "
876
+ " confirmation within conf_target blocks if possible. Uses virtual transaction size as\n "
877
+ " defined in BIP 141 (witness data is discounted).\n "
881
878
" \n Arguments:\n "
882
- " 1. nblocks (numeric) Confirmation target in blocks (1 - 1008)\n "
879
+ " 1. conf_target (numeric) Confirmation target in blocks (1 - 1008)\n "
883
880
" 2. threshold (numeric, optional) The proportion of transactions in a given feerate range that must have been\n "
884
- " confirmed within nblocks in order to consider those feerates as high enough and proceed to check\n "
881
+ " confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n "
885
882
" lower buckets. Default: 0.95\n "
886
883
" \n Result:\n "
887
884
" {\n "
@@ -911,10 +908,7 @@ UniValue estimaterawfee(const JSONRPCRequest& request)
911
908
912
909
RPCTypeCheck (request.params , {UniValue::VNUM, UniValue::VNUM}, true );
913
910
RPCTypeCheckArgument (request.params [0 ], UniValue::VNUM);
914
- int nBlocks = request.params [0 ].get_int ();
915
- if (nBlocks < 1 || (unsigned int )nBlocks > ::feeEstimator.HighestTargetTracked (FeeEstimateHorizon::LONG_HALFLIFE)) {
916
- throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid nblocks" );
917
- }
911
+ unsigned int conf_target = ParseConfirmTarget (request.params [0 ]);
918
912
double threshold = 0.95 ;
919
913
if (!request.params [1 ].isNull ()) {
920
914
threshold = request.params [1 ].get_real ();
@@ -930,9 +924,9 @@ UniValue estimaterawfee(const JSONRPCRequest& request)
930
924
EstimationResult buckets;
931
925
932
926
// Only output results for horizons which track the target
933
- if (( unsigned int )nBlocks > ::feeEstimator.HighestTargetTracked (horizon)) continue ;
927
+ if (conf_target > ::feeEstimator.HighestTargetTracked (horizon)) continue ;
934
928
935
- feeRate = ::feeEstimator.estimateRawFee (nBlocks , threshold, horizon, &buckets);
929
+ feeRate = ::feeEstimator.estimateRawFee (conf_target , threshold, horizon, &buckets);
936
930
UniValue horizon_result (UniValue::VOBJ);
937
931
UniValue errors (UniValue::VARR);
938
932
UniValue passbucket (UniValue::VOBJ);
@@ -983,9 +977,9 @@ static const CRPCCommand commands[] =
983
977
{ " generating" , " generatetoaddress" , &generatetoaddress, true , {" nblocks" ," address" ," maxtries" } },
984
978
985
979
{ " util" , " estimatefee" , &estimatefee, true , {" nblocks" } },
986
- { " util" , " estimatesmartfee" , &estimatesmartfee, true , {" nblocks " , " estimate_mode" } },
980
+ { " util" , " estimatesmartfee" , &estimatesmartfee, true , {" conf_target " , " estimate_mode" } },
987
981
988
- { " hidden" , " estimaterawfee" , &estimaterawfee, true , {" nblocks " , " threshold" } },
982
+ { " hidden" , " estimaterawfee" , &estimaterawfee, true , {" conf_target " , " threshold" } },
989
983
};
990
984
991
985
void RegisterMiningRPCCommands (CRPCTable &t)
0 commit comments