[rpc] ParseHash: Fail when length is not 64 #9042

Merged
merged 1 commit into from Nov 2, 2016

Projects

None yet

3 participants

@MarcoFalke
Member
MarcoFalke commented Oct 30, 2016 edited

There have been a few complaints such as #9040... Maybe this helps to debug them further.

Of course this also makes it impossible to discard the "leading" zeros:

Before:

> getrawtransaction f3fe5b5c0024dbb1030edd720fc1effc306a054da5a507903e8cb5663336
< 01000000014f7...

After:

> getrawtransaction f3fe5b5c0024dbb1030edd720fc1effc306a054da5a507903e8cb5663336
< parameter 1 must be of length 64 (not 60) (code -8)
src/rpc/server.cpp
@@ -147,6 +147,8 @@ uint256 ParseHashV(const UniValue& v, string strName)
strHex = v.get_str();
if (!IsHex(strHex)) // Note: IsHex("") is false
throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
+ if (256 / 4 != strHex.length())
@dcousens
dcousens Oct 31, 2016 Contributor

256 / 4 is more confusing than 32 * 2 or just 64...

@MarcoFalke
MarcoFalke Oct 31, 2016 Member

fixed nit

@laanwj
Member
laanwj commented Nov 2, 2016

Makes sense, utACK fa32619

@laanwj laanwj merged commit fa32619 into bitcoin:master Nov 2, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@laanwj laanwj added a commit that referenced this pull request Nov 2, 2016
@laanwj laanwj Merge #9042: [rpc] ParseHash: Fail when length is not 64
fa32619 [rpc] ParseHash: Fail when length is not 64 (MarcoFalke)
bc785d7
@MarcoFalke MarcoFalke deleted the MarcoFalke:Mf1611-rpcParseHash64 branch Nov 2, 2016
@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Dec 2, 2016
@MarcoFalke @luke-jr MarcoFalke + luke-jr [rpc] ParseHash: Fail when length is not 64
Github-Pull: #9042
Rebased-From: fa32619
5bcb05d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment