aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-10-20 05:55:08 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-10-20 05:55:08 +0800
commitad3fa24a28c0ec45dca43a257005626a4027487a (patch)
treeeafbf105e0a2e5caf70fcf542b018c444705335f /app
parent725d503f68f533e0d1dfc402c4316dcf677c0d89 (diff)
downloadtangerine-wallet-browser-ad3fa24a28c0ec45dca43a257005626a4027487a.tar
tangerine-wallet-browser-ad3fa24a28c0ec45dca43a257005626a4027487a.tar.gz
tangerine-wallet-browser-ad3fa24a28c0ec45dca43a257005626a4027487a.tar.bz2
tangerine-wallet-browser-ad3fa24a28c0ec45dca43a257005626a4027487a.tar.lz
tangerine-wallet-browser-ad3fa24a28c0ec45dca43a257005626a4027487a.tar.xz
tangerine-wallet-browser-ad3fa24a28c0ec45dca43a257005626a4027487a.tar.zst
tangerine-wallet-browser-ad3fa24a28c0ec45dca43a257005626a4027487a.zip
Intermediary commit.
Diffstat (limited to 'app')
-rw-r--r--app/scripts/keyring-controller.js37
-rw-r--r--app/scripts/lib/config-manager.js11
2 files changed, 44 insertions, 4 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 246a45484..db7e5e61e 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -1,5 +1,7 @@
-const configManager = require('./lib/config-manager')
const EventEmitter = require('events').EventEmitter
+const encryptor = require('./lib/encryptor')
+const messageManager = require('./lib/message-manager')
+
module.exports = class KeyringController extends EventEmitter {
@@ -20,7 +22,7 @@ module.exports = class KeyringController extends EventEmitter {
if (!salt) {
salt = generateSalt(32)
- configManager.setSalt(salt)
+ this.configManager.setSalt(salt)
}
var logN = 14
@@ -42,7 +44,21 @@ module.exports = class KeyringController extends EventEmitter {
}
getState() {
- return {}
+ return {
+ isInitialized: !!this.key,
+ isUnlocked: !!this.key,
+ isConfirmed: true, // this.configManager.getConfirmed(),
+ isEthConfirmed: this.configManager.getShouldntShowWarning(),
+ unconfTxs: this.configManager.unconfirmedTxs(),
+ transactions: this.configManager.getTxList(),
+ unconfMsgs: messageManager.unconfirmedMsgs(),
+ messages: messageManager.getMsgList(),
+ selectedAddress: this.configManager.getSelectedAccount(),
+ shapeShiftTxList: this.configManager.getShapeShiftTxList(),
+ currentFiat: this.configManager.getCurrentFiat(),
+ conversionRate: this.configManager.getConversionRate(),
+ conversionDate: this.configManager.getConversionDate(),
+ }
}
setStore(ethStore) {
@@ -50,9 +66,22 @@ module.exports = class KeyringController extends EventEmitter {
}
createNewVault(password, entropy, cb) {
- cb()
+ encryptor.keyFromPassword(password)
+ .then((key) => {
+ this.key = key
+ return encryptor.encryptWithKey(key, {})
+ })
+ .then((encryptedString) => {
+ this.configManager.setVault(encryptedString)
+ cb(null, [])
+ })
+ .catch((err) => {
+ cb(err)
+ })
}
+
+
submitPassword(password, cb) {
cb()
}
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index d775e73fd..1c0e3b696 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -110,6 +110,17 @@ ConfigManager.prototype.setWallet = function (wallet) {
this.setData(data)
}
+ConfigManager.prototype.setVault = function (encryptedString) {
+ var data = this.getData()
+ data.vault = encryptedString
+ this.setData(data)
+}
+
+ConfigManager.prototype.getVault = function () {
+ var data = this.getData()
+ return ('vault' in data) && data.vault
+}
+
ConfigManager.prototype.getKeychains = function () {
return this.migrator.getData().keychains || []
}