From db06906c4fa31cb3f8e8528e31ceb7c3adb78af3 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 12:21:36 +0200 Subject: cmd/geth: version number 0.9.36 --- cmd/geth/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index a05bb4db5..c29d4a257 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -52,7 +52,7 @@ import ( const ( ClientIdentifier = "Geth" - Version = "0.9.35" + Version = "0.9.36" ) var ( -- cgit v1.2.3 From bfcac89881f241d48488ace7774ea6e5195e9f22 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 12:53:36 +0200 Subject: 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. --- cmd/geth/main.go | 21 ++++++++++++--------- cmd/utils/flags.go | 10 +++++++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index c29d4a257..2789601ac 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -461,17 +461,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) } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index aaf569271..91c412366 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -353,6 +353,10 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { clientID += "/" + customName } am := MakeAccountManager(ctx) + etherbase, err := ParamToAddress(ctx.GlobalString(EtherbaseFlag.Name), am) + if err != nil { + glog.V(logger.Error).Infoln("WARNING: No etherbase set and no accounts found as default") + } return ð.Config{ Name: common.MakeName(clientID, version), @@ -364,7 +368,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { LogFile: ctx.GlobalString(LogFileFlag.Name), Verbosity: ctx.GlobalInt(VerbosityFlag.Name), LogJSON: ctx.GlobalString(LogJSONFlag.Name), - Etherbase: common.HexToAddress(ParamToAddress(ctx.GlobalString(EtherbaseFlag.Name), am)), + Etherbase: common.HexToAddress(etherbase), MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name), AccountManager: am, VmDebug: ctx.GlobalBool(VMDebugFlag.Name), @@ -492,7 +496,7 @@ func StartPProf(ctx *cli.Context) { }() } -func ParamToAddress(addr string, am *accounts.Manager) (addrHex string) { +func ParamToAddress(addr string, am *accounts.Manager) (addrHex string, err error) { if !((len(addr) == 40) || (len(addr) == 42)) { // with or without 0x index, err := strconv.Atoi(addr) if err != nil { @@ -501,7 +505,7 @@ func ParamToAddress(addr string, am *accounts.Manager) (addrHex string) { addrHex, err = am.AddressByIndex(index) if err != nil { - Fatalf("%v", err) + return "", err } } else { addrHex = addr -- cgit v1.2.3 From 922f881c3d7c9139a6d7353f7eb23b8b19c6002d Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 13:01:39 +0200 Subject: common/natspec: fixed test --- common/natspec/natspec_e2e_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/natspec/natspec_e2e_test.go b/common/natspec/natspec_e2e_test.go index db5ef2527..d6ce7a2b0 100644 --- a/common/natspec/natspec_e2e_test.go +++ b/common/natspec/natspec_e2e_test.go @@ -125,7 +125,7 @@ func testEth(t *testing.T) (ethereum *eth.Ethereum, err error) { AccountManager: am, MaxPeers: 0, PowTest: true, - Etherbase: testAddress, + Etherbase: common.HexToAddress(testAddress), }) if err != nil { -- cgit v1.2.3 From 4b5c99d97fa885352f11007adbb5c3e2c194e353 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 12:21:36 +0200 Subject: cmd/geth: version number 0.9.36 --- cmd/geth/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index bb6ddc1e2..b9e9cd346 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -49,7 +49,7 @@ import ( const ( ClientIdentifier = "Geth" - Version = "0.9.35" + Version = "0.9.36" ) var ( -- cgit v1.2.3 From ee04b718876438feb0ed6d794f0caf72d24f777a Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 12:53:36 +0200 Subject: 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. --- cmd/geth/main.go | 21 ++++++++++++--------- cmd/utils/flags.go | 10 +++++++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index b9e9cd346..5ac93a983 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -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) } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index d58c754fe..903c97e71 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -369,6 +369,10 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { clientID += "/" + customName } am := MakeAccountManager(ctx) + etherbase, err := ParamToAddress(ctx.GlobalString(EtherbaseFlag.Name), am) + if err != nil { + glog.V(logger.Error).Infoln("WARNING: No etherbase set and no accounts found as default") + } return ð.Config{ Name: common.MakeName(clientID, version), @@ -380,7 +384,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { LogFile: ctx.GlobalString(LogFileFlag.Name), Verbosity: ctx.GlobalInt(VerbosityFlag.Name), LogJSON: ctx.GlobalString(LogJSONFlag.Name), - Etherbase: common.HexToAddress(ParamToAddress(ctx.GlobalString(EtherbaseFlag.Name), am)), + Etherbase: common.HexToAddress(etherbase), MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name), AccountManager: am, VmDebug: ctx.GlobalBool(VMDebugFlag.Name), @@ -508,7 +512,7 @@ func StartPProf(ctx *cli.Context) { }() } -func ParamToAddress(addr string, am *accounts.Manager) (addrHex string) { +func ParamToAddress(addr string, am *accounts.Manager) (addrHex string, err error) { if !((len(addr) == 40) || (len(addr) == 42)) { // with or without 0x index, err := strconv.Atoi(addr) if err != nil { @@ -517,7 +521,7 @@ func ParamToAddress(addr string, am *accounts.Manager) (addrHex string) { addrHex, err = am.AddressByIndex(index) if err != nil { - Fatalf("%v", err) + return "", err } } else { addrHex = addr -- cgit v1.2.3 From df54510e3e5dbbdc0a9fea2b14ab5858af2f74e3 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 13:01:39 +0200 Subject: common/natspec: fixed test --- common/natspec/natspec_e2e_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/natspec/natspec_e2e_test.go b/common/natspec/natspec_e2e_test.go index 890bdd9ca..0cbe040c0 100644 --- a/common/natspec/natspec_e2e_test.go +++ b/common/natspec/natspec_e2e_test.go @@ -141,7 +141,7 @@ func testEth(t *testing.T) (ethereum *eth.Ethereum, err error) { AccountManager: am, MaxPeers: 0, PowTest: true, - Etherbase: testAddress, + Etherbase: common.HexToAddress(testAddress), }) if err != nil { -- cgit v1.2.3