aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyrings/simple.js
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-11-23 02:26:16 +0800
committerGitHub <noreply@github.com>2016-11-23 02:26:16 +0800
commitd92741c41984aa9d5268f4aca04ec916a95ef204 (patch)
treef6400549253c2c6459d54ba3211d0fb9bf61f6dd /app/scripts/keyrings/simple.js
parentbe6b7b496a95fa036161b6c600eadd733676e954 (diff)
parent60afc41bb65547ace5e3a16b9c743a0dbf36d58a (diff)
downloadtangerine-wallet-browser-d92741c41984aa9d5268f4aca04ec916a95ef204.tar
tangerine-wallet-browser-d92741c41984aa9d5268f4aca04ec916a95ef204.tar.gz
tangerine-wallet-browser-d92741c41984aa9d5268f4aca04ec916a95ef204.tar.bz2
tangerine-wallet-browser-d92741c41984aa9d5268f4aca04ec916a95ef204.tar.lz
tangerine-wallet-browser-d92741c41984aa9d5268f4aca04ec916a95ef204.tar.xz
tangerine-wallet-browser-d92741c41984aa9d5268f4aca04ec916a95ef204.tar.zst
tangerine-wallet-browser-d92741c41984aa9d5268f4aca04ec916a95ef204.zip
Merge pull request #856 from MetaMask/i835-OrganizeKeyrings
I835 organize keyrings
Diffstat (limited to 'app/scripts/keyrings/simple.js')
-rw-r--r--app/scripts/keyrings/simple.js21
1 files changed, 17 insertions, 4 deletions
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js
index ee743bc03..4fdccc4f7 100644
--- a/app/scripts/keyrings/simple.js
+++ b/app/scripts/keyrings/simple.js
@@ -4,7 +4,9 @@ const ethUtil = require('ethereumjs-util')
const type = 'Simple Key Pair'
const sigUtil = require('../lib/sig-util')
-module.exports = class SimpleKeyring extends EventEmitter {
+class SimpleKeyring extends EventEmitter {
+
+ /* PUBLIC METHODS */
static type () {
return type
@@ -44,7 +46,7 @@ module.exports = class SimpleKeyring extends EventEmitter {
// tx is an instance of the ethereumjs-transaction class.
signTransaction (address, tx) {
- const wallet = this.getWalletForAccount(address)
+ const wallet = this._getWalletForAccount(address)
var privKey = wallet.getPrivateKey()
tx.sign(privKey)
return tx
@@ -52,7 +54,7 @@ module.exports = class SimpleKeyring extends EventEmitter {
// For eth_sign, we need to sign transactions:
signMessage (withAccount, data) {
- const wallet = this.getWalletForAccount(withAccount)
+ const wallet = this._getWalletForAccount(withAccount)
const message = ethUtil.removeHexPrefix(data)
var privKey = wallet.getPrivateKey()
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
@@ -60,8 +62,19 @@ module.exports = class SimpleKeyring extends EventEmitter {
return rawMsgSig
}
- getWalletForAccount (account) {
+ exportAccount (address) {
+ const wallet = this._getWalletForAccount(address)
+ return wallet.getPrivateKey().toString('hex')
+ }
+
+
+ /* PRIVATE METHODS */
+
+ _getWalletForAccount (account) {
return this.wallets.find(w => w.getAddress().toString('hex') === account)
}
}
+
+SimpleKeyring.type = type
+module.exports = SimpleKeyring