How do I get Bitcoin block header data with nonce?

0

1

How do I get Bitcoin block header data with nonce?

There are tens of so called blockchain explorer websites, tens more offering on-line Bitcoin blockchain parsing.

But all I need are historic Bitcoin blockchain header data only for off-line mode study.

In theory I can set up blockchain parser on my own but I need to download full blockchain first and set up parser.

Since I live on wireless Internet 3G, it's not feasible to download 500GB data, so I would prefer an option just to buy historic Bitcoin blockchain header only data, no overheads, no transaction data.

If you know such place or can offer such download, let me know your terms.

darius

Posted 2018-01-28T21:46:31.560

Reputation: 55

I believe that bitcoin-core will sync all the headers first before syncing the block chain. Perhaps it would be enough to pause/stop syncing after that point? mynt 2018-01-29T00:50:09.927

Answers

3

There is no need to buy any data, and if someone is offering to sell you block headers, then you are being scammed.

The Bitcoin network protocol supports transmitting just block headers. So you can just use or create a software which can speak the Bitcoin network protocol and download just the block headers. The getheaders message is what you need in order to request the headers from a node, in addition to the normal network protocol stuff. Since block headers are just 80 bytes, the entire download will be 80*506612 = 40528960 bytes = 40.528960 MB.

Instead of writing such a software, you can also use Electrum. Electrum is a SPV wallet, but it downloads all of the block headers. If you create an Electrum wallet and let it sync (syncs very quickly), you will find a file in the Electrum data directory named blockchain_headers. This file contains all of the block headers in raw form (so just as bytes). You can then parse that as per the block header format.

Andrew Chow

Posted 2018-01-28T21:46:31.560

Reputation: 40 910

Thank you Andrew for your excellent answer. 40MB download looks better than 500GB download.Just downloaded Electrum wallet from https://electrum.org/#download and installed another one by installer but it is not supported by Windows XP 32bit. What is an exact name of block headers file in blockchain_headers Electrum directory? Maybe there is an option to download this file from the Internet directly.

darius 2018-01-29T13:47:48.750

Just downloaded blockchain_headers from https://headers.electrum.org/blockchain_headers . Size of a file is 36.4 MB vs. 40.528950 MB not sure if the file is last updated.

darius 2018-01-29T14:13:01.203

The file you downloaded is probably out of date.Andrew Chow 2018-01-29T15:29:55.870

Thank you Andrew for your best answer. I would prefer Electrum wallet based solution due to limits set on getheaders: The getheaders message is nearly identical to the getblocks message, with one minor difference: the inv reply to the getblocks message will include no more than 500 block header hashes; the headers reply to the getheaders message will include as many as 2,000 block headers. BTW Could you put blockchain_headers file for download ?darius 2018-01-29T23:48:54.233

Here's the file from my Electrum. It's up to block 506732. https://drive.google.com/file/d/160fTtPS1eIv1QVH4RL785sMCCkt3Crbx/view?usp=sharing

Andrew Chow 2018-01-30T00:03:17.117

Thank you Andrew for your excellent help. Your answer and your comments are worth every bitcoin mined ever. My first download is 477637 block headers long. blochchain_headers file is excellent for parsing due to its clear format clocked every 80 bytes or 5 lines in Hex editor (I will try to parse it with JS) https://hexed.it/ thank you once again . I verified the file against nonce read from https://api.blockchair.com/bitcoin/blocks?q=id(3)

darius 2018-01-30T00:18:58.487