New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add special error for genesis coinbase to getrawtransaction #12278
Add special error for genesis coinbase to getrawtransaction #12278
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
Should throw for testnet and regtest genesis?
Add test for error?
@promag done, thanks |
Shouldn't 1) this be part of |
@luke-jr oops you're right, wrong RPC. Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luke-jr +1.
@@ -59,6 +59,9 @@ def run_test(self): | |||
self.nodes[0].generate(5) | |||
self.sync_all() | |||
|
|||
# Test gettransaction on genesis block coinbase returns an error | |||
assert_raises_rpc_error(-5, "The genesis block coinbase is not considered an ordinary transaction", self.nodes[0].getrawtransaction, "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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'])
src/rpc/rawtransaction.cpp
Outdated
@@ -146,6 +146,11 @@ UniValue getrawtransaction(const JSONRPCRequest& request) | |||
bool in_active_chain = true; | |||
uint256 hash = ParseHashV(request.params[0], "parameter 1"); | |||
CBlockIndex* blockindex = nullptr; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
@@ -59,6 +59,10 @@ def run_test(self): | |||
self.nodes[0].generate(5) | |||
self.sync_all() | |||
|
|||
# Test gettransaction on genesis block coinbase returns an error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/gettransaction/getrawtransaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
utACK ee11121. |
utACK
|
…tion ee11121 Add special error for genesis coinbase to gettransaction (MeshCollider) Pull request description: 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` Tree-SHA512: cd102c7983ec5457b299bff4b6db747d339fda157933a3ac54aec26b1e48b115aa68c1c9e6cb7a916f15c7786273ab558b2b20ab9768544d211e0ae9d1480e34
…transaction ee11121 Add special error for genesis coinbase to gettransaction (MeshCollider) Pull request description: 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` Tree-SHA512: cd102c7983ec5457b299bff4b6db747d339fda157933a3ac54aec26b1e48b115aa68c1c9e6cb7a916f15c7786273ab558b2b20ab9768544d211e0ae9d1480e34
…transaction ee11121 Add special error for genesis coinbase to gettransaction (MeshCollider) Pull request description: 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` Tree-SHA512: cd102c7983ec5457b299bff4b6db747d339fda157933a3ac54aec26b1e48b115aa68c1c9e6cb7a916f15c7786273ab558b2b20ab9768544d211e0ae9d1480e34
…transaction ee11121 Add special error for genesis coinbase to gettransaction (MeshCollider) Pull request description: 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` Tree-SHA512: cd102c7983ec5457b299bff4b6db747d339fda157933a3ac54aec26b1e48b115aa68c1c9e6cb7a916f15c7786273ab558b2b20ab9768544d211e0ae9d1480e34
…transaction ee11121 Add special error for genesis coinbase to gettransaction (MeshCollider) Pull request description: 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` Tree-SHA512: cd102c7983ec5457b299bff4b6db747d339fda157933a3ac54aec26b1e48b115aa68c1c9e6cb7a916f15c7786273ab558b2b20ab9768544d211e0ae9d1480e34
…transaction ee11121 Add special error for genesis coinbase to gettransaction (MeshCollider) Pull request description: 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` Tree-SHA512: cd102c7983ec5457b299bff4b6db747d339fda157933a3ac54aec26b1e48b115aa68c1c9e6cb7a916f15c7786273ab558b2b20ab9768544d211e0ae9d1480e34
…transaction ee11121 Add special error for genesis coinbase to gettransaction (MeshCollider) Pull request description: 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` Tree-SHA512: cd102c7983ec5457b299bff4b6db747d339fda157933a3ac54aec26b1e48b115aa68c1c9e6cb7a916f15c7786273ab558b2b20ab9768544d211e0ae9d1480e34
…transaction ee11121 Add special error for genesis coinbase to gettransaction (MeshCollider) Pull request description: 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` Tree-SHA512: cd102c7983ec5457b299bff4b6db747d339fda157933a3ac54aec26b1e48b115aa68c1c9e6cb7a916f15c7786273ab558b2b20ab9768544d211e0ae9d1480e34
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