Support multiple account unlock attempts

This commit is contained in:
Taylor Gerring 2015-05-19 14:46:32 -05:00
parent af8ada45e7
commit 32b8565022

View File

@ -368,9 +368,16 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass
if len(account) == 0 { if len(account) == 0 {
utils.Fatalf("Invalid account address '%s'", account) utils.Fatalf("Invalid account address '%s'", account)
} }
// Attempt to unlock the account // Attempt to unlock the account 3 times
passphrase = getPassPhrase(ctx, "Unlocking account "+account, false) attempts := 3
err = am.Unlock(common.HexToAddress(account), passphrase) 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 { if err != nil {
utils.Fatalf("Unlock account failed '%v'", err) utils.Fatalf("Unlock account failed '%v'", err)
} }