1

I'm looking for a way to extract some data from the latest downloaded bitcoin blockchain. In particular I'm interested in extracting the whole transaction network, so input and output public keys used in each transaction, the transaction date, hash, block hash and BTC amount. I tried several solutions so far with no luck:

Bitcoin-Transaction-Network-Extraction

rusty-blockparser

bitcointools

BitcoinDatabaseGenerator

BCGraph

I've had some luck with bitcoindatabasegenerator and rusty-blockparser, but while these tools succesfully extract the output PKs, input PKs are nowhere to be found in the resulting files.

Summarizing, I'm looking for something like this to produce a network visualization of bitcoin transactions:

|Source PK(s) (BTC)| ------> Transaction ------> |Target PK(s) (BTC)|

Im not really an expert in coding so this makes everything more complicated for me. Can you suggest me a way to extract this data from downloaded Blk files?

Any help would be greatly appreciated!

1 Answer 1

-2
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 ) :
    QString ( DATA_ROOT "\\blk00%1.dat" ).arg ( i );
}
5
  • This seems to be missing a class definition at least. Commented Mar 18, 2017 at 17:01
  • this piece of code is only a demonstration that blockchain parsing is very simple task
    – amaclin
    Commented Mar 18, 2017 at 17:59
  • 1
    Ok, but it's not an answer. You don't explain what it does, why it works, what it needs. Commented Mar 18, 2017 at 18:20
  • this is an answer for a question "Is there any tool to extract the bitcoin transaction [network] from the blockchain?". the short answer is: "yes, there is. here is a proof that such tool exists"
    – amaclin
    Commented Mar 18, 2017 at 23:34
  • 1
    I'm downvoting this because it gives no context. Just a piece of code that doesn't even compile is not informative. Commented Mar 19, 2017 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.