Link

bitcoinjs-lib

Import WIF

const bitcoin = require('bitcoinjs-lib');

const wif = 'L12wE92KBbwS3RNFxeAnGLbmP5ibw8PRK2Lr1tfZrEvPqn1MP1MD';

console.log(`Using WIF key: ${wif}`);

const keyPair = bitcoin.ECPair.fromWIF(wif);
const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey });

console.log(`Corresponding address: ${address}`);

Multisig

const bitcoin = require('bitcoinjs-lib');

const mainnet = bitcoin.networks.mainnet;

const keyPair1 = bitcoin.ECPair.makeRandom({ network: mainnet });
const keyPair2 = bitcoin.ECPair.makeRandom({ network: mainnet });
const keyPair3 = bitcoin.ECPair.makeRandom({ network: mainnet });

const pubkeys = [
  keyPair1.publicKey,
  keyPair2.publicKey,
  keyPair3.publicKey
];
const multisig = bitcoin.payments.p2sh({
  redeem: bitcoin.payments.p2ms({ m: 2, pubkeys })
})

console.log(multisig.address);

SegWit (legacy)

const bitcoin = require('bitcoinjs-lib');

const mainnet = bitcoin.networks.mainnet;

const keyPair = bitcoin.ECPair.makeRandom({ network: mainnet });
const result = bitcoin.payments.p2sh({ 
  redeem: bitcoin.payments.p2wpkh({ pubkey: keyPair.publicKey })
});
console.log(result.address);

SegWit (native)

const bitcoin = require('bitcoinjs-lib');

const mainnet = bitcoin.networks.mainnet;

const keyPair = bitcoin.ECPair.makeRandom({ network: mainnet });
const result = bitcoin.payments.p2wpkh({ pubkey: keyPair.publicKey });
console.log(result.address);