Author

Topic: block header parsing question from live blockchain (Read 94 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
--snip--
YES that is what i did, in windows. I think i will do it in linux later for easier.
I see in windows, it does download lot of blockchain files in *.data format although i am still not sure how those *dat files are organized.
My end goal is to be able to parse whole block.

Using Linux indeed is easier since many guide/tutorial for Bitcoin Core use Linux-based OS. However, you don't need to read and parse blk*dat files (which store Bitcoin blockchain data) manually when you could just use JSON-RPC which provided by Bitcoin Core.
full member
Activity: 394
Merit: 101
You can use Bitcoin Core to obtain that data. Here's an example,

Code:
$ getblockhash 700000
0000000000000000000590fc0f3eba193a278534220b2b37e9849e1a770ca959
$ getblockheader 0000000000000000000590fc0f3eba193a278534220b2b37e9849e1a770ca959
{
  "hash": "0000000000000000000590fc0f3eba193a278534220b2b37e9849e1a770ca959",
  "confirmations": 84720,
  "height": 700000,
  "version": 1073733636,
  "versionHex": "3fffe004",
  "merkleroot": "1f8d213c864bfe9fb0098cecc3165cce407de88413741b0300d56ea0f4ec9c65",
  "time": 1631333672,
  "mediantime": 1631331088,
  "nonce": 2881644503,
  "bits": "170f48e4",
  "difficulty": 18415156832118.24,
  "chainwork": "0000000000000000000000000000000000000000216dd8dc61fdffabb624feeb",
  "nTx": 1276,
  "previousblockhash": "0000000000000000000aa3ce000eb559f4143be419108134e0ce71042fc636eb",
  "nextblockhash": "00000000000000000002f39baabb00ffeb47dbdb425d5077baa62c47482b7e92"
}
$ getblockheader 0000000000000000000590fc0f3eba193a278534220b2b37e9849e1a770ca959 false
04e0ff3feb36c62f0471cee034811019e43b14f459b50e00cea30a000000000000000000659cecf4a06ed500031b741384e87d40ce5c16c3ec8c09b09ffe4b863c218d1f282d3c61e4480f17d767c2ab

Although if you don't want to download whole Bitcoin blockchain, you could just get raw block data from block explorer and extract raw block header manually.

YES that is what i did, in windows. I think i will do it in linux later for easier.
I see in windows, it does download lot of blockchain files in *.data format although i am still not sure how those *dat files are organized.
My end goal is to be able to parse whole block.
hero member
Activity: 644
Merit: 661
- Leo -
Not entirely certain that Blockchair[1] would give you the information you need, but it is a tool I use when I want to get some information about the current or next block[2].

[1] https://blockchair.com/
[2] https://blockchair.com/bitcoin/block/785043

- Jay -
full member
Activity: 394
Merit: 101
After years of interruption,  I am studying internals of bitcoin again,  starting with block header format.  I wanna see in real life,  from blockchainfo info, I can see contents of certain blocks in a web formatted output,  but nowhere seen the block header.
Is there a way to see block header from live public block chain? Any utility?
Following options are fine for me:
1. Using some utility dump header
2. Using some utility fetch (from public chain) entire block including block header write my own parser. Thanks
Jump to: