A continued implementation of the original
0.1.3 version used by over a million wallet users; the backbone for almost all Bitcoin web wallets in production today.
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.
If you are looking for the original, it is tagged as
0.1.3. Unless you need it for dependency reasons, it is strongly recommended that you use (or upgrade to) the newest version, which adds major functionality, cleans up the interface, fixes many bugs, and adds over 1,300 more tests.
npm install bitcoinjs-lib
var bitcoin = require('bitcoinjs-lib')
From the repo:
var bitcoin = require('./src/index.js')
From the repository: Compile
bitcoinjs-min.js with the following command:
$ npm run-script compile
$ npm -g install bitcoinjs-lib browserify uglify-js $ browserify -r bitcoinjs-lib -s Bitcoin | uglifyjs > bitcoinjs.min.js
After loading this file in your browser, you will be able to use the global
These examples assume you are running bitcoinjs-lib in the browser.
key = bitcoinECKey// Print your private key (in WIF format)console// => Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct// Print your public key (toString defaults to a Bitcoin address)console// => 14bZ7YWde4KdRb5YN7GYkToz3EHVCvRxkF
tx =// Add the input (who is paying) of the form [previous transaction hash, index of the output to use]tx// Add the output (who to pay to) of the form [payee's address, amount in satoshis]tx// Initialize a private key using WIFkey = bitcoinECKey// Sign the first input with the new keytx// Print transaction serialized as hexconsole// => 0100000001313eb630b128102b60241ca895f1d0ffca2170d5a0990e094f2182c102ab94aa000000008a47304402200169f1f844936dc60df54e812345f5dd3e6681fea52e33c25154ad9cc23a330402204381ed8e73d74a95b15f312f33d5a0072c7a12dd6c3294df6e8efbe4aff27426014104e75628573696aed32d7656fb35e9c71ea08eb6492837e13d2662b9a36821d0fff992692fd14d74fdec20fae29128ba12653249cbeef521fc5eba84dde0689f27ffffffff01983a0000000000001976a914ad618cf4333b3b248f9744e8e81db2964d0ae39788ac00000000// You could now push the transaction onto the Bitcoin network manually (see )
var bitcoin =var privKeys = bitcoinECKey bitcoinECKey bitcoinECKeyvar pubKeys = privKeysvar redeemScript = bitcoinscripts // 2 of 3var scriptPubKey = bitcoinscriptsvar multisigAddress = bitcoinAddressconsole// => multisigP2SH: 35k9EWv2F1X5JKXHSF1DhTm7Ybdiwx4RkD
Stefan Thomas is the inventor and creator of this project. His pioneering work made Bitcoin web wallets possible.
Since then, many people have contributed. Click here to see the comprehensive list.
Daniel Cousens, Wei Lu, JP Richardson and Kyle Drake lead the major refactor of the library from 0.1.3 to 1.0.0.
Join the ongoing IRC development channel at
#bitcoinjs-dev on Freenode.
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.
$ npm test $ npm run-script coverage
This library is free and open-source software released under the MIT license.
BitcoinJS (c) 2011-2012 Stefan Thomas Released under MIT license