aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-09-13 02:07:25 +0800
committerDan Finlay <dan@danfinlay.com>2016-09-13 02:13:26 +0800
commit363c2a0939aba5fa73e08ff8e6d65581031242d5 (patch)
tree1cac1090cd3813d57752d4cd2b77e3d26f6f6aac /app
parentfcc9ca812e557fd5ecc547f5eb597069788d6c00 (diff)
downloadtangerine-wallet-browser-363c2a0939aba5fa73e08ff8e6d65581031242d5.tar
tangerine-wallet-browser-363c2a0939aba5fa73e08ff8e6d65581031242d5.tar.gz
tangerine-wallet-browser-363c2a0939aba5fa73e08ff8e6d65581031242d5.tar.bz2
tangerine-wallet-browser-363c2a0939aba5fa73e08ff8e6d65581031242d5.tar.lz
tangerine-wallet-browser-363c2a0939aba5fa73e08ff8e6d65581031242d5.tar.xz
tangerine-wallet-browser-363c2a0939aba5fa73e08ff8e6d65581031242d5.tar.zst
tangerine-wallet-browser-363c2a0939aba5fa73e08ff8e6d65581031242d5.zip
Fix account unlocking
SubmitPassword was not creating a new id-management This is because I broke up the old "createIdmgmt" method to not perform as much conditional logic. Now the pieces are reusable and do what they should do.
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/id-management.js8
-rw-r--r--app/scripts/lib/idStore.js23
2 files changed, 21 insertions, 10 deletions
diff --git a/app/scripts/lib/id-management.js b/app/scripts/lib/id-management.js
index 9b8ceb415..e250943a0 100644
--- a/app/scripts/lib/id-management.js
+++ b/app/scripts/lib/id-management.js
@@ -1,3 +1,11 @@
+/* ID Management
+ *
+ * This module exists to hold the decrypted credentials for the current session.
+ * It therefore exposes sign methods, because it is able to perform these
+ * with noa dditional authentication, because its very instantiation
+ * means the vault is unlocked.
+ */
+
const ethUtil = require('ethereumjs-util')
const Transaction = require('ethereumjs-tx')
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index 8b7e3ad3b..1126b83e7 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -51,7 +51,7 @@ IdentityStore.prototype.createNewVault = function (password, entropy, cb) {
this.configManager.setData({})
}
- this._createIdmgmt(password, null, entropy, (err) => {
+ this._createVault(password, null, entropy, (err) => {
if (err) return cb(err)
this._autoFaucet()
@@ -72,7 +72,7 @@ IdentityStore.prototype.recoverSeed = function (cb) {
}
IdentityStore.prototype.recoverFromSeed = function (password, seed, cb) {
- this._createIdmgmt(password, seed, null, (err) => {
+ this._createVault(password, seed, null, (err) => {
if (err) return cb(err)
this._loadIdentities()
@@ -449,11 +449,12 @@ IdentityStore.prototype.tryPassword = function (password, cb) {
const isCorrect = keyStore.isDerivedKeyCorrect(pwDerivedKey)
if (!isCorrect) return cb(new Error('Lightwallet - password incorrect'))
+ this._createIdMgmt(derivedKey)
cb()
})
}
-IdentityStore.prototype._createIdmgmt = function (password, seedPhrase, entropy, cb) {
+IdentityStore.prototype._createVault = function (password, seedPhrase, entropy, cb) {
const opts = {
password,
hdPathString: this.hdPathString,
@@ -476,13 +477,7 @@ IdentityStore.prototype._createIdmgmt = function (password, seedPhrase, entropy,
keyStore.addHdDerivationPath(this.hdPathString, derivedKey, {curve: 'secp256k1', purpose: 'sign'})
this._createFirstWallet(derivedKey)
-
- this._idmgmt = new IdManagement({
- keyStore: keyStore,
- derivedKey: derivedKey,
- configManager: this.configManager,
- })
-
+ this._createIdMgmt(derivedKey)
this.setSelectedAddressSync()
cb()
@@ -490,6 +485,14 @@ IdentityStore.prototype._createIdmgmt = function (password, seedPhrase, entropy,
})
}
+IdentityStore.prototype._createIdMgmt = function (derivedKey) {
+ this._idmgmt = new IdManagement({
+ keyStore: this.keyStore,
+ derivedKey: derivedKey,
+ configManager: this.configManager,
+ })
+}
+
IdentityStore.prototype.purgeCache = function () {
this._getAddresses().forEach((address) => {
this._ethStore.del(address)