nmarley / bitcoinjs-lib-dash

Bitcoin-related functions implemented in pure JavaScript
MIT License
2 stars 0 forks source link

BitcoinJS (bitcoinjs-lib)

Build Status NPM tip for next commit

js-standard-style

The pure JavaScript Bitcoin library for node.js and browsers. Used by over a million wallet users and the backbone for almost all Bitcoin web wallets in production today.

Features

Should I use this in production?

If you are thinking of using the master branch of this library in production, stop. Master is not stable; it is our development branch, and only tagged releases may be classified as stable.

Installation

npm install bitcoinjs-lib

Setup

Node.js

var bitcoin = require('bitcoinjs-lib')

Browser

If you're familiar with how to use browserify, ignore this and proceed normally. These steps are advisory only, and may not be necessary for your application.

Browserify is assumed to be installed for these steps.

From your repository, create an index.js file

module.exports = {
  base58: require('bs58'),
  bitcoin: require('bitcoinjs-lib'),
  ecurve: require('ecurve'),
  BigInteger: require('bigi')
}

Install each of the above packages locally

npm install bs58 bitcoinjs-lib ecurve bigi

After installation, use browserify to compile index.js for use in the browser:

    $ browserify index.js --standalone foo > app.js

You will now be able to use <script src="https://github.com/nmarley/bitcoinjs-lib-dash/raw/master/app.js" /> in your browser, with each of the above exports accessible via the global foo object (or whatever you chose for the --standalone parameter above).

NOTE: See our package.json for the currently supported version of browserify used by this repository.

NOTE: When uglifying the javascript, you must exclude the following variable names from being mangled: Array, BigInteger, Boolean, ECPair, Function, Number, Point and Script. This is because of the function-name-duck-typing used in typeforce. Example:

uglifyjs ... --mangle --reserved 'Array,BigInteger,Boolean,ECPair,Function,Number,Point'

NOTE: If you expect this library to run on an iOS 10 device, ensure that you are using buffer@5.0.5 or greater.

Flow

Definitions for Flow typechecker are available in flow-typed repository.

You can either download them directly from the repo, or with the flow-typed CLI

# npm install -g flow-typed
$ flow-typed install -f 0.27 bitcoinjs-lib@2.2.0 # 0.27 for flow version, 2.2.0 for bitcoinjs-lib version

The definitions are complete and up to date with version 2.2.0. The definitions are maintained by @runn1ng.

Examples

The below examples are implemented as integration tests, they should be very easy to understand. Otherwise, pull requests are appreciated.

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

Projects utilizing BitcoinJS

Contributors

Stefan Thomas is the inventor and creator of this project. His pioneering work made Bitcoin web wallets possible. Daniel Cousens, Wei Lu, JP Richardson and Kyle Drake lead the major refactor of the library from 0.1.3 to 1.0.0.

Since then, many people have contributed. Click here to see the comprehensive list.

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

Alternatives

LICENSE MIT

Copyright

BitcoinJS (c) 2011-2016 bitcoinjs-lib contributors

Released under MIT license