// function to generate BIP39XRKwallet
function generateBip39XRKWallet(password, wordListLang, entropyLength,
address_pubkeyhash_version, address_checksum_value,
private_key_version) {
const wordList = eval('Mnemonic.Words.' + wordListLang);
var code = new Mnemonic(entropyLength, wordList);
var xprivKey = code.toHDPrivateKey(password); // using a passphrase
var masterPrivateKey = xprivKey.privateKey.toString();
xrkPublicAddress = createXRKAddressFromPrivateKey(masterPrivateKey, address_pubkeyhash_version, address_checksum_value);
xrkPrivateKey = createXRKPrivateKeyFromPrivateKey(masterPrivateKey, private_key_version, address_checksum_value);
CONSOLE_DEBUG && console.log("final publickey hex pkh1: ", PublicKeyString);
// var pkh = bitcore.PublicKey.fromString(PublicKeyString);
// CONSOLE_DEBUG && console.log("final publickey hex pkh: ", pkh);
var xrkWallet = {
"status": "success",
"address": xrkPublicAddress,
"privateKey": xrkPrivateKey,
"publicKey": PublicKeyString,
"seed": code.toString()
};
CONSOLE_DEBUG && console.log("xrkWallet", xrkWallet);
CONSOLE_DEBUG && console.log("xrkWallet success : ", xrkWallet.status);
CONSOLE_DEBUG && console.log("xrkWallet address :", xrkWallet.address);
CONSOLE_DEBUG && console.log("xrkWallet privateKey :", xrkWallet.privateKey);
CONSOLE_DEBUG && console.log("xrkWallet seed :", xrkWallet.seed);
seed = xrkWallet.seed;
localStorage.setItem("pubaddr", xrkWallet.address);
pubaddr = localStorage.getItem("pubaddr");
privkey1 = xrkWallet.privateKey;
CONSOLE_DEBUG && console.log("xrkWallet privkey1 :", privkey1);
CONSOLE_DEBUG && console.log("xrkWallet pubaddr :", pubaddr);
return xrkWallet;
}