Example of data that is hashed in the merkle tree for a transaction So I am reading this (excellent resource) on the Bitcoin merkle tree for a transaction.


  The merkle tree is constructed bottom-up. In the following example, we start with four transactions, A, B, C, and D, which form the leaves of the merkle tree, as shown in Calculating the nodes in a merkle tree. The transactions are not stored in the merkle tree; rather, their data is hashed and the resulting hash is stored in each leaf node as HA, HB, HC, and HD:

HA = SHA256(SHA256(Transaction A))

  
  Consecutive pairs of leaf nodes are then summarized in a parent node, by concatenating the two hashes and hashing them together. For example, to construct the parent node HAB, the two 32-byte hashes of the children are concatenated to create a 64-byte string. That string is then double-hashed to produce the parent node’s hash:

HAB = SHA256(SHA256(HA + HB))

  
  The process continues until there is only one node at the top, the node known as the merkle root. That 32-byte hash is stored in the block header and summarizes all the data in all four transactions.


That makes sense, but I have a few questions. First is how the Transaction like Transaction A is hashed, and what is included in a transaction in practice. For example, if it's a JSON object stringified, or a byteArray in JavaScript, or if data must be in a specific format, etc.. I would like to see for example how a record would be hashed, like { a: 'foo', b: 'bar', c: 123, ... } or something like that.

Second is, if this is where the idea of the Patricia Merkle Tree (or perhaps even Merkle DAG, which I have seen somewhere) comes in, to shorten the amount of stuff you have to store in memory because the hashes don't completely overlap and so would have a lot of empty tree nodes.

Finally, what an example set of transactions would look like in a single block where they say on average they have 1900 transactions. This would be a pretty deep merkle tree, and I would like to see what the transactions are actually called and some more info on their data structure. For example, if they go all the way down to the ISA (Instruction Set Architecture) operations, or they are much higher level. That's basically all I'd like to know. I didn't see that in the book linked to above yet, but will take a closer look.
1) Transactions don't contain merkle hashes. Pre-SegWit transactions' hashes are calculated by serializing the transaction (you can search for "the hex format"), and then hashing the byte array. After SegWit, signatures are excluded from transaction hashes.

2) (I can't understand what you're asking for)

3) 1900 transactions is not so deep. The height can be calculated by ceil(log_2(number_of_tx))+1. Plug in 1900, and the height is 12. If you want to learn how merkle trees could be used for ISA, I'd suggest searching for MAST. It allows hiding the unexecuted parts of Script.