0.1.1 • Published 3 years ago

bitcoin-transaction-indexer v0.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

bitcoin-transaction-indexer

Listen to a bitcoin node ZeroMQ events block and transaction notifications and index them in a Hyperbee.

npm install bitcoin-transaction-indexer

Usage

const Indexer = require('./')
const Hypercore = require('hypercore-x')
const ram = require('random-access-memory')

const core = new Hypercore(ram, { valueEncoding: 'utf-8' })
core.ready().then(() => {
  // Assuming there is a local bitcoin node that enabled publish raw blocks and transactions in port 28332
  const index = new Indexer(core, { endpoint: 'tcp://127.0.0.1:28332' })
  index.start()
})

API

const index = new Indexer(feed, opts)

Instantiate new indexer. Feed is the Hypercore used by the Hyperbee instance.

const opts = {
  endpoint: 'tcp://...',  // Bitcoin node host + ZMQ publish port
}

index.start()

Start listening and indexing the blockchain.

Indexes

block!height!blockHeight

Stores block data hex hash

block!hash!blockId

Stores block data in JSON format

vout!scriptHash

Stores txid and vout index compact encoded

addr!address

Stores txid and vout index compact encoded

tx!txId

Stores transaction data