How to use the bip39.mnemonicToSeedHex function in bip39

To help you get started, we’ve selected a few bip39 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TronLink / tronlink-extension / app / popup / src / pages / Import / TronWatch / index.js View on Github external
async import() {
        // This shouldn't happen, but a failsafe for if it does
        if(this.hasInvalidWords())
            return;

        const words = this.state.words.join(' ');
        const privateKey = bip39.mnemonicToSeedHex(words);
        const publicKey = Utils.privateKeyToAddress(privateKey);

        if(Object.keys(this.props.accounts).includes(publicKey)) {
            return Swal({
                type: 'error',
                title: 'Account already exists',
                text: 'The account you have tried to import already exists'
            });
        }

        const { value: name } = await Swal({
            title: this.translate({ id: 'accounts.import.title' }),
            input: 'text',
            inputPlaceholder: this.translate({ id: 'accounts.create.placeholder' }),
            showCancelButton: true,
            inputValidator: name => {
github ArkEcosystem / mobile-wallet / src / modals / wallet-backup / wallet-backup.ts View on Github external
private generateAccountFromKeys() {
    const pvKey = PrivateKey.fromSeed(this.keys.key, this.currentNetwork);
    const pbKey = pvKey.getPublicKey();
    pbKey.setNetwork(this.currentNetwork);

    const wallet = this.userDataProvider.getWalletByAddress(pbKey.getAddress());

    const account: AccountBackup = {};
    account.address = wallet.address;
    account.mnemonic = this.keys.key;
    account.publicKey = pbKey.toHex();
    account.seed = bip39.mnemonicToSeedHex(account.mnemonic);
    if (pbKey.network.wif) {
      account.wif = pvKey.toWIF();
    }

    if (this.keys.secondKey) {
      account.secondMnemonic = this.keys.secondKey;
    }

    this.account = account;
  }
github oipwg / oip-hdmw / src / Wallet.js View on Github external
fromMnemonic (mnemonic) {
    if (isMnemonic(mnemonic)) {
      this.mnemonic = mnemonic
      this.entropy = bip39.mnemonicToEntropy(this.mnemonic)
      this.seed = bip39.mnemonicToSeedHex(this.mnemonic)

      return true
    }

    return false
  }
  /**
github AnsenYu / Ironman / src / util / Mnemonic.js View on Github external
static async mnemonicToSeed(mnemonic){
        return bip39.mnemonicToSeedHex(mnemonic);
    }
github TronLink / tronlink-extension / app / lib / AccountHandler.js View on Github external
_importFromWordList(wordList) {
        logger.info('Importing account from word list');

        if(!bip39.validateMnemonic(wordList))
            throw new Error(`Invalid wordList ${wordList} provided`);

        logger.info('Word list was valid');

        this._type = ACCOUNT_TYPE.MNEMONIC;
        this._seed = bip39.mnemonicToSeedHex(wordList);
        this._wordList = wordList;
    }
github airgap-it / airgap-vault / src / app / pages / transaction-detail / transaction-detail.page.ts View on Github external
return this.secretsService.retrieveEntropyForSecret(secret).then((entropy: string) => {
      const seed: string = bip39.mnemonicToSeedHex(bip39.entropyToMnemonic(entropy))
      if (wallet.isExtendedPublicKey) {
        const extendedPrivateKey: string = wallet.coinProtocol.getExtendedPrivateKeyFromHexSecret(seed, wallet.derivationPath)

        return wallet.coinProtocol.signWithExtendedPrivateKey(extendedPrivateKey, transaction.transaction)
      } else {
        const privateKey: Buffer = wallet.coinProtocol.getPrivateKeyFromHexSecret(seed, wallet.derivationPath)

        return wallet.coinProtocol.signWithPrivateKey(privateKey, transaction.transaction)
      }
    })
  }
github vitelabs / vite.js / packages / vitejs / es5 / hdAddr / index.js View on Github external
function newAddr(bits, lang, pwd) {
    if (bits === void 0) { bits = 256; }
    if (lang === void 0) { lang = type_1.LangList.english; }
    if (pwd === void 0) { pwd = ''; }
    var err = vitejs_utils_1.checkParams({ bits: bits }, ['bits']);
    if (err) {
        throw new Error(err.message);
    }
    var wordList = getWordList(lang);
    var mnemonic = bip39.generateMnemonic(bits, null, wordList);
    var entropy = bip39.mnemonicToEntropy(mnemonic, wordList);
    var seed = bip39.mnemonicToSeedHex(mnemonic, pwd);
    var path = getPath(0);
    var addr = getAddrFromPath(path, seed);
    var id = exports.getId(mnemonic, lang);
    return { addr: addr, entropy: entropy, mnemonic: mnemonic, id: id };
}
exports.newAddr = newAddr;
github blocktrail / wallet-recovery-tool / src / libs / blocktrail-sdk / lib / api_client.js View on Github external
APIClient.prototype.mnemonicToSeedHex = function(mnemonic, passphrase) {
    var self = this;

    if (useWebWorker) {
        return webworkifier.workify(self.mnemonicToSeedHex, function() {
            return require('./webworker');
        }, {method: 'mnemonicToSeedHex', mnemonic: mnemonic, passphrase: passphrase})
            .then(function(data) {
                return data.seed;
            });
    } else {
        try {
            return q.when(bip39.mnemonicToSeedHex(mnemonic, passphrase));
        } catch (e) {
            return q.reject(e);
        }
    }
};
github chatch / stellar-hd-wallet / src / stellar-hd-wallet.js View on Github external
static fromMnemonic(mnemonic, password = undefined, language = "english") {
    if (!StellarHDWallet.validateMnemonic(mnemonic, language)) {
      throw new Error(INVALID_MNEMONIC);
    }
    return new StellarHDWallet(bip39.mnemonicToSeedHex(mnemonic, password));
  }