Add special error for genesis coinbase to getrawtransaction #12278

pull meshcollider wants to merge 1 commits into bitcoin:master from meshcollider:201801_genesis_gettransaction_error changing 2 files +9 −0
  1. meshcollider commented at 7:36 AM on January 27, 2018: contributor

    Suggested by sipa here: https://botbot.me/freenode/bitcoin-core-dev/2018-01-23/?msg=96069825&page=2

    Just adds a special error message for the genesis block coinbase transaction when using getrawtransaction

  2. fanquake added the label RPC/REST/ZMQ on Jan 27, 2018
  3. promag commented at 9:30 AM on January 27, 2018: member

    Concept ACK.

    Should throw for testnet and regtest genesis?

    Add test for error?

  4. meshcollider commented at 11:45 AM on January 27, 2018: contributor

    @promag done, thanks

  5. luke-jr commented at 11:51 AM on January 27, 2018: member

    Shouldn't 1) this be part of getrawtransaction primarily, and 2) for gettransaction treat it as if it isn't in the wallet at all?

  6. meshcollider commented at 12:11 PM on January 27, 2018: contributor

    @luke-jr oops you're right, wrong RPC. Fixed.

  7. in test/functional/rpc_rawtransaction.py:63 in a29000e500 outdated
      58 | @@ -59,6 +59,9 @@ def run_test(self):
      59 |          self.nodes[0].generate(5)
      60 |          self.sync_all()
      61 |  
      62 | +        # Test gettransaction on genesis block coinbase returns an error
      63 | +        assert_raises_rpc_error(-5, "The genesis block coinbase is not considered an ordinary transaction", self.nodes[0].getrawtransaction, "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")
    


    promag commented at 2:43 PM on January 27, 2018:

    I think it should be something like:

    block = self.nodes[0].getblock(self.nodes[0].getblockhash(0))
    assert_raises_rpc_error(-5, "The genesis block coinbase is not considered an ordinary transaction", self.nodes[0].getrawtransaction, block['merkleroot'])
    
  8. promag commented at 2:44 PM on January 27, 2018: member

    @luke-jr +1.

  9. in src/rpc/rawtransaction.cpp:149 in a29000e500 outdated
     145 | @@ -146,6 +146,11 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
     146 |      bool in_active_chain = true;
     147 |      uint256 hash = ParseHashV(request.params[0], "parameter 1");
     148 |      CBlockIndex* blockindex = nullptr;
     149 | +    
    


    promag commented at 3:27 PM on January 27, 2018:

    Remove whitespaces.

  10. meshcollider renamed this:
    Add special error for genesis coinbase to gettransaction
    Add special error for genesis coinbase to getrawtransaction
    on Jan 27, 2018
  11. meshcollider commented at 9:27 AM on January 29, 2018: contributor

    Comments addresses, thanks :)

  12. laanwj commented at 12:26 PM on January 29, 2018: member

    I like that this keeps the error code the same (RPC_INVALID_ADDRESS_OR_KEY) just changes the message to be clearer to users, but from an API point of view there is no change.

    utACK 8a758dc

  13. Add special error for genesis coinbase to gettransaction ee11121229
  14. in test/functional/rpc_rawtransaction.py:62 in 8a758dc119 outdated
      58 | @@ -59,6 +59,10 @@ def run_test(self):
      59 |          self.nodes[0].generate(5)
      60 |          self.sync_all()
      61 |  
      62 | +        # Test gettransaction on genesis block coinbase returns an error
    


    fanquake commented at 12:27 PM on January 29, 2018:

    nit: s/gettransaction/getrawtransaction


    meshcollider commented at 10:36 PM on January 29, 2018:

    fixed

  15. promag commented at 10:48 PM on January 29, 2018: member

    utACK ee11121.

  16. MarcoFalke commented at 11:48 PM on January 29, 2018: member

    utACK

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    utACK ee1112122932151cee06b28ef724e0726849391b
    -----BEGIN PGP SIGNATURE-----
    
    iQIcBAEBCgAGBQJab7JwAAoJENLqSFDnUoslf2wP/iYueV2UtyfdzHM+j6sbrMFP
    Yb6D3swVRQjwk1iZJDNp6A/HkkanfPNPCcNFLRB5GKWm6oSijWmgBq+2fvGazMqB
    TQwV79AsVG/MOJOpzRlmgIixmOFD3cfewUoRdgGwGa7kDuLmgfxt64P8XdTz1hoB
    1W254XdJikGgVoFUlpkdTXsHgajcy65iQGBnXBWhyFsLr8Pc6Ceis+WBUgDT6N6W
    mK+3H1k6YXqqCzkB90xOC5Hcl5je934aNwZDAvarsiuoGgJYRNGcBSsDShL/e1UJ
    E/SG2o8/L7NHSTr1AtQdW2/rR64F2o9Fn/3WcnEKZm1n9aEJYOsWewIlZz0a+Sg4
    PCIxknkFgdTotiHeHdfwVpb30ogxDRnWmcYtIXNxK9H62ExnOzJH2dA5y6tdrvjW
    ae6KAldambeEUR5WROVTWYieY38y1v2CQHX/8nHCx3Wtaq1iikg5yPsDe7sKTfVS
    W9MXhp5TgWSCxOurNSyqgmFxPbeMErJyW3iSOOZ74tvaYdA4Msf0p2q7dtnc6dOL
    3bI6kMC9lG5jlDR7G3QPFwOkZ19OyLrCqUiNMN1pmEs+oq4ArIaG6siUUtldDpBi
    mxuda6EdCRhIWEuVARnJQLTRsr00x9Exyr4IYpLJ/WjJZG7Et2xTKcqLqlnsov5C
    IJjedLTohUyaQB9PuBnh
    =mVNm
    -----END PGP SIGNATURE-----
    
  17. laanwj merged this on Jan 30, 2018
  18. laanwj closed this on Jan 30, 2018

  19. laanwj referenced this in commit 288deacdbe on Jan 30, 2018
  20. meshcollider deleted the branch on Jan 30, 2018
  21. PastaPastaPasta referenced this in commit 9d5836e8cd on Jan 17, 2020
  22. PastaPastaPasta referenced this in commit 16082c56e6 on Jan 22, 2020
  23. PastaPastaPasta referenced this in commit 49a11f5744 on Jan 22, 2020
  24. PastaPastaPasta referenced this in commit 260a27b3ec on Jan 29, 2020
  25. PastaPastaPasta referenced this in commit f70b6e748a on Jan 29, 2020
  26. PastaPastaPasta referenced this in commit 43f7488d33 on Jan 29, 2020
  27. PastaPastaPasta referenced this in commit 5e6f784df8 on Jan 31, 2020
  28. ckti referenced this in commit b33dddafc4 on Mar 28, 2021
  29. DrahtBot 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