3

Let me first start off by saying im just learning about blockchain and the technical aspects.

From my understanding, each transaction is cryptographically hashed, the hashes are paired and hashed until a single root hash is generated. The miners hash the entire block containing the root hash, previous hash, timestamp etc. If the hash meets the target difficulty then the block is added to the chain. Cryptographic hashing makes it infeasible to obtain the input from the hash output.

Q. If say, I wanted to go back to block X and see which transactions it contains, how is that possible if all the hashes are cryptographic and its infeasible to find the input from the hash output?

Thanks in advance.

2

Just to be clear: It's not the entire block that is being hashed, as you said, blocks are found by hashing only the block header of a candidate block. However, the block header includes the Merkle root of the transaction tree which in turn commits to the exact set of transactions in the block.

You're correct, a cryptographic hash function is a one-way function and the block content is not retrievable from the hash. To learn the content of the block, you use the block hash as a unique identifier and request the complete block from an archival node, i.e a full node that keeps the complete Bitcoin blockchain in store.

In turn, if you only have the txid to go from, you can request the full transaction from any node that has knowledge of it. The raw transaction does not include the information in which block it was included though. AFAIU, to get that you'd do a getData request of the MSG_MERKLEBLOCK type. This will not only give you the full transaction, but also hashing partners to form the Merkle branch up to the block hash and the block header, allowing you to fully validate the transaction's inclusion in the blockchain.

1

The miners hash the entire block containing the root hash, previous hash, timestamp etc. If the hash meets the target difficulty then the block is added to the chain

Not quite, only the block header is hashed for the proof of work. The block header is composed of: the version no, the previous blocks hash, the merkle root, a time stamp, the target (difficulty), and the nonce used to find the valid block.

The block header is just one part of the block though, each block also contains the data for all of the transactions included in it. So to answer your question:

I wanted to go back to block X and see which transactions it contains, how is that possible [...]?

Simple enough, you would just go back to that block, and look at the transaction data in it!

If you're wondering about why/how a merkle root is used, this question has a great answer. The bitcoin wiki also has some relevant info:

[Transactions] are hashed only indirectly through the Merkle root. Because transactions aren't hashed directly, hashing a block with 1 transaction takes exactly the same amount of effort as hashing a block with 10,000 transactions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.