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

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1611-rpcParseHash64 changing 1 files +2 −0
  1. MarcoFalke commented at 4:09 PM on October 30, 2016: member

    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)
    
  2. MarcoFalke added the label RPC/REST/ZMQ on Oct 30, 2016
  3. [rpc] ParseHash: Fail when length is not 64 fa326193ad
  4. in src/rpc/server.cpp:None in fa6e0e1ec0 outdated
     146 | @@ -147,6 +147,8 @@ uint256 ParseHashV(const UniValue& v, string strName)
     147 |          strHex = v.get_str();
     148 |      if (!IsHex(strHex)) // Note: IsHex("") is false
     149 |          throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
     150 | +    if (256 / 4 != strHex.length())
    


    dcousens commented at 2:49 AM on October 31, 2016:

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


    MarcoFalke commented at 9:47 AM on October 31, 2016:

    fixed nit

  5. MarcoFalke force-pushed on Oct 31, 2016
  6. dcousens approved
  7. laanwj commented at 8:03 PM on November 2, 2016: member

    Makes sense, utACK fa32619

  8. laanwj merged this on Nov 2, 2016
  9. laanwj closed this on Nov 2, 2016

  10. laanwj referenced this in commit bc785d7185 on Nov 2, 2016
  11. MarcoFalke deleted the branch on Nov 2, 2016
  12. luke-jr referenced this in commit 5bcb05d4e1 on Dec 2, 2016
  13. codablock referenced this in commit 27264ddebb on Sep 19, 2017
  14. codablock referenced this in commit 42fa46f859 on Jan 13, 2018
  15. andvgal referenced this in commit 2488bf9e34 on Jan 6, 2019
  16. CryptoCentric referenced this in commit 1134e2c904 on Feb 15, 2019
  17. gandrewstone referenced this in commit a41b8d26bc on Mar 20, 2019
  18. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me