mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
keyring - simple - throw error if wallet not found for address
This commit is contained in:
parent
e7cf0f4bdd
commit
82012cbbce
@ -54,6 +54,7 @@ class SimpleKeyring extends EventEmitter {
|
|||||||
// For eth_sign, we need to sign transactions:
|
// For eth_sign, we need to sign transactions:
|
||||||
signMessage (withAccount, data) {
|
signMessage (withAccount, data) {
|
||||||
const wallet = this._getWalletForAccount(withAccount)
|
const wallet = this._getWalletForAccount(withAccount)
|
||||||
|
|
||||||
const message = ethUtil.removeHexPrefix(data)
|
const message = ethUtil.removeHexPrefix(data)
|
||||||
var privKey = wallet.getPrivateKey()
|
var privKey = wallet.getPrivateKey()
|
||||||
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
|
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
|
||||||
@ -70,7 +71,9 @@ class SimpleKeyring extends EventEmitter {
|
|||||||
/* PRIVATE METHODS */
|
/* PRIVATE METHODS */
|
||||||
|
|
||||||
_getWalletForAccount (account) {
|
_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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user