2

https://getmonero.org/resources/developer-guides/daemon-rpc.html

Using the monerod json rpc, we can get the blob data for a specific block.

curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getblock","params":{"height":912345}}' -H 'Content-Type: application/json'

blob data returned for that block:

"blob": "0102f4bedfb405b61c58b2e0be53fad5ef9d9731a55e8a81d972b8d90ed07c04fd37ca6403ff786e0600000195d83701ffd9d73704ee84ddb42102378b043c1724c92c69d923d266fe86477d3a5ddd21145062e148c64c5767700880c0fc82aa020273733cbd6e6218bda671596462a4b062f95cfe5e1dbb5b990dacb30e827d02f280f092cbdd080247a5dab669770da69a860acde21616a119818e1a489bb3c4b1b6b3c50547bc0c80e08d84ddcb01021f7e4762b8b755e3e3c72b8610cc87b9bc25d1f0a87c0c816ebb952e4f8aff3d2b01fd0a778957f4f3103a838afda488c3cdadf2697b3d34ad71234282b2fad9100e02080000000bdfc2c16c00",

block hash for that block:

"hash": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6"

I think the blob is made up of the blockheader, nonce, Merkle root hash and size of transactions.

Using get_block_longhash from https://github.com/monero-project/monero/blob/960886aa04f0b50265884c0d4338031a93b1bc5d/src/cryptonote_basic/cryptonote_format_utils.cpp#L883

Can we hash that blob manually, which should yield its block hash?

Also what's the difference between the getblock method blob and the getblocktemplate method blocktemplate_blob ?

1 Answer 1

2

The block header or block isn't what is being hashed.

The block header contains versions, timestamp, coinbase tx, and other ancillary info.

The block contains the header, as well as a list of transaction IDs.

The block hashing blob, which is different contains the block header plus the number of transactions and the Merkle tree root (ie, not the whole set of tx ids). That is what is being hashed for PoW.

getblocktemplate gets you the block hashing block in the blockhashing_blob field.

3
  • actually iam trying to generate blockhashing_blob 's for old blocks. how to extract merkel tree hash for old blocks? Commented Jan 4, 2018 at 0:10
  • I am able to build blockhashing_blob for old blocks with version, nonce, prev hash,size of txs but couldn't generate merkle hash. Commented Jan 4, 2018 at 0:18
  • See tree_hash in src/crypto. Recursive hashing of a tree of those hashes.
    – user36303
    Commented Jan 4, 2018 at 12:59

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.