Support multiple account unlock attempts

pull/1046/head
Taylor Gerring 10 years ago
parent af8ada45e7
commit 32b8565022
  1. 13
      cmd/geth/main.go

@ -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)
} }

Loading…
Cancel
Save