diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-01-19 05:14:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-19 05:14:27 +0800 |
commit | 25e57939920d4685a20b4e7b3a14060e9d3314c7 (patch) | |
tree | fa3c5f2811912a18ce9811c5c850bb4ec25ffbb1 /app/scripts/keyrings/simple.js | |
parent | 9ab7ce370bc12e10b3458c0755f0dd8488788bec (diff) | |
parent | 0e01abdf7154067ca50bf279340b868aefd8343f (diff) | |
download | tangerine-wallet-browser-25e57939920d4685a20b4e7b3a14060e9d3314c7.tar.gz tangerine-wallet-browser-25e57939920d4685a20b4e7b3a14060e9d3314c7.tar.zst tangerine-wallet-browser-25e57939920d4685a20b4e7b3a14060e9d3314c7.zip |
Merge pull request #1027 from MetaMask/Version-3.1.0v3.1.0
Version 3.1.0
Diffstat (limited to 'app/scripts/keyrings/simple.js')
-rw-r--r-- | app/scripts/keyrings/simple.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js index 6b16137ae..46687fcaf 100644 --- a/app/scripts/keyrings/simple.js +++ b/app/scripts/keyrings/simple.js @@ -20,13 +20,19 @@ class SimpleKeyring extends EventEmitter { } deserialize (privateKeys = []) { - this.wallets = privateKeys.map((privateKey) => { - const stripped = ethUtil.stripHexPrefix(privateKey) - const buffer = new Buffer(stripped, 'hex') - const wallet = Wallet.fromPrivateKey(buffer) - return wallet + return new Promise((resolve, reject) => { + try { + this.wallets = privateKeys.map((privateKey) => { + const stripped = ethUtil.stripHexPrefix(privateKey) + const buffer = new Buffer(stripped, 'hex') + const wallet = Wallet.fromPrivateKey(buffer) + return wallet + }) + } catch (e) { + reject(e) + } + resolve() }) - return Promise.resolve() } addAccounts (n = 1) { @@ -54,8 +60,7 @@ class SimpleKeyring extends EventEmitter { // For eth_sign, we need to sign transactions: signMessage (withAccount, data) { const wallet = this._getWalletForAccount(withAccount) - - const message = ethUtil.removeHexPrefix(data) + const message = ethUtil.stripHexPrefix(data) var privKey = wallet.getPrivateKey() var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey) var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s)) |