diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-01-18 04:08:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-18 04:08:47 +0800 |
commit | c53932a19a77516110a45d7b201b85dc6ea71a47 (patch) | |
tree | 4b53230af166215f932b0d5c3ac17888946c85ca /app/scripts/keyrings/simple.js | |
parent | 79040c2e681012c98869b7e4d49a9e0ed406c52f (diff) | |
parent | a245fb7d22a5fe08c4fc8c2c1c64d406805018a8 (diff) | |
download | tangerine-wallet-browser-c53932a19a77516110a45d7b201b85dc6ea71a47.tar tangerine-wallet-browser-c53932a19a77516110a45d7b201b85dc6ea71a47.tar.gz tangerine-wallet-browser-c53932a19a77516110a45d7b201b85dc6ea71a47.tar.bz2 tangerine-wallet-browser-c53932a19a77516110a45d7b201b85dc6ea71a47.tar.lz tangerine-wallet-browser-c53932a19a77516110a45d7b201b85dc6ea71a47.tar.xz tangerine-wallet-browser-c53932a19a77516110a45d7b201b85dc6ea71a47.tar.zst tangerine-wallet-browser-c53932a19a77516110a45d7b201b85dc6ea71a47.zip |
Merge branch 'dev' into conversion-api-err
Diffstat (limited to 'app/scripts/keyrings/simple.js')
-rw-r--r-- | app/scripts/keyrings/simple.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js index 9717f1c45..d604430b8 100644 --- a/app/scripts/keyrings/simple.js +++ b/app/scripts/keyrings/simple.js @@ -35,12 +35,12 @@ class SimpleKeyring extends EventEmitter { newWallets.push(Wallet.generate()) } this.wallets = this.wallets.concat(newWallets) - const hexWallets = newWallets.map(w => w.getAddress().toString('hex')) + const hexWallets = newWallets.map(w => ethUtil.bufferToHex(w.getAddress())) return Promise.resolve(hexWallets) } getAccounts () { - return Promise.resolve(this.wallets.map(w => w.getAddress().toString('hex'))) + return Promise.resolve(this.wallets.map(w => ethUtil.bufferToHex(w.getAddress()))) } // tx is an instance of the ethereumjs-transaction class. @@ -54,7 +54,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)) @@ -70,7 +70,9 @@ class SimpleKeyring extends EventEmitter { /* PRIVATE METHODS */ _getWalletForAccount (account) { - return this.wallets.find(w => w.getAddress().toString('hex') === account) + let wallet = this.wallets.find(w => ethUtil.bufferToHex(w.getAddress()) === account) + if (!wallet) throw new Error('Simple Keyring - Unable to find matching address.') + return wallet } } |