Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chromaway/blockchainjs
Bitcoin blockchain for wallets.
https://github.com/chromaway/blockchainjs
Last synced: 26 days ago
JSON representation
Bitcoin blockchain for wallets.
- Host: GitHub
- URL: https://github.com/chromaway/blockchainjs
- Owner: chromaway
- License: mit
- Created: 2015-01-28T12:35:24.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-02T23:11:09.000Z (over 8 years ago)
- Last Synced: 2024-11-07T19:47:37.867Z (about 1 month ago)
- Language: JavaScript
- Size: 483 KB
- Stars: 6
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cryptocoinjs - bitcoin
README
# blockchainjs
[![Version](http://img.shields.io/npm/v/blockchainjs.svg?style=flat-square)](https://www.npmjs.org/package/blockchainjs)
[![build status](https://img.shields.io/travis/chromaway/blockchainjs.svg?branch=master&style=flat-square)](http://travis-ci.org/chromaway/blockchainjs)
[![Coverage Status](https://img.shields.io/coveralls/chromaway/blockchainjs.svg?style=flat-square)](https://coveralls.io/r/chromaway/blockchainjs)
[![Dependency status](https://img.shields.io/david/chromaway/blockchainjs.svg?style=flat-square)](https://david-dm.org/chromaway/blockchainjs#info=dependencies)A pure JavaScript library for node.js and browsers for easy data exchange between wallets and bitcoin network.
## What is include blockchainjs?
blockchainjs have two abstraction level: Connector and Blockchain
Connector implements a common interface for remote service. For now available only one provider: [chromanode](https://github.com/chromaway/chromanode).
Blockchain implements a common interface between connector and your wallet. You can use Naive (trust all data from remove service) or Verified (SPV implementation).
In addition to Verified blockchainjs has Storage interface for store headers. Memory and LocalStorage available for now.
## API
* [Connector](docs/connector.md)
* [Chromanode](docs/connector.md#chromanode)
* [Blockchain](docs/blockchainapi.md)
* [Naive](docs/blockchainapi.md#naive)
* [Verified](docs/blockchainapi.md#verified)
* [Storage](docs/storageapi.md)
* [Memory](docs/storageapi.md#memory)
* [LocalStorage](docs/storageapi.md#localstorage)## Examples
### Show UTXO on address touched
```js
var blockchainjs = require('blockchainjs')
var connector = new blockchainjs.connector.Chromanode({networkName: 'testnet'})
var address = 'mp8XoMWnJzQwovninMdChQutPuhyHokJNc'function showUTXO(address) {
connector.addressesQuery([address], {status: 'unspent'})
.then(function (result) {
console.log('UTXO for ' + address + ':')
result.transactions.forEach(function (unspent) {
// var txOut = unspent.txid + ':' + unspent.outIndex
// console.log(txOut + ' has ' + unspent.value + ' satoshi')
// sorry, only txid and height available now
console.log('Unspent in txid: ' + unspent.txid)
})
if (result.transactions.length === 0) {
console.log('nothing...')
}
console.log('')
})
}connector.on(address, showUTXO)
connector.connect()
connector.subscribe({event: 'touchAddress', address: address})
showUTXO(address)
```### Show last header upon completion of sync process
```js
var blockchainjs = require('blockchainjs')var connector = new blockchainjs.connector.Chromanode({networkName: 'testnet'})
connector.connect()var storage = new blockchainjs.storage.Memory({
networkName: 'testnet',
compactMode: true
})var blockchain = new blockchainjs.blockchain.Verified(connector, {
storage: storage,
networkName: 'testnet',
testnet: true,
compactMode: true,
chunkHashes: blockchainjs.chunkHashes.testnet
})blockchain.on('syncStop', blockchainjs.util.makeSerial(function () {
return blockchain.getHeader(blockchain.latest.hash)
.then(function (header) {
console.log('Current header: ', header)
})
}))
```## License
Code released under [the MIT license](LICENSE).
Copyright 2015 Chromaway AB
## Todo
* migrate to bitcore (in tests)
* add karma
* add https://github.com/visionmedia/debug