aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 16:32:05 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 16:32:05 +0800
commit35cd355c14d9a5266a7d4b11127d25eb7f961494 (patch)
tree879c8d86b8865f733c73992e8c04c71d52152437 /cmd/utils
parentd764bd058457cd9eb91d205d1ac187d40c4866d6 (diff)
downloadgo-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.tar
go-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.tar.gz
go-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.tar.bz2
go-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.tar.lz
go-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.tar.xz
go-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.tar.zst
go-tangerine-35cd355c14d9a5266a7d4b11127d25eb7f961494.zip
cmd,eth,rpc,tests: default coinbase
Diffstat (limited to 'cmd/utils')
-rw-r--r--cmd/utils/flags.go28
1 files changed, 24 insertions, 4 deletions
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 &eth.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
+}