Skip to content

Instantly share code, notes, and snippets.

@placecodex
Last active December 1, 2020 23:09
Show Gist options
  • Save placecodex/528b5139e7d32297b7bf47f6ca815308 to your computer and use it in GitHub Desktop.
Save placecodex/528b5139e7d32297b7bf47f6ca815308 to your computer and use it in GitHub Desktop.
generate bitcoin address testnet o main
const bitcoin = require('bitcoinjs-lib');
const TestNet = bitcoin.networks.testnet;
let keyPair = bitcoin.ECPair.makeRandom({ network: TestNet });//testnet
//var keyPair = bitcoin.ECPair.makeRandom();//main
var publicKey = keyPair.publicKey
var { address } = bitcoin.payments.p2pkh({ pubkey: publicKey });
var privateKey = keyPair.toWIF();
console.log(address)
console.log(privateKey)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment