diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-07-07 17:55:33 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-07-07 17:55:33 +0800 |
commit | e5fba8fd7025bb45a88a19c1bbef80db5bd3b688 (patch) | |
tree | b17726c936fcb695e26b2a145b5d423b8556871b /cmd | |
parent | 916d1554675974adb92af4046e1b04ad3b26dca3 (diff) | |
parent | 37c1a8f69de44827a60296342189b6719a49dbc3 (diff) | |
download | go-tangerine-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.tar.gz go-tangerine-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.tar.zst go-tangerine-e5fba8fd7025bb45a88a19c1bbef80db5bd3b688.zip |
Merge pull request #1428 from obscuren/coinbase-fixes
cmd,eth,rpc,tests: default coinbase
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/main.go | 17 | ||||
-rw-r--r-- | cmd/utils/flags.go | 28 |
2 files changed, 25 insertions, 20 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 3428bb4cf..a05bb4db5 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -461,22 +461,7 @@ func execJSFiles(ctx *cli.Context) { func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (addrHex, auth string) { var err error - // Load startup keys. XXX we are going to need a different format - - if !((len(addr) == 40) || (len(addr) == 42)) { // with or without 0x - var index int - index, err = strconv.Atoi(addr) - if err != nil { - utils.Fatalf("Invalid account address '%s'", addr) - } - - addrHex, err = am.AddressByIndex(index) - if err != nil { - utils.Fatalf("%v", err) - } - } else { - addrHex = addr - } + addrHex = utils.ParamToAddress(addr, am) // Attempt to unlock the account 3 times attempts := 3 for tries := 0; tries < attempts; tries++ { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 20d3543d6..aaf569271 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "runtime" + "strconv" "github.com/ethereum/go-ethereum/metrics" @@ -122,8 +123,8 @@ var ( } EtherbaseFlag = cli.StringFlag{ Name: "etherbase", - Usage: "Public address for block mining rewards. By default the address of your primary account is used", - Value: "primary", + Usage: "Public address for block mining rewards. By default the address first created is used", + Value: "0", } GasPriceFlag = cli.StringFlag{ Name: "gasprice", @@ -351,6 +352,8 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { if len(customName) > 0 { clientID += "/" + customName } + am := MakeAccountManager(ctx) + return ð.Config{ Name: common.MakeName(clientID, version), DataDir: ctx.GlobalString(DataDirFlag.Name), @@ -361,9 +364,9 @@ 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: ctx.GlobalString(EtherbaseFlag.Name), + Etherbase: common.HexToAddress(ParamToAddress(ctx.GlobalString(EtherbaseFlag.Name), am)), MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name), - AccountManager: MakeAccountManager(ctx), + AccountManager: am, VmDebug: ctx.GlobalBool(VMDebugFlag.Name), MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name), MaxPendingPeers: ctx.GlobalInt(MaxPendingPeersFlag.Name), @@ -488,3 +491,20 @@ func StartPProf(ctx *cli.Context) { log.Println(http.ListenAndServe(address, nil)) }() } + +func ParamToAddress(addr string, am *accounts.Manager) (addrHex string) { + if !((len(addr) == 40) || (len(addr) == 42)) { // with or without 0x + index, err := strconv.Atoi(addr) + if err != nil { + Fatalf("Invalid account address '%s'", addr) + } + + addrHex, err = am.AddressByIndex(index) + if err != nil { + Fatalf("%v", err) + } + } else { + addrHex = addr + } + return +} |