mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-04 07:07:13 +00:00
Generate account from seed
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user