Created
March 13, 2016 12:06
-
-
Save assafshomer/b251c2e4276365d18f5b to your computer and use it in GitHub Desktop.
bitcoinjs-lib addresses and network selection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var bitcoin = require('bitcoinjs-lib') | |
| var net = function(network) { | |
| tmp = (network == 'testnet') ? bitcoin.networks.testnet : bitcoin.networks.bitcoin; | |
| return tmp; | |
| }; | |
| network = 'bitcoin' | |
| var key = bitcoin.ECPair.makeRandom({network: net(network)}); | |
| var bitcoinAddress = key.getAddress(net(network)).toString(); | |
| var privateKeyWif = key.toWIF(); | |
| console.log('address',bitcoinAddress); | |
| console.log('wif',privateKeyWif); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment