Home

Awesome

bitcoind-rpc-client

NPM Package build status Coverage Status js-standard-style Dependency status

Bitcoind RPC client with blackjack and hookers.

Current rpc client support promises and callbacks.

Installation

npm install bitcoind-rpc-client

Commands

You can find list of all available commands in source code.

Examples

Create client

var client = new RpcClient({
  host: '127.0.0.1',
  port: 18332
});
client.set('user', 'bitcoinrpc')

getnewaddress with callback

client.getNewAddress(function (err, result) {
  console.log(err, result) // null, {result: {...}, error: null}
})

getnewaddress with promise

client.getNewAddress().then(function (result) {
  console.log(result) // {result: {...}, error: null}
})

alias of getnewaddress with promise

client.getnewaddress().then(function (result) {
  console.log(result) // {result: {...}, error: null}
})

getnewaddress using cmd

client.cmd('getnewaddress').then(function (result) {
  console.log(result) // {result: {...}, error: null}
})

batch (array form)

client.batch([
  {method: 'getnewaddress', params: ['myaccount']},
  {method: 'getnewaddress', params: ['myaccount']}
])
.then(function (result) {
  console.log(result) // [{result: {...}, error: null}, {result: {...}, error: null}]
})

batch (chained form)

client.batch()
  .getInfo()
  .clear()
  .getNewAddress('myaccount')
  .getNewAddress('secondaccount')
  .call()
  .then(function (result) {
    console.log(result) // [{result: {...}, error: null}, {result: {...}, error: null}]
  })

License

This software is licensed under the MIT License.