ChainLib Bitcoin
A library for building Bitcoin chain based databases.
Getting Started
Install
git clone git@github.com:bitpay/chainlib-bitcoin.gitcd chainlib-bitcoinnpm install
Example Usage
var BitcoinNode = RPCNode; var privkey = 'tprv8ZgxMBicQKsPdj1QowoT9z1tY5Et38qaMjCHZVoPdPFb6narfmYkqTygEVHfUmY78k3HcaEpkyNCAQDANaXtwNe1HLFvcA7nqYj1B7wTSTo'; var configuration = db: xprivkey: privkey path: './bitcoin-testnet.db' p2p: addrs: ip: v4: '127.0.0.1' port: 18333 dnsSeed: false rpc: host: 'localhost' port: 18332 user: 'user' pass: 'password' ssl: false sslStrict: false testnet: true; var node = configuration; nodechain;
API Documentation
Get Unspent Outputs
var address = '15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2';var includeMempool = true;node;
View Balances
var address = '15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2';var includeMempool = true;node;
Get Outputs
var address = '15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2';var includeMempool = true;node;
Get Transaction
var txid = 'c349b124b820fe6e32136c30e99f6c4f115fce4d750838edf0c46d3cb4d7281e';var includeMempool = true;node;
Get Block
var blockHash = '00000000d17332a156a807b25bc5a2e041d2c730628ceb77e75841056082a2c2';node;
Tests and Coverage
To run all of the tests:
npm run testnpm run coverage
To run a single test file in watch mode (useful for developing):
mocha -w -R spec test/db.unit.js