Include transaction hex in verbose getblock output

This commit is contained in:
Josh Ellithorpe 2020-12-03 14:14:01 -10:00
parent c8896f9907
commit efb603557a
No known key found for this signature in database
GPG Key ID: DA16DD2148DB9A7C
2 changed files with 5 additions and 0 deletions

View File

@ -85,6 +85,9 @@ class RawTransactionsTest(BitcoinTestFramework):
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

View File

@ -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);
BOOST_FOREACH(const CTxIn& txin, tx.vin) {