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

rn-bitcoinjs-lib

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-bitcoinjs-lib

Client-side Bitcoin JavaScript library

  • 4.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by1300%
Maintainers
1
Weekly downloads
 
Created
Source

BitcoinJS (bitcoinjs-lib)

Build Status NPM tip for next commit

js-standard-style

This is a React Native compatible version of bitcoinjs-lib,a pure JavaScript Bitcoin library for node.js and browsers. Estimated to be in use by over 15 million wallet users and is the backbone for almost all Bitcoin web wallets in production today.

Features

  • Clean: Pure JavaScript, concise code, easy to read.
  • Tested: Coverage > 90%, third-party integration tests.
  • Careful: Two person approval process for small, focused pull requests.
  • Compatible: Works on Node.js and all modern browsers.
  • Powerful: Support for advanced features, such as multi-sig, HD Wallets.
  • Secure: Strong random number generation, PGP signed releases, trusted developers.
  • Principled: No support for browsers with crap RNG (IE < 11)
  • Standardized: Node community coding style, Browserify, Node's stdlib and Buffers.
  • Fast: Optimized code, uses typed arrays instead of byte arrays for performance.
  • Experiment-friendly: Bitcoin Mainnet and Testnet support.
  • Altcoin-ready: Capable of working with bitcoin-derived cryptocurrencies (such as Dogecoin).

Installation

yarn add https://github.com/coreyphillips/react-native-bitcoinjs-lib

Setup

React Native

Install the following dependencies:

yarn add buffer-reverse react-native-randombytes crypto buffer@5
yarn add --dev rn-nodeify
react-native link react-native-randombytes

Add the following to your script in package.json:

"postinstall": "rn-nodeify --install buffer,stream,assert,events,crypto,vm --hack"

Install any remaining dependencies and run postinstall. NOTE: (If you receive an error about "shim.js" not existing just run yarn install again):

yarn install

Add the following to shim.js:

if (typeof Buffer.prototype.reverse === 'undefined') {
  var bufferReverse = require('buffer-reverse');

  Buffer.prototype.reverse = function () {
    return bufferReverse(this);
  };
}

Add/Uncomment "require('crypto')" at the bottom of shim.js:

require('crypto')

Usage

import "./shim";
const bitcoin = require("bitcoinjs-lib");
const keyPair = bitcoin.ECPair.makeRandom();
const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey });
console.log(address);

You shouldn't trust or rely on this repo for anything other than testing. To setup bitcoinjs-lib (4.0.1) in your RN project, please follow the how-to below:

RN BitcoinJS-Lib (4.0.1) Setup

Node.js

Use bitcoinjs-lib

Browser

Use bitcoinjs-lib

Examples

The below examples are implemented as integration tests, they should be very easy to understand. Otherwise, pull requests are appreciated. Some examples interact (via HTTPS) with a 3rd Party Blockchain Provider (3PBP).

If you have a use case that you feel could be listed here, please ask for it!

Projects utilizing BitcoinJS

Contributing

We are always accepting of pull requests, but we do adhere to specific standards in regards to coding style, test driven development and commit messages.

Please make your best effort to adhere to these when contributing to save on trivial corrections.

Running the test suite

npm test
npm run-script coverage

Complementing Libraries

  • BIP21 - A BIP21 compatible URL encoding library
  • BIP38 - Passphrase-protected private keys
  • BIP39 - Mnemonic generation for deterministic keys
  • BIP32-Utils - A set of utilities for working with BIP32
  • BIP66 - Strict DER signature decoding
  • BIP68 - Relative lock-time encoding library
  • BIP69 - Lexicographical Indexing of Transaction Inputs and Outputs
  • Base58 - Base58 encoding/decoding
  • Base58 Check - Base58 check encoding/decoding
  • Bech32 - A BIP173 compliant Bech32 encoding library
  • coinselect - A fee-optimizing, transaction input selection module for bitcoinjs-lib.
  • merkle-lib - A performance conscious library for merkle root and tree calculations.
  • minimaldata - A module to check bitcoin policy: SCRIPT_VERIFY_MINIMALDATA

Alternatives

LICENSE MIT

Keywords

FAQs

Package last updated on 04 Sep 2018

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