Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds --keystore #2293

Merged
merged 1 commit into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.GenesisFileFlag,
utils.BootnodesFlag,
utils.DataDirFlag,
utils.KeyStoreDirFlag,
utils.BlockchainVersionFlag,
utils.OlympicFlag,
utils.FastSyncFlag,
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var AppHelpFlagGroups = []flagGroup{
Name: "ETHEREUM",
Flags: []cli.Flag{
utils.DataDirFlag,
utils.KeyStoreDirFlag,
utils.NetworkIdFlag,
utils.OlympicFlag,
utils.TestNetFlag,
Expand Down
19 changes: 17 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ var (
Usage: "Data directory for the databases and keystore",
Value: DirectoryString{common.DefaultDataDir()},
}
KeyStoreDirFlag = DirectoryFlag{
Name: "keystore",
Usage: "Directory for the keystore (default = inside the datadir)",
}
NetworkIdFlag = cli.IntFlag{
Name: "networkid",
Usage: "Network identifier (integer, 0=Olympic, 1=Frontier, 2=Morden)",
Expand Down Expand Up @@ -393,6 +397,16 @@ func MustMakeDataDir(ctx *cli.Context) string {
return ""
}

// MakeKeyStoreDir resolves the folder to use for storing the account keys from the
// set command line flags, returning the explicitly requested path, or one inside
// the data directory otherwise.
func MakeKeyStoreDir(datadir string, ctx *cli.Context) string {
if path := ctx.GlobalString(KeyStoreDirFlag.Name); path != "" {
return path
}
return filepath.Join(datadir, "keystore")
}

// MakeIPCPath creates an IPC path configuration from the set command line flags,
// returning an empty string if IPC was explicitly disabled, or the set path.
func MakeIPCPath(ctx *cli.Context) string {
Expand Down Expand Up @@ -525,8 +539,9 @@ func MakeAccountManager(ctx *cli.Context) *accounts.Manager {
}
// Assemble an account manager using the configured datadir
var (
datadir = MustMakeDataDir(ctx)
keystore = crypto.NewKeyStorePassphrase(filepath.Join(datadir, "keystore"), scryptN, scryptP)
datadir = MustMakeDataDir(ctx)
keystoredir = MakeKeyStoreDir(datadir, ctx)
keystore = crypto.NewKeyStorePassphrase(keystoredir, scryptN, scryptP)
)
return accounts.NewManager(keystore)
}
Expand Down