Skip to content

Commit

Permalink
Auto merge of #4891 - zquestz:add_hex_to_getblock, r=daira
Browse files Browse the repository at this point in the history
[Feature] Include transaction hex in verbose getblock output

This fixes zcash/zcash#4888 and actually makes it so the existing documentation is correct!

I also added a small test to make sure the transaction hex is returned correctly in verbose (2) `getblock` calls, and matches the value in `getrawtransaction`.

Let me know if there is anything else I need to update, as this is my first PR for zcash.

-------------------------------------------------------------------------------------------

Please ensure this checklist is followed for any pull requests for this repo. This checklist must be checked by both the PR creator and by anyone who reviews the PR.
* [ ] Relevant documentation for this PR has to be completed and reviewed by @mdr0id before the PR can be merged
* [ ] A test plan for the PR must be documented in the PR notes and included in the test plan for the next regular release

As a note, all buildbot tests need to be passing and all appropriate code reviews need to be done before this PR can be merged.
  • Loading branch information
zkbot committed Dec 8, 2020
2 parents 7dbd969 + efb6035 commit 5ab6976
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qa/rpc-tests/rawtransactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def run_test(self):
gottx = self.nodes[0].getrawtransaction(tx, 1)
assert_equal(gottx['txid'], tx)
assert 'in_active_chain' not in gottx
# We should have hex for the transaction from the getblock and getrawtransaction calls.
blk = self.nodes[0].getblock(block1, 2)
assert_equal(gottx['hex'], blk['tx'][1]['hex'])
# We should not get the tx if we provide an unrelated block
assert_raises(JSONRPCException, self.nodes[0].getrawtransaction, tx, 1, block2)
# An invalid block hash should raise errors
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
entry.pushKV("expiryheight", (int64_t)tx.nExpiryHeight);
}

entry.pushKV("hex", EncodeHexTx(tx));

KeyIO keyIO(Params());
UniValue vin(UniValue::VARR);
for (const CTxIn& txin : tx.vin) {
Expand Down

0 comments on commit 5ab6976

Please sign in to comment.