How to find values of Prev_Hash and Tx_Root

0

https://bitcoin.stackexchange.com/a/13347/27951

Based upon the answer here, it seems there's values per block with each Prev_Hash and also Tx_Root

There doesn't seem to be much documentation for how to access these. How can I find the Prev_Hash and the Tx_Root of the most recent block for example?

Thanks

Anthony

Posted 2016-04-15T23:44:48.207

Reputation: 151

Do you want to access the values from code? Or just see them? You can see the values on a block explorer, but to decode the values from a raw block you'd need to understand the message protocol format.

morsecoder 2016-04-16T00:50:58.260

I'd like to see them for now but additionally access them by code eventually. I've found the getblock method which can be used to display the merkle tree, but how do I find the blockHash parameter to pass to that method, for say the last block or last 10 blocks? Not sure where I can find those blockHashesAnthony 2016-04-16T00:58:03.700

Answers

1

Look at a block on a block explorer.

enter image description here

Here the Prev_Hash is called 'Previous Block' and the Tx_Root is called 'Merkle Root'.

For more technical info, take a look at the Protocol Documentation.

morsecoder

Posted 2016-04-15T23:44:48.207

Reputation: 12 624

Awesome, thanks. Can I use getblock to access this via the Blockchain API? And also how can I find the hash of the latest block? Thanks!Anthony 2016-04-16T01:06:32.077

I'm not an expert on Blockchain's API, but their documentation is here: https://blockchain.info/api/blockchain_api. For the latest block, it looks like you can use: https://blockchain.info/latestblock.

morsecoder 2016-04-16T01:09:20.763

Whoops, I meant to say use getblock to access this via the Bitcoin API, typo.Anthony 2016-04-16T01:14:04.353

You mean the Bitcoin Core RPC command getblock? Yes, it reports those values.Pieter Wuille 2016-04-17T08:32:11.347