Search code examples
postgresqlapirpcbitcoinbitcoind

Populating PostgreSQL DB using bitcoind RPCs and API


I'm attempting to create a PostgreSQL database with block data on:

Hash, total transactions, height, time, merkle root, confirmations, difficulty, bits, size (bytes), version, nonce

And transaction data on:

Hash, Txid, Size (bytes), confirmations, fee, time, amount, addresses

I'm struggling to figure out the best way to use the bitcoin daemon RPCs/API to get the data, so that I can put it into the database.

Cheers!


Solution

  • First, you have to have acces to the information of blocks and transactions. Choose one of these

    Then, query every block and its transactions, from block 0 to current one (496764 as of now) and store this information through SQL to your PostgreSQL database.

    To query blocks and transactions from a Bitcoin node, use the JSON/RPC API.