Skip to content

Commit

Permalink
Support multiple account unlock attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
tgerring committed May 19, 2015
1 parent af8ada4 commit 32b8565
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,16 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass
if len(account) == 0 {
utils.Fatalf("Invalid account address '%s'", account)
}
// Attempt to unlock the account
passphrase = getPassPhrase(ctx, "Unlocking account "+account, false)
err = am.Unlock(common.HexToAddress(account), passphrase)
// Attempt to unlock the account 3 times
attempts := 3
for tries := 0; tries < attempts; tries++ {
msg := fmt.Sprintf("Unlocking account %s...%s | Attempt %d/%d", account[:8], account[len(account)-6:], tries+1, attempts)
passphrase = getPassPhrase(ctx, msg, false)
err = am.Unlock(common.HexToAddress(account), passphrase)
if err == nil {
break
}
}
if err != nil {
utils.Fatalf("Unlock account failed '%v'", err)
}
Expand Down

0 comments on commit 32b8565

Please sign in to comment.