mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
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
This commit is contained in:
commit
288deacdbe
@ -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()) {
|
||||
|
@ -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, [])
|
||||
|
Loading…
Reference in New Issue
Block a user