But how to parse those files?
It is not too difficult to parse bitcoin blockchain if you have programming skills and know what you want to do. Have a look to my piece of code - this is just a working example that parsing is easy. Of course, you have to write code in your favorite language for your task
#include <QTimer>
#include "BlockChain.h"
#include "Util.h"
#include "MyByteArray.h"
#include "Target.h"
BlockChain::BlockChain ( QObject* parent ) : QFile ( parent ), blkFile ( START_BLOCK )
{
connect ( this, SIGNAL ( block ( const QByteArray& ) ), parent, SLOT ( block ( const QByteArray& ) ) );
connect ( this, SIGNAL ( doneFile ( ) ), parent, SLOT ( doneFile ( ) ) );
QTimer::singleShot ( 0, this, SLOT ( start ( ) ) );
}
void BlockChain::start ( )
{
setFileName ( blkFileName ( blkFile++ ) );
if ( !open ( QIODevice::ReadOnly ) )
{
_trace ( QString ( "cant open [%1]" ).arg ( fileName ( ) ) )
emit block ( QByteArray ( ) );
deleteLater ( );
}
else
{
_trace ( QString ( "processing [%1]" ).arg ( fileName ( ) ) )
QTimer::singleShot ( 0, this, SLOT ( next ( ) ) );
}
}
void BlockChain::next ( )
{
if ( pos ( ) < size ( ) )
{
quint32 magic;
quint32 sz ( read ( (char*)&magic, 4 ) );
while ( !magic && pos ( ) < size ( ) - 4 )
read ( (char*)&magic, 4 );
xassert ( ( ( magic == MAGIC_ID ) || !magic ) && ( sz == 4 ) )
if ( magic )
{
read ( (char*)&sz, 4 );
emit block ( read ( sz ) );
QTimer::singleShot ( 0, this, SLOT ( next ( ) ) );
return;
}
}
close ( );
emit doneFile ( );
QTimer::singleShot ( 0, this, SLOT ( start ( ) ) );
}
const QString BlockChain::blkFileName ( const int i ) const
{
return
( i < 10 ) ? QString ( DATA_ROOT "\\blk0000%1.dat" ).arg ( i ) :
( i < 100 ) ? QString ( DATA_ROOT "\\blk000%1.dat" ).arg ( i ) :
( i < 1000 ) ? QString ( DATA_ROOT "\\blk00%1.dat" ).arg ( i ) :
QString ( DATA_ROOT "\\blk0%1.dat" ).arg ( i );
}