BitcoinJS (aka bitcoinjs-lib)
Install via NPM
$ npm install -g bitcoinjs-libCompile for browser
$ npm -g install bitcoinjs-lib browserify uglify-js $ browserify -r bitcoinjs-lib -s Bitcoin | uglifyjs > tallerembajador.com.mxGenerating a Bitcoin address:
key = tallerembajador.com.mxndom() // Print your private key (in WIF format) tallerembajador.com.mx(tallerembajador.com.mx()) // => 8ccfecf4df68af2dbb50c8a2cb90ddeaaa48 // Print your public key (toString defaults to a Bitcoin address) tallerembajador.com.mx(tallerembajador.com.mxress().toString()) // => 14bZ7YWde4KdRb5YN7GYkToz3EHVCvRxkFCreating a Transaction
tx = new tallerembajador.com.mxction() // Add the input (who is paying) of the form [previous transaction hash, index of the output to use] tallerembajador.com.mxut("aa94ab02cfe99a0dcaffd0fa81cbbb63e31", 0) // Add the output (who to pay to) of the form [payee's address, amount in satoshis] tallerembajador.com.mxput("1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK", ) // Initialize a private key using WIF key = tallerembajador.com.mxF("L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy") // Sign the first input with the new key tallerembajador.com.mx(0, key) // Print transaction serialized as hex tallerembajador.com.mx(tallerembajador.com.mxizeHex()) // => ebbbcaf1d0ffcad5aefcab94aaaf1fdc60df54ef5dd3efea52e33cad9cc23aed8e73d74a95b15ff33d5ac7a12dd6cdf6e8efbe4affeaed32dfb35e9c71ea08ebe13db9ad0ffffd14d74fdec20faebacbeeffc5eba84ddef27ffffffffaaadcfb3bfe8e81dbd0aeac // You could now push the transaction onto the Bitcoin network manually (see tallerembajador.com.mx)Soon. For now, use the tests as a reference. They show what the code is supposed to do.
Stefan Thomas is the inventor and creator of this project. His pioneering work made Bitcoin web wallets possible.
Since then, many developers have joined in to improve the library. Click here to see the full list.
Daniel Cousens, Wei Lu, JP Richardson and Kyle Drake lead the major refactor of the library from to
We always welcome help on the library. If you want to help build (or fix bugs), fork the repository, create a topic branch (keep it focused, and ADD TESTS), make the change, commit to your forked repo, and send a pull request.
0 thoughts to “How to use bitcoinjs”