2

It is stated that the header of a block does not contain a 'hash' field (see e.g. Bitcoin-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?

2 Answers 2

4

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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