Handle invalid passwords

This commit is contained in:
maciejhirsz 2017-04-06 17:36:21 +02:00
parent 564a1b0fbb
commit a45791d2c0
2 changed files with 16 additions and 0 deletions

View File

@ -170,6 +170,12 @@ export default class LocalAccountsMiddleware extends Middleware {
account.decryptPrivateKey(password) account.decryptPrivateKey(password)
]) ])
.then(([nonce, privateKey]) => { .then(([nonce, privateKey]) => {
if (!privateKey) {
transactions.unlock(id);
throw new Error('Invalid password');
}
const tx = new EthereumTx({ const tx = new EthereumTx({
nonce, nonce,
to, to,

View File

@ -68,6 +68,16 @@ class Transactions {
state.status = LOCKED; state.status = LOCKED;
} }
unlock (id) {
const state = this._states[id];
if (!state || state.status !== LOCKED) {
throw new Error('Trying to unlock an invalid transaction');
}
state.status = AWAITING;
}
hash (id) { hash (id) {
const state = this._states[id]; const state = this._states[id];