<p>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.</p>
<p>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.</p>
<p>In turn, if you only have the <code>txid</code> 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 <code>getData</code> request of the <a href="https://developer.bitcoin.org/reference/p2p_networking.html#merkleblock" rel="nofollow noreferrer"><code>MSG_MERKLEBLOCK</code></a> type. This will not only give you the full transaction, but also hashing partners to form the <a href="https://bitcoin.stackexchange.com/a/50680/5406">Merkle branch</a> up to the block hash and the block header, allowing you to fully validate the transaction's inclusion in the blockchain.</p>

CC BY-SA 4.0
2017-12-14T20:36:31.260Z
2024-03-04T10:17:18.640Z
2024-03-04T10:17:18.640Z
Murch
<blockquote>
  <p>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</p>
</blockquote>

<p>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. </p>

<p>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:</p>

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

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

<p>If you're wondering about why/how a merkle root is used, <a href="https://bitcoin.stackexchange.com/questions/10479/what-is-the-merkle-root">this question</a> has a great answer. <a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow noreferrer">The bitcoin wiki also has some relevant info</a>:</p>

<blockquote>
  <p>[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.</p>
</blockquote>

CC BY-SA 3.0
2017-12-14T08:14:13.580Z
2017-12-14T08:14:13.580Z
chytrik
<p>Let me first start off by saying im just learning about blockchain and the technical aspects. </p>

<p>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. </p>

<p>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? </p>

<p>Thanks in advance.</p>

<transactions><blockchain><hash><confirmations><cryptography>
Verifying that a transaction is in the blockchain
sju
# Verifying that a transaction is in the blockchain

(Asked by: username_0 on 2017-12-14)

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.

**Tags:** transactions, blockchain, hash, confirmations, cryptography


---

## 2 answers

### Answer by username_1 on 2017-12-14. Score: 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`](https://developer.bitcoin.org/reference/p2p_networking.html#merkleblock) type. This will not only give you the full transaction, but also hashing partners to form the [Merkle branch](https://bitcoin.stackexchange.com/a/50680/5406) up to the block hash and the block header, allowing you to fully validate the transaction's inclusion in the blockchain.


---

### Answer by username_2 on 2017-12-14. Score: 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](https://bitcoin.stackexchange.com/questions/10479/what-is-the-merkle-root) has a great answer. [The bitcoin wiki also has some relevant info](https://en.bitcoin.it/wiki/Block_hashing_algorithm):

> [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.


---

