<p>The block hash is the output obtained when hashing the header of a bitcoin block. The header of a bitcoin block is comprised of several pieces of data, one of which is the merkle root.</p>
<p>So having the merkle root alone is not sufficient to calculate the block hash, you would need additional information (the rest of the block header).</p>
<p>You could write some code to query the block database for a specific merkle root, but otherwise I am not aware of any software that currently includes this functionality.</p>
<p>(this seems odd to me though: if you have calculated the merkle root, you assumedly have all the transaction data from the block in question. I'm not sure in what situation you would have all of this data, but not the rest of the block header data)</p>

CC BY-SA 4.0
2020-07-01T17:14:50.560Z
I am in the verge of validating a new functionality of verifying the merkle proof, I used different positions like changing LEFT to RIGHT and got some value of merkle root, hence using that merkle root value, I need to know the block hash / height to verify whether its correct or not.
Bhala T R
CC BY-SA 4.0
2020-06-30T23:12:13.427Z
2020-06-30T23:12:13.427Z
chytrik
<p>I have the merkle root, using this value, how to get the block hash or its height?
There is this merkle root available in getblock RPC output:</p>
<pre><code>./bitcoin-cli getblock 0320d6c1bd3c4cd2a08d6f76acb50b06a3ed766b058d247fbda3147aecfef388
{
  &quot;tx&quot;: [
    &quot;bccf4c873984245694f64263a3392c4d67c6a6f60efe4ed53aa4965f6d8b7dc0&quot;
  ],
  &quot;hash&quot;: &quot;0320d6c1bd3c4cd2a08d6f76acb50b06a3ed766b058d247fbda3147aecfef388&quot;,
  &quot;confirmations&quot;: 2,
  &quot;size&quot;: 180,
  &quot;height&quot;: 102,
  &quot;version&quot;: 536870912,
  &quot;versionHex&quot;: &quot;20000000&quot;,
  &quot;merkleroot&quot;: &quot;bccf4c873984245694f64263a3392c4d67c6a6f60efe4ed53aa4965f6d8b7dc0&quot;,
  &quot;num_tx&quot;: 1,
  &quot;time&quot;: 1593523883,
  &quot;mediantime&quot;: 1593467398,
  &quot;nonce&quot;: 1,
  &quot;bits&quot;: &quot;207fffff&quot;,
  &quot;difficulty&quot;: 4.656542373906925e-10,
  &quot;chainwork&quot;: &quot;00000000000000000000000000000000000000000000000000000000000000ce&quot;,
  &quot;previousblockhash&quot;: &quot;1664a604a6c8e603e311c6759f7693343ad77896c53de1bcef37de04dbcbbbc5&quot;,
  &quot;nextblockhash&quot;: &quot;1924c8db1b986f398a12d5481fcc293913a2dab2ee7fbcb0e131d7941e5201c2&quot;
}
</code></pre>
<p>using different transaction hashes, I got the merkle root value, now I need to know which block has this merkle root as in getblock.</p>

CC BY-SA 4.0
2020-07-01T01:37:14.727Z
Do you have the entire coinbase transaction? The height is included in its scriptSig
pinhead
<blockchain><bitcoin-cli>
how to find the block height from merkle root?
Bhala T R
# how to find the block height from merkle root?

(Asked by: username_0 on 2020-06-30)

I have the merkle root, using this value, how to get the block hash or its height?
There is this merkle root available in getblock RPC output:

```
./bitcoin-cli getblock 0320d6c1bd3c4cd2a08d6f76acb50b06a3ed766b058d247fbda3147aecfef388
{
  "tx": [
    "bccf4c873984245694f64263a3392c4d67c6a6f60efe4ed53aa4965f6d8b7dc0"
  ],
  "hash": "0320d6c1bd3c4cd2a08d6f76acb50b06a3ed766b058d247fbda3147aecfef388",
  "confirmations": 2,
  "size": 180,
  "height": 102,
  "version": 536870912,
  "versionHex": "20000000",
  "merkleroot": "bccf4c873984245694f64263a3392c4d67c6a6f60efe4ed53aa4965f6d8b7dc0",
  "num_tx": 1,
  "time": 1593523883,
  "mediantime": 1593467398,
  "nonce": 1,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "00000000000000000000000000000000000000000000000000000000000000ce",
  "previousblockhash": "1664a604a6c8e603e311c6759f7693343ad77896c53de1bcef37de04dbcbbbc5",
  "nextblockhash": "1924c8db1b986f398a12d5481fcc293913a2dab2ee7fbcb0e131d7941e5201c2"
}

```

using different transaction hashes, I got the merkle root value, now I need to know which block has this merkle root as in getblock.

**Tags:** blockchain, bitcoin-cli

> **Comments:**
> **username_1**: Do you have the entire coinbase transaction? The height is included in its scriptSig  

---

## 1 answers

### Answer by username_2 on 2020-06-30. Score: 1

The block hash is the output obtained when hashing the header of a bitcoin block. The header of a bitcoin block is comprised of several pieces of data, one of which is the merkle root.

So having the merkle root alone is not sufficient to calculate the block hash, you would need additional information (the rest of the block header).

You could write some code to query the block database for a specific merkle root, but otherwise I am not aware of any software that currently includes this functionality.

(this seems odd to me though: if you have calculated the merkle root, you assumedly have all the transaction data from the block in question. I'm not sure in what situation you would have all of this data, but not the rest of the block header data)

> **Comments:**
> **username_0**: I am in the verge of validating a new functionality of verifying the merkle proof, I used different positions like changing LEFT to RIGHT and got some value of merkle root, hence using that merkle root value, I need to know the block hash / height to verify whether its correct or not.  

---

