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
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
Concept ACK.
Should throw for testnet and regtest genesis?
Add test for error?
@promag done, thanks
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?
@luke-jr oops you're right, wrong RPC. Fixed.
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")
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'])
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 | +
Remove whitespaces.
Comments addresses, thanks :)
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
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
nit: s/gettransaction/getrawtransaction
fixed
utACK ee11121.
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-----