diff options
author | obscuren <geffobscura@gmail.com> | 2014-07-16 02:36:45 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-07-16 02:36:45 +0800 |
commit | c302afd411e3f54ba4ee98bec5c964bdcf36adef (patch) | |
tree | b6a815075e9bf40516eb92bb1556d340ca7265ab /utils | |
parent | 28948d061cfc14d7a5da307a12ebd504b78d2dbb (diff) | |
parent | 223432fa1eedb9fa5c712056afb804322aa12b02 (diff) | |
download | dexon-c302afd411e3f54ba4ee98bec5c964bdcf36adef.tar dexon-c302afd411e3f54ba4ee98bec5c964bdcf36adef.tar.gz dexon-c302afd411e3f54ba4ee98bec5c964bdcf36adef.tar.bz2 dexon-c302afd411e3f54ba4ee98bec5c964bdcf36adef.tar.lz dexon-c302afd411e3f54ba4ee98bec5c964bdcf36adef.tar.xz dexon-c302afd411e3f54ba4ee98bec5c964bdcf36adef.tar.zst dexon-c302afd411e3f54ba4ee98bec5c964bdcf36adef.zip |
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Diffstat (limited to 'utils')
-rw-r--r-- | utils/cmd.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/utils/cmd.go b/utils/cmd.go index 889726b04..1e1599582 100644 --- a/utils/cmd.go +++ b/utils/cmd.go @@ -1,6 +1,7 @@ package utils import ( + "bitbucket.org/kardianos/osext" "fmt" "github.com/ethereum/eth-go" "github.com/ethereum/eth-go/ethcrypto" @@ -16,6 +17,8 @@ import ( "os" "os/signal" "path" + "path/filepath" + "runtime" "time" ) @@ -164,7 +167,34 @@ func NewKeyManager(KeyStore string, Datadir string, db ethutil.Database) *ethcry return keyManager } +func DefaultAssetPath() string { + var assetPath string + // If the current working directory is the go-ethereum dir + // assume a debug build and use the source directory as + // asset directory. + pwd, _ := os.Getwd() + if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "ethereal") { + assetPath = path.Join(pwd, "assets") + } else { + switch runtime.GOOS { + case "darwin": + // Get Binary Directory + exedir, _ := osext.ExecutableFolder() + assetPath = filepath.Join(exedir, "../Resources") + case "linux": + assetPath = "/usr/share/ethereal" + case "windows": + assetPath = "./assets" + default: + assetPath = "." + } + } + return assetPath +} + func KeyTasks(keyManager *ethcrypto.KeyManager, KeyRing string, GenAddr bool, SecretFile string, ExportDir string, NonInteractive bool) { + ethcrypto.InitWords(DefaultAssetPath()) // Init mnemonic word list + var err error switch { case GenAddr: |