@owstack/bitcoind-rpc
Bitcoin Client Library to connect to Bitcoin Core via RPC.
Last updated 2 years ago by niahmiah .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @owstack/bitcoind-rpc 
SYNC missed versions from official npm registry.

bitcoind-rpc

NPM Package Build Status Coverage Status

A client library to connect to Bitcoin Core RPC in JavaScript.

Attribution

This repository was created by copy forking bitcoind-rpc commit da5d5ec.

Get Started

bitcoind-rpc.js runs on node, and can be installed via npm:

npm install bitcoind-rpc

Examples

var run = function() {
  var btccore = require('btccore');
  var RpcClient = require('bitcoind-rpc');

  var config = {
    protocol: 'http',
    user: 'user',
    pass: 'pass',
    host: '127.0.0.1',
    port: '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 btccore.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.

Copyright 2017 Open Wallet Stack

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

2 Versions

  • 1.0.0                                ...           2 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (5)

Copyright 2014 - 2017 © taobao.org |