bitcoind-rpc-client

0.3.1 • Public • Published

bitcoind-rpc-client

NPM Package build status Coverage Status Dependency status

js-standard-style

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

Code released under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i bitcoind-rpc-client

Weekly Downloads

3

Version

0.3.1

License

MIT

Last publish

Collaborators

  • fanatid