https://github.com/fanatid/bitcoind-rpc-client
Connect to Bitcoin Core via JSON-RPC in JavaScript.
https://github.com/fanatid/bitcoind-rpc-client
Last synced: 6 months ago
JSON representation
Connect to Bitcoin Core via JSON-RPC in JavaScript.
- Host: GitHub
- URL: https://github.com/fanatid/bitcoind-rpc-client
- Owner: fanatid
- License: mit
- Created: 2015-08-22T14:39:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-24T06:50:40.000Z (over 9 years ago)
- Last Synced: 2024-04-16T18:25:01.857Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cryptocoinjs - bitcoin
README
# bitcoind-rpc-client
[](https://www.npmjs.org/package/bitcoind-rpc-client)
[](http://travis-ci.org/fanatid/bitcoind-rpc-client)
[](https://coveralls.io/r/fanatid/bitcoind-rpc-client)
[](https://github.com/feross/standard)
[](https://david-dm.org/fanatid/bitcoind-rpc-client#info=dependencies)Bitcoind RPC client with blackjack and hookers.
Current rpc client support promises and callbacks.
## Installation
```bash
npm install bitcoind-rpc-client
```## Commands
You can find list of all available commands in [source code](blob/master/src/methods.js).
## Examples
### Create client
```js
var client = new RpcClient({
host: '127.0.0.1',
port: 18332
});
client.set('user', 'bitcoinrpc')
```### getnewaddress with callback
```js
client.getNewAddress(function (err, result) {
console.log(err, result) // null, {result: {...}, error: null}
})
```### getnewaddress with promise
```js
client.getNewAddress().then(function (result) {
console.log(result) // {result: {...}, error: null}
})
```### alias of getnewaddress with promise
```js
client.getnewaddress().then(function (result) {
console.log(result) // {result: {...}, error: null}
})
```### getnewaddress using `cmd`
```js
client.cmd('getnewaddress').then(function (result) {
console.log(result) // {result: {...}, error: null}
})
```### batch (array form)
```js
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)
```js
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.