aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils
diff options
context:
space:
mode:
authorKobi Gurkan <kobigurk@gmail.com>2016-03-08 06:38:56 +0800
committerKobi Gurkan <kobigurk@gmail.com>2016-03-08 06:38:56 +0800
commit627c2311fb2feaafdd55d444c3c2770d33c5b052 (patch)
treecae967047ad182ddbd5e74ce2e33d3802f32a1ee /cmd/utils
parentd45f01d5f782857c6a65f65fdc67b630a8f028bd (diff)
downloadgo-tangerine-627c2311fb2feaafdd55d444c3c2770d33c5b052.tar
go-tangerine-627c2311fb2feaafdd55d444c3c2770d33c5b052.tar.gz
go-tangerine-627c2311fb2feaafdd55d444c3c2770d33c5b052.tar.bz2
go-tangerine-627c2311fb2feaafdd55d444c3c2770d33c5b052.tar.lz
go-tangerine-627c2311fb2feaafdd55d444c3c2770d33c5b052.tar.xz
go-tangerine-627c2311fb2feaafdd55d444c3c2770d33c5b052.tar.zst
go-tangerine-627c2311fb2feaafdd55d444c3c2770d33c5b052.zip
cmd/utils: add --keystore
Diffstat (limited to 'cmd/utils')
-rw-r--r--cmd/utils/flags.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index adcc0adca..3efb65e42 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -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)",
@@ -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 {
@@ -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)
}