From e7cf0f4bdd537b69d27afa3c788f67b758d02c05 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 16 Jan 2017 11:49:31 -0800 Subject: keyring - simple - fix address generation --- app/scripts/keyrings/simple.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/scripts/keyrings') diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js index 9717f1c45..6f4512b70 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. @@ -70,7 +70,7 @@ class SimpleKeyring extends EventEmitter { /* PRIVATE METHODS */ _getWalletForAccount (account) { - return this.wallets.find(w => w.getAddress().toString('hex') === account) + return this.wallets.find(w => ethUtil.bufferToHex(w.getAddress()) === account) } } -- cgit From 82012cbbce47c691d322b290ad9e77723b289f0b Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 16 Jan 2017 11:54:59 -0800 Subject: keyring - simple - throw error if wallet not found for address --- app/scripts/keyrings/simple.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/scripts/keyrings') diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js index 6f4512b70..6b16137ae 100644 --- a/app/scripts/keyrings/simple.js +++ b/app/scripts/keyrings/simple.js @@ -54,6 +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) var privKey = wallet.getPrivateKey() var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey) @@ -70,7 +71,9 @@ class SimpleKeyring extends EventEmitter { /* PRIVATE METHODS */ _getWalletForAccount (account) { - return this.wallets.find(w => ethUtil.bufferToHex(w.getAddress()) === 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 } } -- cgit