From aca9d6a1fb4c2b01d1b8f6e1bf165a39d4b9ac8e Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 30 Mar 2016 22:58:08 +0200 Subject: [PATCH] cmd/geth: print actual error when --unlock fails --- cmd/geth/accountcmd.go | 4 ++-- cmd/geth/accountcmd_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go index 6e8d2b7ebf..86175d05f6 100644 --- a/cmd/geth/accountcmd.go +++ b/cmd/geth/accountcmd.go @@ -181,13 +181,13 @@ func unlockAccount(ctx *cli.Context, accman *accounts.Manager, address string, i for trials := 0; trials < 3; trials++ { prompt := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", address, trials+1, 3) password := getPassPhrase(prompt, false, i, passwords) - if err := accman.Unlock(account, password); err == nil { + if err = accman.Unlock(account, password); err == nil { glog.V(logger.Info).Infof("Unlocked account %x", account.Address) return account, password } } // All trials expended to unlock account, bail out - utils.Fatalf("Failed to unlock account: %s", address) + utils.Fatalf("Failed to unlock account %s (%v)", address, err) return accounts.Account{}, "" } diff --git a/cmd/geth/accountcmd_test.go b/cmd/geth/accountcmd_test.go index fa3f73843a..440a0cb0b3 100644 --- a/cmd/geth/accountcmd_test.go +++ b/cmd/geth/accountcmd_test.go @@ -168,7 +168,7 @@ Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 2/3 Passphrase: {{.InputLine "wrong2"}} Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 3/3 Passphrase: {{.InputLine "wrong3"}} -Fatal: Failed to unlock account: f466859ead1932d743d622cb74fc058882e8648a +Fatal: Failed to unlock account f466859ead1932d743d622cb74fc058882e8648a (could not decrypt key with given passphrase) `) } @@ -225,6 +225,6 @@ func TestUnlockFlagPasswordFileWrongPassword(t *testing.T) { "--password", "testdata/wrong-passwords.txt", "--unlock", "0,2") defer geth.expectExit() geth.expect(` -Fatal: Failed to unlock account: 0 +Fatal: Failed to unlock account 0 (could not decrypt key with given passphrase) `) }