Properly bound check conf_target in wallet RPC calls

This commit is contained in:
Alex Morcos
2017-07-12 14:42:57 -04:00
parent fd29d3df29
commit 11590d39b9
3 changed files with 18 additions and 9 deletions

View File

@@ -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.