Skip to content

Instantly share code, notes, and snippets.

@makevoid
Created September 14, 2018 14:06
Show Gist options
  • Select an option

  • Save makevoid/1df81da2f6c79e60a75f2e9b8efeb181 to your computer and use it in GitHub Desktop.

Select an option

Save makevoid/1df81da2f6c79e60a75f2e9b8efeb181 to your computer and use it in GitHub Desktop.
BCH create address and private key via bitcoincashjs node module (JS - bitcore-lib)
const fs = require('fs')
const bitcoin = require('bitcoincashjs') // npm i bitcoincashjs --save
// ( see https://bitcore.io/api/lib for docs )
// // generate and save private key
// const pvt = new bitcoin.PrivateKey()
// console.log(pvt.toString('hex'))
const privateKeyString = fs.readFileSync('./private-key.txt').toString().trim()
const privateKey = new bitcoin.PrivateKey(privateKeyString)
const address = privateKey.toAddress().toString()
console.log("loaded private key")
// console.log(privateKey)
console.log("address:", address)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment