diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2016-10-31 07:02:11 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2016-10-31 07:02:11 +0800 |
commit | f9409793d8a4413c42e5d11ec0279c893c7c446c (patch) | |
tree | 632fbdeb190ae0676a5f5ed83a6fd625f016abe4 /app/scripts/keyring-controller.js | |
parent | 25c46a16364612cd4bcebe375af910c08862b17a (diff) | |
parent | 18e5173f061c2e21b5acb3e1b329343b5cffc558 (diff) | |
download | tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.gz tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.bz2 tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.lz tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.xz tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.zst tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.zip |
Merge branch 'i328-MultiVault' of github.com:MetaMask/metamask-plugin into i328-MultiVault
Diffstat (limited to 'app/scripts/keyring-controller.js')
-rw-r--r-- | app/scripts/keyring-controller.js | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 3ac101ad8..b8066e303 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -9,6 +9,9 @@ const BN = ethUtil.BN const Transaction = require('ethereumjs-tx') const createId = require('web3-provider-engine/util/random-id') +// TEMPORARY UNTIL FULL DEPRECATION: +const IdStoreMigrator = require('./lib/idStore-migrator') + // Keyrings: const SimpleKeyring = require('./keyrings/simple') const HdKeyring = require('./keyrings/hd') @@ -34,6 +37,11 @@ module.exports = class KeyringController extends EventEmitter { this._unconfMsgCbs = {} this.network = null + + // TEMPORARY UNTIL FULL DEPRECATION: + this.idStoreMigrator = new IdStoreMigrator({ + configManager: this.configManager, + }) } getState() { @@ -63,18 +71,32 @@ module.exports = class KeyringController extends EventEmitter { createNewVault(password, entropy, cb) { const salt = this.encryptor.generateSalt() this.configManager.setSalt(salt) - this.loadKey(password) + + let serialized + + this.idStoreMigrator.oldSeedForPassword(password) + .then((oldSerialized) => { + if (oldSerialized) { + serialized = oldSerialized + } + return this.loadKey(password) + }) .then((key) => { - return this.encryptor.encryptWithKey(key, []) + const first = serialized ? [serialized] : [] + return this.encryptor.encryptWithKey(key, first) }) .then((encryptedString) => { this.configManager.setVault(encryptedString) - // TEMPORARY SINGLE-KEYRING CONFIG: - this.addNewKeyring('HD Key Tree', null, cb) + if (!serialized) { + // TEMPORARY SINGLE-KEYRING CONFIG: + return this.addNewKeyring('HD Key Tree', null, cb) + } else { + return this.submitPassword(password, cb) + } // NORMAL BEHAVIOR: - // cb(null, this.getState()) + // return cb(null, this.getState()) }) .catch((err) => { cb(err) @@ -99,6 +121,7 @@ module.exports = class KeyringController extends EventEmitter { return this.encryptor.keyFromPassword(password + salt) .then((key) => { this.key = key + this.configManager.setSalt(salt) return key }) } |