aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/geth/js.go2
-rw-r--r--cmd/geth/main.go7
-rw-r--r--cmd/utils/flags.go32
-rw-r--r--eth/backend.go2
4 files changed, 20 insertions, 23 deletions
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index 196f3af59..843c9a5b5 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -245,7 +245,7 @@ func (self *jsre) batch(statement string) {
func (self *jsre) welcome() {
self.re.Run(`
(function () {
- console.log('instance: ' + web3.version.client);
+ console.log('instance: ' + web3.version.node);
console.log(' datadir: ' + admin.datadir);
console.log("coinbase: " + eth.coinbase);
var ts = 1000 * eth.getBlock(eth.blockNumber).timestamp;
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 3a5471845..6ec30cebc 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -464,9 +464,12 @@ func execScripts(ctx *cli.Context) {
node.Stop()
}
+// tries unlocking the specified account a few times.
func unlockAccount(ctx *cli.Context, accman *accounts.Manager, address string, i int, passwords []string) (common.Address, string) {
- // Try to unlock the specified account a few times
- account := utils.MakeAddress(accman, address)
+ account, err := utils.MakeAddress(accman, address)
+ if err != nil {
+ utils.Fatalf("Unlock error: %v", err)
+ }
for trials := 0; trials < 3; trials++ {
prompt := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", address, trials+1, 3)
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 53126f9e5..839ec3f02 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -518,47 +518,41 @@ func MakeAccountManager(ctx *cli.Context) *accounts.Manager {
// MakeAddress converts an account specified directly as a hex encoded string or
// a key index in the key store to an internal account representation.
-func MakeAddress(accman *accounts.Manager, account string) common.Address {
+func MakeAddress(accman *accounts.Manager, account string) (a common.Address, err error) {
// If the specified account is a valid address, return it
if common.IsHexAddress(account) {
- return common.HexToAddress(account)
+ return common.HexToAddress(account), nil
}
// Otherwise try to interpret the account as a keystore index
index, err := strconv.Atoi(account)
if err != nil {
- Fatalf("Invalid account address or index: '%s'", account)
+ return a, fmt.Errorf("invalid account address or index %q", account)
}
hex, err := accman.AddressByIndex(index)
if err != nil {
- Fatalf("Failed to retrieve requested account #%d: %v", index, err)
+ return a, fmt.Errorf("can't get account #%d (%v)", index, err)
}
- return common.HexToAddress(hex)
+ return common.HexToAddress(hex), nil
}
// MakeEtherbase retrieves the etherbase either from the directly specified
// command line flags or from the keystore if CLI indexed.
func MakeEtherbase(accman *accounts.Manager, ctx *cli.Context) common.Address {
- // If the specified etherbase is a valid address, return it
- etherbase := ctx.GlobalString(EtherbaseFlag.Name)
- if common.IsHexAddress(etherbase) {
- return common.HexToAddress(etherbase)
- }
- // If no etherbase was specified and no accounts are known, bail out
accounts, _ := accman.Accounts()
- if etherbase == "" && len(accounts) == 0 {
+ if !ctx.GlobalIsSet(EtherbaseFlag.Name) && len(accounts) == 0 {
glog.V(logger.Error).Infoln("WARNING: No etherbase set and no accounts found as default")
return common.Address{}
}
- // Otherwise try to interpret the parameter as a keystore index
- index, err := strconv.Atoi(etherbase)
- if err != nil {
- Fatalf("Invalid account address or index: '%s'", etherbase)
+ etherbase := ctx.GlobalString(EtherbaseFlag.Name)
+ if etherbase == "" {
+ return common.Address{}
}
- hex, err := accman.AddressByIndex(index)
+ // If the specified etherbase is a valid address, return it
+ addr, err := MakeAddress(accman, etherbase)
if err != nil {
- Fatalf("Failed to set requested account #%d as etherbase: %v", index, err)
+ Fatalf("Option %q: %v", EtherbaseFlag.Name, err)
}
- return common.HexToAddress(hex)
+ return addr
}
// MakeMinerExtra resolves extradata for the miner from the set command line flags
diff --git a/eth/backend.go b/eth/backend.go
index 0369f6afd..91f02db72 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -191,7 +191,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
shutdownChan: make(chan bool),
chainDb: chainDb,
dappDb: dappDb,
- eventMux: &event.TypeMux{},
+ eventMux: ctx.EventMux,
accountManager: config.AccountManager,
etherbase: config.Etherbase,
netVersionId: config.NetworkId,