cmd/geth, cmd/utils: changed ParamsToAddress to return error

ParamsToAddress no longer aborts the process, it now returns an error
instead so that the caller can handle the error properly.
This commit is contained in:
Jeffrey Wilcke
2015-07-07 12:53:36 +02:00
parent 4b5c99d97f
commit ee04b71887
2 changed files with 19 additions and 12 deletions

View File

@ -458,17 +458,20 @@ func execJSFiles(ctx *cli.Context) {
func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (addrHex, auth string) {
var err error
addrHex = utils.ParamToAddress(addr, am)
// Attempt to unlock the account 3 times
attempts := 3
for tries := 0; tries < attempts; tries++ {
msg := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", addr, tries+1, attempts)
auth = getPassPhrase(ctx, msg, false, i)
err = am.Unlock(common.HexToAddress(addrHex), auth)
if err == nil {
break
addrHex, err = utils.ParamToAddress(addr, am)
if err == nil {
// Attempt to unlock the account 3 times
attempts := 3
for tries := 0; tries < attempts; tries++ {
msg := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", addr, tries+1, attempts)
auth = getPassPhrase(ctx, msg, false, i)
err = am.Unlock(common.HexToAddress(addrHex), auth)
if err == nil {
break
}
}
}
if err != nil {
utils.Fatalf("Unlock account failed '%v'", err)
}