aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-10 22:44:05 +0800
committerFelix Lange <fjl@twurst.com>2015-03-10 22:44:05 +0800
commit0bb7377ebee69c3467c21d355dd24945d0becad5 (patch)
treeb358540359800a9bdc0c312061d0557bd2a5609e /cmd
parent9d4e1e8f8bbdfa84937bcdcdc6b4ca4ba6cd79a2 (diff)
downloaddexon-0bb7377ebee69c3467c21d355dd24945d0becad5.tar.gz
dexon-0bb7377ebee69c3467c21d355dd24945d0becad5.tar.zst
dexon-0bb7377ebee69c3467c21d355dd24945d0becad5.zip
cmd/ethereum: show more helpful message if no accounts exist
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ethereum/main.go19
-rw-r--r--cmd/mist/main.go5
-rw-r--r--cmd/utils/flags.go8
3 files changed, 23 insertions, 9 deletions
diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go
index 1703c02bb..8beba471a 100644
--- a/cmd/ethereum/main.go
+++ b/cmd/ethereum/main.go
@@ -29,6 +29,7 @@ import (
"time"
"github.com/codegangsta/cli"
+ "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
@@ -148,14 +149,28 @@ func main() {
func run(ctx *cli.Context) {
fmt.Printf("Welcome to the FRONTIER\n")
utils.HandleInterrupt()
- eth := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ eth, err := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ if err == accounts.ErrNoKeys {
+ utils.Fatalf(`No accounts configured.
+Please run 'ethereum account new' to create a new account.`)
+ } else if err != nil {
+ utils.Fatalf("%v", err)
+ }
+
startEth(ctx, eth)
// this blocks the thread
eth.WaitForShutdown()
}
func runjs(ctx *cli.Context) {
- eth := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ eth, err := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ if err == accounts.ErrNoKeys {
+ utils.Fatalf(`No accounts configured.
+Please run 'ethereum account new' to create a new account.`)
+ } else if err != nil {
+ utils.Fatalf("%v", err)
+ }
+
startEth(ctx, eth)
repl := newJSRE(eth)
if len(ctx.Args()) == 0 {
diff --git a/cmd/mist/main.go b/cmd/mist/main.go
index c27f1dba9..9a773e33a 100644
--- a/cmd/mist/main.go
+++ b/cmd/mist/main.go
@@ -95,7 +95,10 @@ func run(ctx *cli.Context) {
tstart := time.Now()
// TODO: show qml popup instead of exiting if initialization fails.
- ethereum := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ ethereum, err := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ if err != nil {
+ utils.Fatalf("%v", err)
+ }
utils.StartRPC(ethereum, ctx)
go utils.StartEthereum(ethereum)
fmt.Println("initializing eth stack took", time.Since(tstart))
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index cde5fa024..97d312dd4 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -157,8 +157,8 @@ func GetNodeKey(ctx *cli.Context) (key *ecdsa.PrivateKey) {
return key
}
-func GetEthereum(clientID, version string, ctx *cli.Context) *eth.Ethereum {
- ethereum, err := eth.New(&eth.Config{
+func GetEthereum(clientID, version string, ctx *cli.Context) (*eth.Ethereum, error) {
+ return eth.New(&eth.Config{
Name: p2p.MakeName(clientID, version),
DataDir: ctx.GlobalString(DataDirFlag.Name),
LogFile: ctx.GlobalString(LogFileFlag.Name),
@@ -175,10 +175,6 @@ func GetEthereum(clientID, version string, ctx *cli.Context) *eth.Ethereum {
Dial: true,
BootNodes: ctx.GlobalString(BootnodesFlag.Name),
})
- if err != nil {
- exit(err)
- }
- return ethereum
}
func GetChain(ctx *cli.Context) (*core.ChainManager, ethutil.Database, ethutil.Database) {