diff options
author | Alex Morcos <morcos@chaincode.com> | 2017-07-12 14:42:57 -0400 |
---|---|---|
committer | Alex Morcos <morcos@chaincode.com> | 2017-07-14 23:41:40 -0400 |
commit | 11590d39b9888403ead8354302e308eca139ba17 (patch) | |
tree | 8b4a12b1209b00dc08ec71ef2e8db4573842ecd9 /src/rpc/mining.cpp | |
parent | fd29d3df299bd06c0e6bb218863e0c855b3b91af (diff) |
Properly bound check conf_target in wallet RPC calls
Diffstat (limited to 'src/rpc/mining.cpp')
-rw-r--r-- | src/rpc/mining.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 5dc468e111..b8c94d32ec 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -30,6 +30,16 @@ #include <univalue.h> +unsigned int ParseConfirmTarget(const UniValue& value) +{ + int target = value.get_int(); + unsigned int max_target = ::feeEstimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE); + if (target < 1 || (unsigned int)target > max_target) { + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid conf_target, must be between %u - %u", 1, max_target)); + } + return (unsigned int)target; +} + /** * Return average network hashes per second based on the last 'lookup' blocks, * or from the last difficulty change if 'lookup' is nonpositive. |