aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js1
-rw-r--r--app/scripts/lib/idStore.js31
2 files changed, 18 insertions, 14 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index eb51f1ec5..01df16541 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -75,6 +75,7 @@ function handleInternalCommunication(remotePort){
var connection = Dnode({
getState: function(cb){ cb(null, getState()) },
// forward directly to idStore
+ createNewVault: idStore.createNewVault.bind(idStore),
submitPassword: idStore.submitPassword.bind(idStore),
setSelectedAddress: idStore.setSelectedAddress.bind(idStore),
signTransaction: idStore.signTransaction.bind(idStore),
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index 878648050..430092cc7 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -32,11 +32,24 @@ function IdentityStore(ethStore) {
// public
//
+IdentityStore.prototype.createNewVault = function(password, cb){
+ const self = this
+ delete self._keyStore
+ delete window.localStorage['lightwallet']
+ var keyStore = self._getKeyStore(password)
+ var seedWords = keyStore.getSeed(password)
+ self._loadIdentities()
+ self._didUpdate()
+ cb(null, seedWords)
+}
+
+
IdentityStore.prototype.setStore = function(store){
const self = this
self._ethStore = store
}
+
IdentityStore.prototype.getState = function(){
const self = this
return clone(extend(self._currentState, {
@@ -83,7 +96,6 @@ IdentityStore.prototype.addUnconfirmedTransaction = function(txParams, cb){
IdentityStore.prototype.setLocked = function(){
const self = this
delete self._keyStore
- delete window.sessionStorage['password']
}
IdentityStore.prototype.submitPassword = function(password, cb){
@@ -93,7 +105,6 @@ IdentityStore.prototype.submitPassword = function(password, cb){
if (err) console.log('bad password:', password, err)
if (err) return cb(err)
console.log('good password:', password)
- window.sessionStorage['password'] = password
// load identities before returning...
self._loadIdentities()
cb()
@@ -174,7 +185,6 @@ IdentityStore.prototype._signTransaction = function(password, txParams, cb){
gasLimit: txParams.gas,
})
- var password = self._getPassword()
var serializedTx = self._keyStore.signTx(tx.serialize(), password, self._currentState.selectedAddress)
// // deserialize and dump values to confirm configuration
@@ -201,20 +211,19 @@ IdentityStore.prototype._didUpdate = function(){
IdentityStore.prototype._isUnlocked = function(){
const self = this
- // var password = window.sessionStorage['password']
// var result = Boolean(password)
var result = Boolean(self._keyStore)
return result
}
-// load identities from keyStore
+// load identities from keyStoreet
IdentityStore.prototype._loadIdentities = function(){
const self = this
if (!self._isUnlocked()) throw new Error('not unlocked')
// get addresses and normalize address hexString
var addresses = self._keyStore.getAddresses().map(function(address){ return '0x'+address })
addresses.forEach(function(address){
- // add to ethStore
+ // // add to ethStore
self._ethStore.addAccount(address)
// add to identities
var identity = {
@@ -265,7 +274,7 @@ IdentityStore.prototype._getKeyStore = function(password){
self._saveKeystore(keyStore)
}
keyStore.passwordProvider = function getPassword(cb){
- cb(null, self._getPassword())
+ cb(null, password)
}
self._keyStore = keyStore
return keyStore
@@ -274,13 +283,7 @@ IdentityStore.prototype._getKeyStore = function(password){
IdentityStore.prototype._saveKeystore = function(keyStore){
const self = this
window.localStorage['lightwallet'] = keyStore.serialize()
-}
-
-IdentityStore.prototype._getPassword = function(){
- const self = this
- var password = window.sessionStorage['password']
- console.warn('using password from memory:', password)
- return password
+ console.log('saved to localStorage')
}
// util