aboutsummaryrefslogtreecommitdiff
path: root/src/core_io.h
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_io.h
parent990fc0de1afdfac8b711f39d9dbbab0c5f88a4c5 (diff)
downloadbitcoin-9c5af58d51cea7d0cf2a598a9979eeba103b23ff.tar.xz
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_io.h')
-rw-r--r--src/core_io.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core_io.h b/src/core_io.h
index d53a45c0cb..2c3b64d81e 100644
--- a/src/core_io.h
+++ b/src/core_io.h
@@ -25,7 +25,16 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco
bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness = false, bool try_witness = true);
bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
-uint256 ParseHashStr(const std::string&, const std::string& strName);
+
+/**
+ * Parse a hex string into 256 bits
+ * @param[in] strHex a hex-formatted, 64-character string
+ * @param[out] result the result of the parasing
+ * @returns true if successful, false if not
+ *
+ * @see ParseHashV for an RPC-oriented version of this
+ */
+bool ParseHashStr(const std::string& strHex, uint256& result);
std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);
bool DecodePSBT(PartiallySignedTransaction& psbt, const std::string& base64_tx, std::string& error);
int ParseSighashString(const UniValue& sighash);