2
2
This is how to create a brainwallet with bitcore
const Bitcore = require("bitcore-lib");
// const Mnemonic = require("bitcore-mnemonic");
// https://bitcore.io/api/lib/crypto
let brainsrc= 'satoshi'
let input = new Buffer(brainsrc)
let hash = Bitcore.crypto.Hash.sha256(input)
let bn = Bitcore.crypto.BN.fromBuffer(hash)
let pk = new Bitcore.PrivateKey(bn).toWIF()
let addy = new Bitcore.PrivateKey(bn).toAddress();
console.log('The brain wallet of '+brainsrc+' \nAddress: '+addy,' Private key:'+pk)
For bitcoinjs, I only know how to create random address:
// https://github.com/bitcoinjs/bitcoinjs-lib/blob/v3.3.2/test/integration/addresses.js
const bitcoin = require('bitcoinjs-lib')
var keyPair = bitcoin.ECPair.makeRandom()
var secret = (keyPair.toWIF())
var addr = (keyPair.getAddress())
console.log('The brain wallet of '+brainsrc+' \nAddress: '+addr,' Private key:'+secret)
How to do it?
TypeError: bitcoin.ECPair.fromPrivateKey is not a function – TSR – 2018-09-13T00:48:58.123
what version of
bitcoinjs-libandnodeare you using? – JBaczuk – 2018-09-13T01:31:31.193Yes node. I upgraded to 4.0.0 and it works. – TSR – 2018-09-13T02:05:29.460
It would be a plus if you can provide a link to the documentation – TSR – 2018-09-13T02:05:58.867
Good idea, just edited the answer, Bitcoinjs-lib doesn't have formal docs, but there are examples. – JBaczuk – 2018-09-13T02:20:15.020