diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-01-30 09:59:22 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-01-30 09:59:28 +0100 |
commit | 288deacdbe088e72139cc4128f0d148a894bd10b (patch) | |
tree | 7cc27bc927cbcd1d228ff12d369473949f0c76cf | |
parent | 7cf1aea5cfcc7ef84c2dab7a3c55ab70babe3f7f (diff) | |
parent | ee1112122932151cee06b28ef724e0726849391b (diff) |
Merge #12278: Add special error for genesis coinbase to getrawtransaction
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
-rw-r--r-- | src/rpc/rawtransaction.cpp | 5 | ||||
-rwxr-xr-x | test/functional/rpc_rawtransaction.py | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 82399e1567..00e73675b4 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -147,6 +147,11 @@ UniValue getrawtransaction(const JSONRPCRequest& request) uint256 hash = ParseHashV(request.params[0], "parameter 1"); CBlockIndex* blockindex = nullptr; + if (hash == Params().GenesisBlock().hashMerkleRoot) { + // Special exception for the genesis block coinbase transaction + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "The genesis block coinbase is not considered an ordinary transaction and cannot be retrieved"); + } + // Accept either a bool (true) or a num (>=1) to indicate verbose output. bool fVerbose = false; if (!request.params[1].isNull()) { diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py index d39d86b310..c2ca7c70b8 100755 --- a/test/functional/rpc_rawtransaction.py +++ b/test/functional/rpc_rawtransaction.py @@ -59,6 +59,10 @@ class RawTransactionsTest(BitcoinTestFramework): self.nodes[0].generate(5) self.sync_all() + # Test getrawtransaction on genesis block coinbase returns an error + 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']) + # Test `createrawtransaction` required parameters assert_raises_rpc_error(-1, "createrawtransaction", self.nodes[0].createrawtransaction) assert_raises_rpc_error(-1, "createrawtransaction", self.nodes[0].createrawtransaction, []) |