Handle invalid passwords
This commit is contained in:
parent
564a1b0fbb
commit
a45791d2c0
@ -170,6 +170,12 @@ export default class LocalAccountsMiddleware extends Middleware {
|
||||
account.decryptPrivateKey(password)
|
||||
])
|
||||
.then(([nonce, privateKey]) => {
|
||||
if (!privateKey) {
|
||||
transactions.unlock(id);
|
||||
|
||||
throw new Error('Invalid password');
|
||||
}
|
||||
|
||||
const tx = new EthereumTx({
|
||||
nonce,
|
||||
to,
|
||||
|
@ -68,6 +68,16 @@ class Transactions {
|
||||
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) {
|
||||
const state = this._states[id];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user