# bitcored-rpc-neobitcoin

> neobitcoin Client Library to connect to neobitcoin Core (neobitcoind) via RPC

Latest version **1.2.0** (published 2020-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install bitcored-rpc-neobitcoin
pnpm add bitcored-rpc-neobitcoin
yarn add bitcored-rpc-neobitcoin
bun add bitcored-rpc-neobitcoin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2020-06-21 |
| First published | 2020-06-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 41.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Stephen Pair |
| Maintainers | neobitcoin |
| Keywords | neobitcoin, rpc |

## Links

- npm: https://www.npmjs.com/package/bitcored-rpc-neobitcoin
- Repository: https://github.com/neobitcoin-official/bitcored-rpc-neobitcoin
- Issues: https://github.com/neobitcoin-official/bitcored-rpc-neobitcoin/issues
- npm.io page: https://npm.io/package/bitcored-rpc-neobitcoin

## Dependencies (2)

- [async](https://npm.io/package/async.md) ^2.6.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1

## Recent versions

- 1.2.0 (latest) — 2020-06-21

## README

bitcored-rpc-neobitcoin.js
===============

[![NPM Package](https://img.shields.io/npm/v/bitcored-rpc-neobitcoin.svg?style=flat-square)](https://www.npmjs.org/package/bitcored-rpc-neobitcoin)
[![Build Status](https://img.shields.io/travis/bitcored-rpc-neobitcoin.svg?branch=master&style=flat-square)](https://travis-ci.org/bitcored-rpc-neobitcoin)
[![Coverage Status](https://img.shields.io/coveralls/bitcored-rpc-neobitcoin.svg?style=flat-square)](https://coveralls.io/r/bitcored-rpc-neobitcoin?branch=master)

A client library to connect to neobitcoin Core RPC in JavaScript.

## Get Started

bitcored-rpc-neobitcoin.js runs on [node](http://nodejs.org/), and can be installed via [npm](https://npmjs.org/):

```bash
npm install bitcored-rpc-neobitcoin
```

## RpcClient

Config parameters :

	- protocol : (string - optional) - (default: 'https') - Set the protocol to be used. Either `http` or `https`.
	- user : (string - optional) - (default: 'user') - Set the user credential.
	- pass : (string - optional) - (default: 'pass') - Set the password credential.
	- host : (string - optional) - (default: '127.0.0.1') - The host you want to connect with.
	- port : (integer - optional) - (default: 3105) - Set the port on which perform the RPC command.

Promise vs callback based

  - `require('bitcoind-rpc-neobitcoin/promise')` to have promises returned
  - `require('bitcoind-rpc-neobitcoin')` to have callback functions returned

## Examples

Config:
```javascript
var config = {
    protocol: 'http',
    user: 'neobitcoin',
    pass: 'local321',
    host: '127.0.0.1',
    port: 13105
};
```

Promise based:
```javascript
var RpcClient = require('bitcoind-rpc-neobitcoin/promise');
var rpc = new RpcClient(config);

rpc.getRawMemPool()
    .then(ret => {
        return Promise.all(ret.result.map(r => rpc.getRawTransaction(r)))
    })
    .then(rawTxs => {
        rawTxs.forEach(rawTx => {
            console.log(`RawTX: ${rawTx.result}`);
        })
    })
    .catch(err => {
        console.log(err)
    })

```

Callback based (legacy):
```javascript
var run = function() {
  var bitcore = require('bitcore');
  var RpcClient = require('bitcoind-rpc-neobitcoin');
  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();
};
```

## Help

You can dynamically access to the help of each method by doing
```
const RpcClient = require('bitcoind-rpc-neobitcoin');
var client = new RPCclient({
    protocol:'http',
    user: 'neobitcoin',
    pass: 'local321',
    host: '127.0.0.1',
    port: 13105
});

var cb = function (err, data) {
    console.log(data)
};
client.help(cb); //Get full help
client.help('getinfo',cb); //Get help of specific method
```
## License

**Code released under [the MIT license](https://github.com/bitpay/bitcore/blob/master/LICENSE).**

Copyright 2013-2014 BitPay, Inc.

---
_Source: https://npm.io/package/bitcored-rpc-neobitcoin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
