app/scripts/keyring-controller.js
// creates a new HD wallet from the given seed with 1 account.
creates a new HD wallet from the given seed with 1 account.
creates a new HD wallet from the given seed with 1 account .
createNewVaultAndRestore (password, seed) {
    if (typeof password !== 'string') {
      return Promise.reject('Password must be text.')
    }
    if (!bip39.validateMnemonic(seed)) {
      return Promise.reject('Seed phrase is invalid.')
    }
    this.clearKeyrings()
    return this.persistAllKeyrings(password)
    .then(() => {
      return this.addNewKeyring('HD Key Tree', {
        mnemonic: seed,
        numberOfAccounts: 1,
      })
    })
    .then((firstKeyring) => {
      return firstKeyring.getAccounts()
    })
    .then((accounts) => {
      const firstAccount = accounts[0]
      if (!firstAccount) throw new Error('KeyringController - First Account not found.')
      const hexAccount = normalizeAddress(firstAccount)
      this.emit('newAccount', hexAccount)
      return this.setupAccounts(accounts)
    })
    .then(this.persistAllKeyrings.bind(this, password))
    .then(this.fullUpdate.bind(this))
  }
createNewVaultAndRestore ( password , seed ) { if ( typeof password !== 'string' ) { return Promise . reject ( 'Password must be text.' ) } if ( ! bip39 . validateMnemonic ( seed ) ) { return Promise . reject ( 'Seed phrase is invalid.' ) } this . clearKeyrings ( ) return this . persistAllKeyrings ( password ) . then ( ( ) => { return this . addNewKeyring ( 'HD Key Tree' , { mnemonic : seed , numberOfAccounts : 1 , } ) } ) . then ( ( firstKeyring ) => { return firstKeyring . getAccounts ( ) } ) . then ( ( accounts ) => { const firstAccount = accounts [ 0 ] if ( ! firstAccount ) throw new Error ( 'KeyringController - First Account not found.' ) const hexAccount = normalizeAddress ( firstAccount ) this . emit ( 'newAccount' , hexAccount ) return this . setupAccounts ( accounts ) } ) . then ( this . persistAllKeyrings . bind ( this , password ) ) . then ( this . fullUpdate . bind ( this ) ) }
creates a new HD wallet from the given seed with 1 account.
creates a new HD wallet from the given seed with 1 account .