aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-02-16 07:49:04 +0800
committerGitHub <noreply@github.com>2017-02-16 07:49:04 +0800
commit352bb5cb3941c3a07b383c2400dae337771c6d3a (patch)
treed3db707f1c2e8236c78e143b48e1a2fd9f0323f9 /app
parentcdd4faa917a2f02b531c479eb2f05f39f303d51b (diff)
parentf2539d125c2cfe240511f8505e222a9893bf7748 (diff)
downloadtangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.gz
tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.zst
tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.zip
Merge branch 'master' into dev
Diffstat (limited to 'app')
-rw-r--r--app/manifest.json2
-rw-r--r--app/scripts/keyrings/hd.js17
-rw-r--r--app/scripts/keyrings/simple.js16
3 files changed, 30 insertions, 5 deletions
diff --git a/app/manifest.json b/app/manifest.json
index c5d34e6ea..95475ddf1 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,7 +1,7 @@
{
"name": "MetaMask",
"short_name": "Metamask",
- "version": "3.2.1",
+ "version": "3.2.2",
"manifest_version": 2,
"author": "https://metamask.io",
"description": "Ethereum Browser Extension",
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))
})
}
}
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js
index fa8e9fd78..82881aa2d 100644
--- a/app/scripts/keyrings/simple.js
+++ b/app/scripts/keyrings/simple.js
@@ -58,7 +58,18 @@ class SimpleKeyring extends EventEmitter {
}
// For eth_sign, we need to sign transactions:
- signMessage (withAccount, msgHex) {
+ 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)
@@ -77,7 +88,8 @@ class SimpleKeyring extends EventEmitter {
/* PRIVATE METHODS */
_getWalletForAccount (account) {
- let wallet = this.wallets.find(w => ethUtil.bufferToHex(w.getAddress()) === account)
+ const address = sigUtil.normalize(account)
+ let wallet = this.wallets.find(w => ethUtil.bufferToHex(w.getAddress()) === address)
if (!wallet) throw new Error('Simple Keyring - Unable to find matching address.')
return wallet
}