Generate account from seed

This commit is contained in:
Jae Kwon
2015-08-14 10:49:44 -07:00
parent 5bf0040f14
commit 4d765dcf2b
5 changed files with 48 additions and 29 deletions
-20
View File
@@ -1,30 +1,10 @@
package config
import (
"bufio"
"fmt"
"os"
"strings"
"sync"
"time"
)
func Prompt(prompt string, defaultValue string) string {
fmt.Print(prompt)
reader := bufio.NewReader(os.Stdin)
line, err := reader.ReadString('\n')
if err != nil {
log.Warn("Error reading stdin", "err", err)
return defaultValue
} else {
line = strings.TrimSpace(line)
if line == "" {
return defaultValue
}
return line
}
}
type Config interface {
Get(key string) interface{}
GetBool(key string) bool
+2 -2
View File
@@ -30,8 +30,8 @@ func initTMRoot(rootDir string) {
// Write default config file if missing.
if !FileExists(configFilePath) {
// Ask user for moniker
moniker := cfg.Prompt("Type hostname: ", "anonymous")
MustWriteFile(configFilePath, []byte(defaultConfig(moniker)))
// moniker := cfg.Prompt("Type hostname: ", "anonymous")
MustWriteFile(configFilePath, []byte(defaultConfig("anonymous")))
}
if !FileExists(genesisFilePath) {
MustWriteFile(genesisFilePath, []byte(defaultGenesis))
+2 -2
View File
@@ -35,8 +35,8 @@ func initTMRoot(rootDir string) {
// Write default config file if missing.
if !FileExists(configFilePath) {
// Ask user for moniker
moniker := cfg.Prompt("Type hostname: ", "anonymous")
MustWriteFile(configFilePath, []byte(defaultConfig(moniker)))
// moniker := cfg.Prompt("Type hostname: ", "anonymous")
MustWriteFile(configFilePath, []byte(defaultConfig("anonymous")))
}
if !FileExists(genesisFilePath) {
MustWriteFile(genesisFilePath, []byte(defaultGenesis))