npm i byteball bitcore-mnemonic --save
const { toWif, getChash160 } = require('byteball/lib/utils');
const Mnemonic = require('bitcore-mnemonic');
const testnet = false; // Change to "true" to generate testnet wallet
const path = testnet ? "m/44'/1'/0'/0/0" : "m/44'/0'/0'/0/0";
let mnemonic = new Mnemonic();
while (!Mnemonic.isValid(mnemonic.toString())) {
mnemonic = new Mnemonic();
}
const xPrivKey = mnemonic.toHDPrivateKey();
const { privateKey } = xPrivKey.derive(path);
const privKeyBuf = privateKey.bn.toBuffer({ size: 32 });
const wif = toWif(privKeyBuf, testnet);
const pubkey = privateKey.publicKey.toBuffer().toString('base64');
const definition = ['sig', { pubkey }];
const address = getChash160(definition);
console.log(
'Seed:', mnemonic.phrase,
'\nPath:', path,
'\nWIF:', wif,
'\nPublic key:', pubkey,
'\nAddress:', address
);