From bedf6f40aff0dd14bfab533a37c329ddc9a4bdd5 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 20 Nov 2017 17:39:53 +0100 Subject: cmd/geth: make geth account new faster with many keys (#15529) --- cmd/geth/accountcmd.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go index 0f53c92b0..0db5c4ce0 100644 --- a/cmd/geth/accountcmd.go +++ b/cmd/geth/accountcmd.go @@ -291,15 +291,28 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr // accountCreate creates a new account into the keystore defined by the CLI flags. func accountCreate(ctx *cli.Context) error { - stack, _ := makeConfigNode(ctx) + cfg := gethConfig{Node: defaultNodeConfig()} + // Load config file. + if file := ctx.GlobalString(configFileFlag.Name); file != "" { + if err := loadConfig(file, &cfg); err != nil { + utils.Fatalf("%v", err) + } + } + utils.SetNodeConfig(ctx, &cfg.Node) + scryptN, scryptP, keydir, err := cfg.Node.AccountConfig() + + if err != nil { + utils.Fatalf("Failed to read configuration: %v", err) + } + password := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx)) - ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) - account, err := ks.NewAccount(password) + address, err := keystore.StoreKey(keydir, password, scryptN, scryptP) + if err != nil { utils.Fatalf("Failed to create account: %v", err) } - fmt.Printf("Address: {%x}\n", account.Address) + fmt.Printf("Address: {%x}\n", address) return nil } -- cgit v1.2.3 From 8f35e3086cbea24839c5435b1cebe85a438b42d3 Mon Sep 17 00:00:00 2001 From: Maximilian Meister Date: Tue, 28 Nov 2017 14:00:00 +0100 Subject: cmd/geth: fix geth attach --datadir=... (#15517) --- cmd/geth/consolecmd.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmd/geth') diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go index 2bb452d73..051962be4 100644 --- a/cmd/geth/consolecmd.go +++ b/cmd/geth/consolecmd.go @@ -17,6 +17,7 @@ package main import ( + "fmt" "os" "os/signal" "strings" @@ -112,7 +113,11 @@ func localConsole(ctx *cli.Context) error { // console to it. func remoteConsole(ctx *cli.Context) error { // Attach to a remotely running geth instance and start the JavaScript console - client, err := dialRPC(ctx.Args().First()) + endpoint := ctx.Args().First() + if endpoint == "" && ctx.GlobalIsSet(utils.DataDirFlag.Name) { + endpoint = fmt.Sprintf("%s/geth.ipc", ctx.GlobalString(utils.DataDirFlag.Name)) + } + client, err := dialRPC(endpoint) if err != nil { utils.Fatalf("Unable to attach to remote geth: %v", err) } -- cgit v1.2.3 From 6e613cf3de6ebfd14edd5a332baf6e4079c1c86f Mon Sep 17 00:00:00 2001 From: Sorin Neacsu Date: Tue, 5 Dec 2017 02:17:38 -0800 Subject: cmd/geth: add support for geth attach --testnet (#15597) --- cmd/geth/consolecmd.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go index 051962be4..2c6b16687 100644 --- a/cmd/geth/consolecmd.go +++ b/cmd/geth/consolecmd.go @@ -20,6 +20,7 @@ import ( "fmt" "os" "os/signal" + "path/filepath" "strings" "github.com/ethereum/go-ethereum/cmd/utils" @@ -114,8 +115,15 @@ func localConsole(ctx *cli.Context) error { func remoteConsole(ctx *cli.Context) error { // Attach to a remotely running geth instance and start the JavaScript console endpoint := ctx.Args().First() - if endpoint == "" && ctx.GlobalIsSet(utils.DataDirFlag.Name) { - endpoint = fmt.Sprintf("%s/geth.ipc", ctx.GlobalString(utils.DataDirFlag.Name)) + if endpoint == "" { + path := node.DefaultDataDir() + if ctx.GlobalIsSet(utils.DataDirFlag.Name) { + path = ctx.GlobalString(utils.DataDirFlag.Name) + } + if path != "" && ctx.GlobalBool(utils.TestnetFlag.Name) { + path = filepath.Join(path, "testnet") + } + endpoint = fmt.Sprintf("%s/geth.ipc", path) } client, err := dialRPC(endpoint) if err != nil { -- cgit v1.2.3