updated readme
This commit is contained in:
parent
655ac37ba0
commit
02b2d165d7
97
README.md
97
README.md
@ -1,25 +1,87 @@
|
|||||||
# bitcoind.js
|
bitcoind.js
|
||||||
|
=======
|
||||||
|
[](https://travis-ci.org/bitpay/bitcoind.js)
|
||||||
|
[](https://coveralls.io/r/bitpay/bitcoind.js)
|
||||||
|
|
||||||
A Node.js module that adds a native interface to Bitcoin Core for querying information about the Bitcoin blockchain. Bindings are linked to Bitcore Core compiled as a shared library.
|
A Node.js module that adds a native interface to Bitcoin Core for querying information about the Bitcoin blockchain. Bindings are linked to Bitcore Core compiled as a shared library.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone git@github.com:bitpay/bitcoind.js.git
|
||||||
|
cd bitcoind.js
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
## Example Usage
|
## Example Usage
|
||||||
|
|
||||||
``` js
|
```js
|
||||||
var bitcoind = require('bitcoind.js')({
|
|
||||||
|
var BitcoinNode = require('bitcoind.js');
|
||||||
|
|
||||||
|
var configuration = {
|
||||||
directory: '~/.bitcoin',
|
directory: '~/.bitcoin',
|
||||||
testnet: true
|
testnet: true
|
||||||
|
};
|
||||||
|
|
||||||
|
var node = new BitcoinNode(configuration);
|
||||||
|
|
||||||
|
node.chain.on('addblock', function(block) {
|
||||||
|
console.log('New Best Tip:', block.hash);
|
||||||
});
|
});
|
||||||
|
|
||||||
bitcoind.on('ready', function() {
|
```
|
||||||
|
|
||||||
bitcoind.getBlock(blockHash, function(err, block) {
|
## API Documentation
|
||||||
// block is a node buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
bitcoind.close(function(err, result) {
|
Get Unspent Outputs
|
||||||
// bitcoind is stopped
|
|
||||||
});
|
```js
|
||||||
|
var address = '15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2';
|
||||||
|
var includeMempool = true;
|
||||||
|
node.getUnspentOutputs(address, includeMempool, function(err, unspentOutputs) {
|
||||||
|
//...
|
||||||
});
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
View Balances
|
||||||
|
|
||||||
|
```js
|
||||||
|
var address = '15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2';
|
||||||
|
var includeMempool = true;
|
||||||
|
node.getBalance(address, includeMempool, function(err, balance) {
|
||||||
|
//...
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Get Outputs
|
||||||
|
|
||||||
|
```js
|
||||||
|
var address = '15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2';
|
||||||
|
var includeMempool = true;
|
||||||
|
node.getOutputs(address, includeMempool, function(err, outputs) {
|
||||||
|
//...
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Get Transaction
|
||||||
|
|
||||||
|
```js
|
||||||
|
var txid = 'c349b124b820fe6e32136c30e99f6c4f115fce4d750838edf0c46d3cb4d7281e';
|
||||||
|
var includeMempool = true;
|
||||||
|
node.getTransaction(txid, includeMempool, function(err, transaction) {
|
||||||
|
//...
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Get Block
|
||||||
|
|
||||||
|
```js
|
||||||
|
var blockHash = '00000000d17332a156a807b25bc5a2e041d2c730628ceb77e75841056082a2c2';
|
||||||
|
node.getBlock(blockHash, function(err, block) {
|
||||||
|
//...
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -31,14 +93,14 @@ $ tail -f ~/.bitcoin/debug.log
|
|||||||
|
|
||||||
^C (SIGINT) will call `StartShutdown()` in bitcoind on the node thread pool.
|
^C (SIGINT) will call `StartShutdown()` in bitcoind on the node thread pool.
|
||||||
|
|
||||||
## Documentation
|
## Daemon Documentation
|
||||||
|
|
||||||
- `bitcoind.start([options], [callback])` - Start the JavaScript Bitcoin node.
|
- `daemon.start([options], [callback])` - Start the JavaScript Bitcoin node.
|
||||||
- `bitcoind.getBlock(blockHash|blockHeight, callback)` - Get any block asynchronously by block hash or height as a node buffer.
|
- `daemon.getBlock(blockHash|blockHeight, callback)` - Get any block asynchronously by block hash or height as a node buffer.
|
||||||
- `bitcoind.getTransaction(txid, blockhash, callback)` - Get any tx asynchronously by reading it from disk.
|
- `daemon.getTransaction(txid, blockhash, callback)` - Get any tx asynchronously by reading it from disk.
|
||||||
- `bitcoind.log(message), bitcoind.info(message)` - Log to standard output.
|
- `daemon.log(message), daemon.info(message)` - Log to standard output.
|
||||||
- `bitcoind.error(message)` - Log to stderr.
|
- `daemon.error(message)` - Log to stderr.
|
||||||
- `bitcoind.close([callback])` - Stop the JavaScript bitcoin node safely, the callback will be called when bitcoind is closed. This will also be done automatically on `process.exit`. It also takes the bitcoind node off the libuv event loop. If the bitcoind object is the only thing on the event loop. Node will simply close.
|
- `daemon.close([callback])` - Stop the JavaScript bitcoin node safely, the callback will be called when bitcoind is closed. This will also be done automatically on `process.exit`. It also takes the bitcoind node off the libuv event loop. If the daemon object is the only thing on the event loop. Node will simply close.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
@ -147,3 +209,4 @@ Copyright 2013-2015 BitPay, Inc.
|
|||||||
|
|
||||||
- bitcoin: Copyright (c) 2009-2015 Bitcoin Core Developers (MIT License)
|
- bitcoin: Copyright (c) 2009-2015 Bitcoin Core Developers (MIT License)
|
||||||
- bcoin (some code borrowed temporarily): Copyright Fedor Indutny, 2014.
|
- bcoin (some code borrowed temporarily): Copyright Fedor Indutny, 2014.
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user