Created
September 14, 2018 14:06
-
-
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)
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
| 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