<p>When working in regTest (or testNet) mode the '<a href="https://en.bitcoin.it/wiki/Protocol_specification#Common_structures" rel="nofollow">magic number</a>' identifying the start of each block is different to what it is for the live network.  The parser you mention may well use the magic number to identify the start of blocks. This may be the cause of your problem and why it is not finding any blocks in the regTest blockchain file.</p>

<p><code>RegTest (and testNet): 0xdab5bffa
 Live: 0xd9b4bef9</code></p>

<p>Hence it is likely that the parser code needs to be modified to work with regTest/testNet magic numbers.</p>

CC BY-SA 3.0
2014-09-27T17:52:39.067Z
2014-09-27T17:52:39.067Z
Fred Tingey
<p>Has anyone used this blockchain parser for Bitcoin <a href="https://code.google.com/p/blockchain/" rel="nofollow">https://code.google.com/p/blockchain/</a> ?</p>

<p><a href="http://codesuppository.blogspot.in/2014/01/a-command-line-interface-for-blockchain.html" rel="nofollow">http://codesuppository.blogspot.in/2014/01/a-command-line-interface-for-blockchain.html</a></p>

<p>I tried to parse blockchain generated by Bitcoin (<strong>bitcoind -regtest -daemon</strong>) in <strong>regtest</strong> mode but it is not reading(parsing) it correctly. </p>

<p>I copied the file <strong>blk00000.dat</strong> (this is the <strong>only file generated in regtest mode</strong>) to <strong>/home/somesh/Desktop/blockchain-read-only/</strong> folder.  I executed the command: <br>  <code>./blockchain.out /home/somesh/Desktop/blockchain-read-only</code></p>

<p>output:<br></p>

<pre><code>Successfully opened block-chain input file '/home/somesh/Desktop/blockchain-read-only/blk00000.dat'
Welcome ...
Commands available: ... (then prints all the available commands)
</code></pre>

<p>then I selected scanning option</p>

<pre><code>scan
</code></pre>

<p>The following is the message I get on scanning </p>

<pre><code>Scanning block-chain re-started from block 0 up to a maximum of 500000 blocks..&lt;br&gt;
Warning: Missing block-header; scanning for next one.
Failed to open block-chain input file '/home/somesh/Desktop/blockchain-read-only/blk00001.dat'&lt;br&gt;
Finished scanning block headers. Built block-chain with 0 blocks found..
</code></pre>

<p>It is working fine for Bitcoin's real blockchain but not for the blockchain generated in regtest mode.</p>

<p>I think the parser is not able to find the block header in blk00000.dat and is skipping to next file.</p>

<p><strong>Warning: Missing block-header; scanning for next one.</strong><br></p>

<p>what changes do I have to make ?</p>

CC BY-SA 3.0
2014-09-25T12:59:03.707Z
First: are you sure it is looking for the files in the right directory?  `ls /home/somesh/Desktop/blockchain-read-only/blk00001.dat` confirms that the file exists?  (Normally it would be in a subdirectory called `blocks`.)  Can you also include the exact command you are running, with all arguments?
Nate Eldredge
CC BY-SA 3.0
2014-09-25T15:25:44.250Z
I updated my question with the commands that I used.
somesh
<blockchain><bitcoind>
Blockchain Parser not working on blockchain generated in regtest mode using bitcoind. Any help?
somesh
# Blockchain Parser not working on blockchain generated in regtest mode using bitcoind. Any help?

(Asked by: username_0 on 2014-09-24)

Has anyone used this blockchain parser for Bitcoin https://code.google.com/p/blockchain/ ?
http://codesuppository.blogspot.in/2014/01/a-command-line-interface-for-blockchain.html
I tried to parse blockchain generated by Bitcoin (bitcoind -regtest -daemon) in regtest mode but it is not reading(parsing) it correctly. 
I copied the file blk00000.dat (this is the only file generated in regtest mode) to /home/username_0/Desktop/blockchain-read-only/ folder.  I executed the command:  ./blockchain.out /home/username_0/Desktop/blockchain-read-only
output:
Successfully opened block-chain input file '/home/username_0/Desktop/blockchain-read-only/blk00000.dat'
Welcome ...
Commands available: ... (then prints all the available commands)

then I selected scanning option
scan

The following is the message I get on scanning 
Scanning block-chain re-started from block 0 up to a maximum of 500000 blocks..
Warning: Missing block-header; scanning for next one.
Failed to open block-chain input file '/home/username_0/Desktop/blockchain-read-only/blk00001.dat'
Finished scanning block headers. Built block-chain with 0 blocks found..

It is working fine for Bitcoin's real blockchain but not for the blockchain generated in regtest mode.
I think the parser is not able to find the block header in blk00000.dat and is skipping to next file.
Warning: Missing block-header; scanning for next one.
what changes do I have to make ?

**Tags:** blockchain, bitcoind

> **Comments:**
> **username_1**: First: are you sure it is looking for the files in the right directory?  `ls /home/username_0/Desktop/blockchain-read-only/blk00001.dat` confirms that the file exists?  (Normally it would be in a subdirectory called `blocks`.)  Can you also include the exact command you are running, with all arguments?  
> **username_0**: I updated my question with the commands that I used.  

---

## 1 answers

### Answer by username_2 on 2014-09-27. Score: 4

When working in regTest (or testNet) mode the '[magic number](https://en.bitcoin.it/wiki/Protocol_specification#Common_structures)' identifying the start of each block is different to what it is for the live network. The parser you mention may well use the magic number to identify the start of blocks. This may be the cause of your problem and why it is not finding any blocks in the regTest blockchain file.

`RegTest (and testNet): 0xdab5bffa
Live: 0xd9b4bef9`

Hence it is likely that the parser code needs to be modified to work with regTest/testNet magic numbers.


---

