diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-02-16 07:49:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-16 07:49:04 +0800 |
commit | 352bb5cb3941c3a07b383c2400dae337771c6d3a (patch) | |
tree | d3db707f1c2e8236c78e143b48e1a2fd9f0323f9 /app/scripts/keyrings/hd.js | |
parent | cdd4faa917a2f02b531c479eb2f05f39f303d51b (diff) | |
parent | f2539d125c2cfe240511f8505e222a9893bf7748 (diff) | |
download | tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.gz tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.bz2 tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.lz tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.xz tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.zst tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.zip |
Merge branch 'master' into dev
Diffstat (limited to 'app/scripts/keyrings/hd.js')
-rw-r--r-- | app/scripts/keyrings/hd.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js index 2e3b74192..3a66f7868 100644 --- a/app/scripts/keyrings/hd.js +++ b/app/scripts/keyrings/hd.js @@ -74,7 +74,18 @@ class HdKeyring extends EventEmitter { } // For eth_sign, we need to sign transactions: - signMessage (withAccount, msgHex) { + // hd + signMessage (withAccount, data) { + const wallet = this._getWalletForAccount(withAccount) + 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)) + return Promise.resolve(rawMsgSig) + } + + // For eth_sign, we need to sign transactions: + newGethSignMessage (withAccount, msgHex) { const wallet = this._getWalletForAccount(withAccount) const privKey = wallet.getPrivateKey() const msgBuffer = ethUtil.toBuffer(msgHex) @@ -101,9 +112,11 @@ class HdKeyring extends EventEmitter { _getWalletForAccount (account) { + const targetAddress = sigUtil.normalize(account) return this.wallets.find((w) => { const address = w.getAddress().toString('hex') - return ((address === account) || (sigUtil.normalize(address) === account)) + return ((address === targetAddress) || + (sigUtil.normalize(address) === targetAddress)) }) } } |