aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyrings
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-10-21 08:24:03 +0800
committerDan Finlay <dan@danfinlay.com>2016-10-21 08:29:25 +0800
commit957b7a72b55be864320a346108673d02448caefd (patch)
treeb44d07f86b50bca5213ed060d824db733b084619 /app/scripts/keyrings
parent55d56f77cf42a9c4e80768fd7e4a9bb6f0485606 (diff)
downloadtangerine-wallet-browser-957b7a72b55be864320a346108673d02448caefd.tar
tangerine-wallet-browser-957b7a72b55be864320a346108673d02448caefd.tar.gz
tangerine-wallet-browser-957b7a72b55be864320a346108673d02448caefd.tar.bz2
tangerine-wallet-browser-957b7a72b55be864320a346108673d02448caefd.tar.lz
tangerine-wallet-browser-957b7a72b55be864320a346108673d02448caefd.tar.xz
tangerine-wallet-browser-957b7a72b55be864320a346108673d02448caefd.tar.zst
tangerine-wallet-browser-957b7a72b55be864320a346108673d02448caefd.zip
Improved simple account generation
Diffstat (limited to 'app/scripts/keyrings')
-rw-r--r--app/scripts/keyrings/simple.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js
index 3eda9b8f9..59d4691c6 100644
--- a/app/scripts/keyrings/simple.js
+++ b/app/scripts/keyrings/simple.js
@@ -12,17 +12,19 @@ module.exports = class SimpleKeyring extends EventEmitter {
super()
this.type = type
this.opts = opts || {}
- const walletData = this.opts.wallets || []
- this.wallets = walletData.map((w) => {
- return Wallet.fromPrivateKey(w)
- })
+ this.wallets = []
}
serialize() {
- return {
- type,
- wallets: this.wallets.map(w => w.getPrivateKey()),
- }
+ return this.wallets.map(w => w.getPrivateKey().toString('hex'))
+ }
+
+ deserialize(wallets = []) {
+ this.wallets = wallets.map((w) => {
+ var b = new Buffer(w, 'hex')
+ const wallet = Wallet.fromPrivateKey(b)
+ return wallet
+ })
}
addAccounts(n = 1) {
@@ -30,12 +32,12 @@ module.exports = class SimpleKeyring extends EventEmitter {
for (var i = 0; i < n; i++) {
newWallets.push(Wallet.generate())
}
- this.wallets.concat(newWallets)
- return newWallets.map(w => w.getAddress())
+ this.wallets = this.wallets.concat(newWallets)
+ return newWallets.map(w => w.getAddress().toString('hex'))
}
getAccounts() {
- return this.wallets.map(w => w.getAddress())
+ return this.wallets.map(w => w.getAddress().toString('hex'))
}
}