Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bitpay/bitcoind-rpc
A client library to connect to Bitcoin Core RPC in JavaScript.
https://github.com/bitpay/bitcoind-rpc
Last synced: 4 days ago
JSON representation
A client library to connect to Bitcoin Core RPC in JavaScript.
- Host: GitHub
- URL: https://github.com/bitpay/bitcoind-rpc
- Owner: bitpay
- License: mit
- Created: 2015-01-16T00:50:50.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-08T08:14:04.000Z (almost 2 years ago)
- Last Synced: 2024-11-12T19:43:45.668Z (30 days ago)
- Language: JavaScript
- Size: 172 KB
- Stars: 175
- Watchers: 16
- Forks: 315
- Open Issues: 25
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cryptocoinjs - bitcoin
README
bitcoind-rpc.js
===============[![NPM Package](https://img.shields.io/npm/v/bitcoind-rpc.svg?style=flat-square)](https://www.npmjs.org/package/bitcoind-rpc)
[![Build Status](https://img.shields.io/travis/bitpay/bitcoind-rpc.svg?branch=master&style=flat-square)](https://travis-ci.org/bitpay/bitcoind-rpc)
[![Coverage Status](https://img.shields.io/coveralls/bitpay/bitcoind-rpc.svg?style=flat-square)](https://coveralls.io/r/bitpay/bitcoind-rpc?branch=master)A client library to connect to Bitcoin Core RPC in JavaScript.
## Get Started
bitcoind-rpc.js runs on [node](http://nodejs.org/), and can be installed via [npm](https://npmjs.org/):
```bash
npm install bitcoind-rpc
```## Examples
```javascript
var run = function() {
var bitcore = require('bitcore');
var RpcClient = require('bitcoind-rpc');var config = {
protocol: 'http',
user: 'user',
pass: 'pass',
host: '127.0.0.1',
port: '18332',
};// config can also be an url, e.g.:
// var config = 'http://user:[email protected]:18332';var rpc = new RpcClient(config);
var txids = [];
function showNewTransactions() {
rpc.getRawMemPool(function (err, ret) {
if (err) {
console.error(err);
return setTimeout(showNewTransactions, 10000);
}function batchCall() {
ret.result.forEach(function (txid) {
if (txids.indexOf(txid) === -1) {
rpc.getRawTransaction(txid);
}
});
}rpc.batch(batchCall, function(err, rawtxs) {
if (err) {
console.error(err);
return setTimeout(showNewTransactions, 10000);
}rawtxs.map(function (rawtx) {
var tx = new bitcore.Transaction(rawtx.result);
console.log('\n\n\n' + tx.id + ':', tx.toObject());
});txids = ret.result;
setTimeout(showNewTransactions, 2500);
});
});
}showNewTransactions();
};
```## License
**Code released under [the MIT license](https://github.com/bitpay/bitcore/blob/master/LICENSE).**
Copyright 2013-2018 BitPay, Inc.