How to use bitcore-mnemonic - 10 common examples

To help you get started, we’ve selected a few bitcore-mnemonic 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 intervalue / intervalue-lightnode-2.0-testnet / src / js / controllers / recoveryFromSeeddir.js View on Github external
self.recoveryForm = function () {

		// 首先拼接一下 12个 助记词
		self.strMnemonic();
		if (self.inputMnemonic) {
			self.error = '';
			// 首先转换成小写
			self.inputMnemonic = self.inputMnemonic.toLowerCase();
			if ((self.inputMnemonic.split(' ').length % 3 === 0) && Mnemonic.isValid(self.inputMnemonic)) {
				self.scanning = true;

				// 向内存中写入2
				// self.haschoosen();

				// 模态框 显示出来
				self.show = true;

				if (self.bLight) {
					scanForAddressesAndWalletsInLightClient(self.inputMnemonic, cleanAndAddWalletsAndAddresses);

				} else {
					scanForAddressesAndWallets(self.inputMnemonic, cleanAndAddWalletsAndAddresses);
				}
			} else {
				self.error = 'Seed is not valid';
github byteball / headless-obyte / start.js View on Github external
rl.question('Passphrase for your private keys: ', function(passphrase){
					rl.close();
					if (process.stdout.moveCursor) process.stdout.moveCursor(0, -1);
					if (process.stdout.clearLine)  process.stdout.clearLine();
					var deviceTempPrivKey = crypto.randomBytes(32);
					var devicePrevTempPrivKey = crypto.randomBytes(32);

					var mnemonic = new Mnemonic(); // generates new mnemonic
					while (!Mnemonic.isValid(mnemonic.toString()))
						mnemonic = new Mnemonic();

					writeKeys(mnemonic.phrase, deviceTempPrivKey, devicePrevTempPrivKey, function(){
						console.log('keys created');
						var xPrivKey = mnemonic.toHDPrivateKey(passphrase);
						createWallet(xPrivKey, function(){
							onDone(mnemonic.phrase, passphrase, deviceTempPrivKey, devicePrevTempPrivKey);
						});
					});
				});
			});
github LiskHQ / lisk-desktop / src / utils / passphrase.js View on Github external
export const isValidPassphrase = (passphrase) => {
  const normalizedValue = passphrase.replace(/ +/g, ' ').trim();
  let isValid;
  try {
    isValid = normalizedValue.split(' ').length >= 12 && mnemonic.isValid(normalizedValue);
  } catch (e) {
    // If the mnemonic check throws an error, we assume that the
    // passphrase being entered isn't valid
    isValid = false;
  }
  return isValid;
};
github BIoTws / biot-core / lib / keys.js View on Github external
function generateKey() {
	let deviceTempPrivKey = crypto.randomBytes(32);
	let devicePrevTempPrivKey = crypto.randomBytes(32);
	
	let mnemonic = new Mnemonic(); // generates new mnemonic
	while (!Mnemonic.isValid(mnemonic.toString())) {
		mnemonic = new Mnemonic();
	}
	
	return {mnemonic, deviceTempPrivKey, devicePrevTempPrivKey};
}
github intervalue / intervalue-lightnode-2.0-testnet / src / js / directives / directives.js View on Github external
var validator = function (value) {
					try {
						value = value.split('-').join(' ');
						if (Mnemonic.isValid(value)) {
							ctrl.$setValidity('validMnemonic', true);
							return value;
						} else {
							ctrl.$setValidity('validMnemonic', false);
							return value;
						}
					} catch (ex) {
						ctrl.$setValidity('validMnemonic', false);
						return value;
					}
				};
				ctrl.$parsers.unshift(validator);
github intervalue / intervalue-lightnode-2.0-testnet / src / js / controllers / recoveryFromSeed.js View on Github external
function create() {
                self.inputMnemonic = self.value;
                if (self.inputMnemonic) {
                    self.error = '';
                    self.inputMnemonic = self.inputMnemonic.toLowerCase();
                    if (self.inputMnemonic == fc.credentials.mnemonic) {
                        self.error = 'can not recover the same wallet';
                        return;
                    }
                    if ((self.inputMnemonic.split(' ').length % 3 === 0) && Mnemonic.isValid(self.inputMnemonic)) {
                        self.scanning = true;
                        if (self.bLight) {
                            setTimeout(function () {
                                scanForAddressesAndWalletsInLightClient(self.inputMnemonic, cleanAndAddWalletsAndAddresses);
                            }, 3 * 1000);

                        } else {
                            scanForAddressesAndWallets(self.inputMnemonic, cleanAndAddWalletsAndAddresses);
                        }
                    } else {
                        self.error = 'Seed is not valid';
                    }
                }
            }
            create();
github byteball / ocore / wallet.js View on Github external
function expandMnemonic(mnemonic) {
	var addrInfo = {};
	mnemonic = mnemonic.toLowerCase().split('-').join(' ');
	if ((mnemonic.split(' ').length % 3 !== 0) || !Mnemonic.isValid(mnemonic)) {
		throw new Error("invalid mnemonic: "+mnemonic);
	}
	mnemonic = new Mnemonic(mnemonic);
	addrInfo.xPrivKey = mnemonic.toHDPrivateKey().derive("m/44'/0'/0'/0/0");
	addrInfo.pubkey = addrInfo.xPrivKey.publicKey.toBuffer().toString("base64");
	addrInfo.definition = ["sig", {"pubkey": addrInfo.pubkey}];
	addrInfo.address = objectHash.getChash160(addrInfo.definition);
	return addrInfo;
}
github byteball / obyte-gui-wallet / src / js / directives / directives.js View on Github external
var validator = function(value) {
           try {
             value = value.split('-').join(' ');
              if (Mnemonic.isValid(value)) {
                ctrl.$setValidity('validMnemonic', true);
                return value;
              } else {
                ctrl.$setValidity('validMnemonic', false);
                return value;
              }
          } catch(ex) {
              ctrl.$setValidity('validMnemonic', false);
             return value;
          }
          };
         ctrl.$parsers.unshift(validator);
github byteball / obyte-gui-wallet / angular-bitcore-wallet-client / bitcore-wallet-client / lib / credentials.js View on Github external
Credentials.createWithMnemonic = function(network, passphrase, language, account) {
    _checkNetwork(network);
    if (!wordsForLang[language])
        throw new Error('Unsupported language');
    $.shouldBeNumber(account);

    var m = new Mnemonic(wordsForLang[language]);
    while (!Mnemonic.isValid(m.toString())) {
		console.log('--- retrying mnemonic generation');
        m = new Mnemonic(wordsForLang[language])
    };
    var x = new Credentials();

    x.network = network;
    x.account = account;
    x.xPrivKey = m.toHDPrivateKey(passphrase, network).toString();
    x._expand();
    x.mnemonic = m.phrase;
    x.mnemonicHasPassphrase = !!passphrase;

    console.log("credentials: createWithMnemonic " + network + ', ' + passphrase + ',' + language + ',' + account);

    return x;
};
github byteball / headless-obyte / tools / recovery.js View on Github external
rl.question('mnemonic:', (mnemonic_phrase) => {
				mnemonic_phrase = mnemonic_phrase.trim().toLowerCase();
				if ((mnemonic_phrase.split(' ').length % 3 === 0) && Mnemonic.isValid(mnemonic_phrase)) {
					let deviceTempPrivKey = crypto.randomBytes(32);
					let devicePrevTempPrivKey = crypto.randomBytes(32);
					writeKeys(mnemonic_phrase, deviceTempPrivKey, devicePrevTempPrivKey, () => {
						getKeys(callback)
					})
				} else {
					throw new Error('Incorrect mnemonic phrase!')
				}
			});
		} else {

bitcore-mnemonic

BIP39 Mnemonics implemented for Bitcore.

MIT
Latest version published 2 months ago

Package Health Score

53 / 100
Full package analysis

Popular bitcore-mnemonic functions