Last active
June 14, 2016 06:05
-
-
Save bkawk/86b015f2be16cfe3046c99c4036e6637 to your computer and use it in GitHub Desktop.
Make a bitcoin address and WIF
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 fs = require("fs") | |
function randomString(length, chars) { | |
var result = ''; | |
for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)]; | |
return result; | |
} | |
function makePair(params) { | |
var rand = randomString(32, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); | |
function rng () { return new Buffer(rand) } | |
var keyPair = bitcoin.ECPair.makeRandom({ rng: rng }) | |
var address = keyPair.getAddress(); | |
var wif = keyPair.toWIF(); | |
console.log('Address: '+address); | |
console.log('WIF: '+wif); | |
} | |
(function () { | |
makePair(); | |
})(); |
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
{ | |
"name": "KeyPair", | |
"version": "1.0.0", | |
"description": "Make a bitcoin address and WIF", | |
"main": "index.js", | |
"scripts": { | |
"start": "nodemon index.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Will In China @bkawk", | |
"license": "MIT", | |
"dependencies": { | |
"bitcoinjs-lib": "^2.2.0" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment