Consolidate redundant implementations of ParseHashStr

This change:
* adds a length check to ParseHashStr, appropriate given its use to populate
  a 256-bit number from a hex str.
* allows the caller to handle the failure, which allows for the more
  appropriate JSONRPCError on failure in prioritisetransaction rpc
This commit is contained in:
Ben Woosley
2018-09-24 10:59:17 -04:00
parent 990fc0de1a
commit 9c5af58d51
6 changed files with 87 additions and 22 deletions

View File

@@ -105,15 +105,6 @@ static std::string AvailableDataFormatsString()
return formats;
}
static bool ParseHashStr(const std::string& strReq, uint256& v)
{
if (!IsHex(strReq) || (strReq.size() != 64))
return false;
v.SetHex(strReq);
return true;
}
static bool CheckWarmup(HTTPRequest* req)
{
std::string statusmessage;