aboutsummaryrefslogtreecommitdiff
path: root/src/core_read.cpp
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2018-09-24 10:59:17 -0400
committerBen Woosley <ben.woosley@gmail.com>2018-09-25 09:14:52 -0700
commit9c5af58d51cea7d0cf2a598a9979eeba103b23ff (patch)
tree8b75bcda130319567c94b2e37535f81d911b4d2d /src/core_read.cpp
parent990fc0de1afdfac8b711f39d9dbbab0c5f88a4c5 (diff)
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
Diffstat (limited to 'src/core_read.cpp')
-rw-r--r--src/core_read.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/core_read.cpp b/src/core_read.cpp
index b02016c014..301f99bc1c 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -193,14 +193,13 @@ bool DecodePSBT(PartiallySignedTransaction& psbt, const std::string& base64_tx,
return true;
}
-uint256 ParseHashStr(const std::string& strHex, const std::string& strName)
+bool ParseHashStr(const std::string& strHex, uint256& result)
{
- if (!IsHex(strHex)) // Note: IsHex("") is false
- throw std::runtime_error(strName + " must be hexadecimal string (not '" + strHex + "')");
+ if ((strHex.size() != 64) || !IsHex(strHex))
+ return false;
- uint256 result;
result.SetHex(strHex);
- return result;
+ return true;
}
std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName)