Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bcdt

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bcdt

NodeJS client for btcd WebSocket API

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
0
Weekly downloads
 
Created
Source

btcd

NodeJS client for btcd WebSocket API. Written in CoffeeScript (and published to npm as compiled JavaScript).

Install

npm install btcd

Use

// Notice the "/ws" in the url.
var btcd = require('btcd')('wss://user:password@localhost:8334/ws',
                           __dirname + '/rpc.cert');

// All the jsonrpc calls are available as methods:
btcd.getblockhash(0, function(err, hash){
  if (err) throw err;
  console.log(hash); // 000000000019d6689c085ae...
});

btcd.createrawtransaction(
  [{ txid: ..., vout: 0 }],
  { '1KDZMzoahiAHtAbp8VuVvNahm5SaN3PFXc': 0.5 },
  function(err, rawtx) {
   // ...
  }
)

// Calls with notifications emits additional events:
btcd.notifyreceived([ '1KDZMzoahiAHtAbp8VuVvNahm5SaN3PFXc' ], function(err) {
  if (err) throw err;
  // Listening started succesfully, transactions will now trigger 'recvtx' below
});

btcd.on('recvtx', function(tx, block) {
  // process tx
});

// Close the connection
btcd.close();

(TODO: document events)

Test

Running the tests requires setting up a local btcd and configuring the tests to connect to it.

# Install dev dependencies
npm install

# Run tests
BTCD_URI=wss://user:pass@localhost:8334/ws \
BTCD_CERT=./rpc.cert \
npm test

Debug

Information about data being sent and received can be displayed using the debug package. To enable this, start the process with the environment variable DEBUG=btcd.

License

MIT

Keywords

FAQs

Package last updated on 01 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc