<blockquote>
<p>Is the &quot;hash&quot; field something that 'bitcoin-cli' calculates and inserts in situ into the json for informational purposes OR
is it that the &quot;hash&quot; field &gt;is&lt; actually part of the header and my understanding of this aspect is flawed?</p>
</blockquote>
<p>The &quot;block hash&quot; is produced by hashing the block’s header data. As such, it cannot be included in the header itself. However, it is also not calculated every time afresh. After a node processes a new block, it will use the block hash to uniquely identify this block in the chainstate database, to announce the block to peers, and the succeeding block references its predecessor in the header per the same hash. Therefore, even while the hash is not part of the header, it is most certainly stored by nodes in the context of the header after they calculate it once from the block header data.</p>

CC BY-SA 4.0
2024-08-29T13:42:25.907Z
2024-08-29T13:42:25.907Z
Murch
<blockquote>
  <p>Is the "hash" field something that the 'bitcoin-cli' calculates and inserts in situ into the json for informational purpouses</p>
</blockquote>

<p>This is correct. The block contains all of the info necessary to compute the hash, so as you mentioned, including it would be unnecessary and self-referential. </p>

<p>As one of the steps taken to confirm the block as being valid, <code>bitcoind</code> will calculate the hash and check it against the network difficulty. Using the <code>getblock</code> command returns this hash, among other info (not all of which is explicitly included in the block, but can be calculated locally with the available info). </p>

CC BY-SA 4.0
2018-07-29T04:32:57.193Z
2018-07-29T04:32:57.193Z
chytrik
<p>It is stated that the header of a block does <strong>not</strong> contain a 'hash' field (see e.g. <a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow noreferrer">Bitcoin-Wiki: Block hashing algorithm</a> or Antonopolous' Mastering Bitcoin 2nd Ed.).
This makes sense since including such a field would be self-referential.</p>
<p>However, when interrogating the blockchain for info on a specific block for example via <code>bitcoin-cli getblock</code> a 'hash' field is reported:</p>
<pre><code>{
  &quot;hash&quot;:  &quot;00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048&quot;,
  &quot;confirmations&quot;: 534047,
  &quot;strippedsize&quot;: 215,
  …
}
</code></pre>
<p>Is the &quot;hash&quot; field something that 'bitcoin-cli' calculates and inserts in situ into the json for informational purposes</p>
<p>OR</p>
<p>is it that the &quot;hash&quot; field  &gt;is&lt;  actually part of the header and my understanding of this aspect is flawed?</p>

<block-header><block-hash>
What is the source for the "hash" field reported by the 'bitcoin-cli getblock' command?
darbehdar
# What is the source for the "hash" field reported by the 'bitcoin-cli getblock' command?

(Asked by: username_0 on 2018-07-29)

It is stated that the header of a block does **not** contain a 'hash' field (see e.g. [Bitcoin-Wiki: Block hashing algorithm](https://en.bitcoin.it/wiki/Block_hashing_algorithm) or Antonopolous' Mastering Bitcoin 2nd Ed.).
This makes sense since including such a field would be self-referential.

However, when interrogating the blockchain for info on a specific block for example via `bitcoin-cli getblock` a 'hash' field is reported:

```
{
  "hash":  "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
  "confirmations": 534047,
  "strippedsize": 215,
  …
}

```

Is the "hash" field something that 'bitcoin-cli' calculates and inserts in situ into the json for informational purposes

OR

is it that the "hash" field >is< actually part of the header and my understanding of this aspect is flawed?

**Tags:** block-header, block-hash


---

## 2 answers

### Answer by username_2 on 2018-07-29. Score: 4 | Accepted answer

> Is the "hash" field something that the 'bitcoin-cli' calculates and inserts in situ into the json for informational purpouses

This is correct. The block contains all of the info necessary to compute the hash, so as you mentioned, including it would be unnecessary and self-referential.

As one of the steps taken to confirm the block as being valid, `bitcoind` will calculate the hash and check it against the network difficulty. Using the `getblock` command returns this hash, among other info (not all of which is explicitly included in the block, but can be calculated locally with the available info).


---

### Answer by username_1 on 2024-08-29. Score: 0

> Is the "hash" field something that 'bitcoin-cli' calculates and inserts in situ into the json for informational purposes OR
> is it that the "hash" field >is< actually part of the header and my understanding of this aspect is flawed?

The "block hash" is produced by hashing the block’s header data. As such, it cannot be included in the header itself. However, it is also not calculated every time afresh. After a node processes a new block, it will use the block hash to uniquely identify this block in the chainstate database, to announce the block to peers, and the succeeding block references its predecessor in the header per the same hash. Therefore, even while the hash is not part of the header, it is most certainly stored by nodes in the context of the header after they calculate it once from the block header data.


---

