elasticsearch-blockchain
This node script queries your bitcoin-core client via RPC and inserts data into an elasticsearch index.
Prerequisites
- A fully synced bitcoin-core client.
- A running ElasticSearch node Note that the Elasticsearch index size is ~220GB when the process completes.
How does it work?
getLastHeight()
will check if an index namedblocks
already exists in your elasticsearch instance.- If the index does not exist, it will return
0
to therun()
function which will start the data gathering. If the index already exists it will query it to get the last inserted block height and will pass that value torun()
so the process will continue where it was last stopped. - Data is pulled via the bitcoin-core RPC in the following manner:
- Run
getBlockHash()
with the current block height. - Run
getBlock()
with the result. - Iterate through all block transactions and get
getRawTransction()
. - Get the TX information by running
decodeRawTransaction()
. - All trnasaction details for the given block are then flattened into block information under
block.txinfo
.