JSPM

paccoind-rpc

0.7.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q23258F
  • License MIT

$PAC Client Library to connect to PAC Core via RPC

Package Exports

  • paccoind-rpc

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (paccoind-rpc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

paccoind-rpc.js

Build Status

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

Get Started

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

npm install paccoind-rpc

Examples

var run = function() {
  var bitcore = require('bitcore-pac');
  var RpcClient = require('paccoind-rpc');

  var config = {
    protocol: 'http',
    user: 'user',
    pass: 'pass',
    host: '127.0.0.1',
    port: '17111',
  };

  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.

Copyright 2013-2014 BitPay, Inc.