aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-03-16 04:39:12 +0800
committerkumavis <aaron@kumavis.me>2016-03-16 04:39:12 +0800
commit21977505101f3164dc7d60cd9fc7a6c5901b4e38 (patch)
tree50c53c56bbee34537fbae83a4864b97fe136888a /app/scripts/lib
parent231d7ab1def6df37087ed2d2bb66c07aa4dfd7aa (diff)
downloadtangerine-wallet-browser-21977505101f3164dc7d60cd9fc7a6c5901b4e38.tar
tangerine-wallet-browser-21977505101f3164dc7d60cd9fc7a6c5901b4e38.tar.gz
tangerine-wallet-browser-21977505101f3164dc7d60cd9fc7a6c5901b4e38.tar.bz2
tangerine-wallet-browser-21977505101f3164dc7d60cd9fc7a6c5901b4e38.tar.lz
tangerine-wallet-browser-21977505101f3164dc7d60cd9fc7a6c5901b4e38.tar.xz
tangerine-wallet-browser-21977505101f3164dc7d60cd9fc7a6c5901b4e38.tar.zst
tangerine-wallet-browser-21977505101f3164dc7d60cd9fc7a6c5901b4e38.zip
add vault recovery
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/idStore.js25
1 files changed, 20 insertions, 5 deletions
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index 148947cd7..173a1672f 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -41,7 +41,7 @@ IdentityStore.prototype.createNewVault = function(password, cb){
const self = this
delete self._keyStore
delete window.localStorage['lightwallet']
- var keyStore = self._createIdmgmt(password, function(err){
+ var keyStore = self._createIdmgmt(password, null, function(err){
if (err) return cb(err)
var seedWords = self._idmgmt.getSeed()
self._loadIdentities()
@@ -50,6 +50,15 @@ IdentityStore.prototype.createNewVault = function(password, cb){
})
}
+IdentityStore.prototype.recoverFromSeed = function(password, seed, cb){
+ const self = this
+ self._createIdmgmt(password, seed, function(err){
+ if (err) return cb(err)
+ self._loadIdentities()
+ self._didUpdate()
+ cb()
+ })
+}
IdentityStore.prototype.setStore = function(store){
const self = this
@@ -202,17 +211,23 @@ IdentityStore.prototype._loadIdentities = function(){
IdentityStore.prototype._tryPassword = function(password, cb){
const self = this
- self._createIdmgmt(password, cb)
+ self._createIdmgmt(password, null, cb)
}
-IdentityStore.prototype._createIdmgmt = function(password, cb){
+IdentityStore.prototype._createIdmgmt = function(password, seed, cb){
const self = this
var keyStore = null
LightwalletKeyStore.deriveKeyFromPassword(password, function(err, derrivedKey){
if (err) return cb(err)
var serializedKeystore = window.localStorage['lightwallet']
- // returning user
- if (serializedKeystore) {
+ // recovering from seed
+ if (seed) {
+ keyStore = new LightwalletKeyStore(seed, derrivedKey)
+ keyStore.generateNewAddress(derrivedKey, 3)
+ window.localStorage['lightwallet'] = keyStore.serialize()
+ console.log('saved to keystore localStorage')
+ // returning user, recovering from localStorage
+ } else if (serializedKeystore) {
keyStore = LightwalletKeyStore.deserialize(serializedKeystore)
var isCorrect = keyStore.isDerivedKeyCorrect(derrivedKey)
if (!isCorrect) return cb(new Error('Lightwallet - password incorrect'))