Install
npm i bitcoinjs-lib --save
Source
const bitcoin = require('bitcoinjs-lib');
const net = process.env.USDT_OMNI_NETWORK === 'testnet'
? bitcoin.networks.testnet
: bitcoin.networks.bitcoin;
const alice = bitcoin.ECPair.fromWIF(omniWIF, net);
const alice_p2pkh_legacy_address = bitcoin.payments.p2pkh({
pubkey: alice.publicKey,
network: net
}).address;// NEW** New Payments API for p2pkh
console.log(alice_p2pkh_legacy_address);
const alice_p2wpkh_segwit_address = bitcoin.payments.p2sh({
redeem: bitcoin.payments.p2wpkh({pubkey: alice.publicKey, network: net}),
network: net
}).address;
console.log(alice_p2wpkh_segwit_address);