mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-25 04:47:17 +00:00
cmd/ethereum: add a flag to switch to unencrytped keystore
This is mostly for automated tests. The tests can use the following commands to start the node: ethereum --unencrypted-keys account new ... ethereum --unencrypted-keys
This commit is contained in:
parent
58909117be
commit
99bc44cf52
@ -127,6 +127,7 @@ runtime will execute the file and exit.
|
|||||||
utils.RPCEnabledFlag,
|
utils.RPCEnabledFlag,
|
||||||
utils.RPCListenAddrFlag,
|
utils.RPCListenAddrFlag,
|
||||||
utils.RPCPortFlag,
|
utils.RPCPortFlag,
|
||||||
|
utils.UnencryptedKeysFlag,
|
||||||
utils.VMDebugFlag,
|
utils.VMDebugFlag,
|
||||||
//utils.VMTypeFlag,
|
//utils.VMTypeFlag,
|
||||||
}
|
}
|
||||||
@ -213,20 +214,24 @@ func accountList(ctx *cli.Context) {
|
|||||||
|
|
||||||
func accountCreate(ctx *cli.Context) {
|
func accountCreate(ctx *cli.Context) {
|
||||||
am := utils.GetAccountManager(ctx)
|
am := utils.GetAccountManager(ctx)
|
||||||
fmt.Println("The new account will be encrypted with a passphrase.")
|
passphrase := ""
|
||||||
fmt.Println("Please enter a passphrase now.")
|
if !ctx.GlobalBool(utils.UnencryptedKeysFlag.Name) {
|
||||||
auth, err := readPassword("Passphrase: ", true)
|
fmt.Println("The new account will be encrypted with a passphrase.")
|
||||||
if err != nil {
|
fmt.Println("Please enter a passphrase now.")
|
||||||
utils.Fatalf("%v", err)
|
auth, err := readPassword("Passphrase: ", true)
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("%v", err)
|
||||||
|
}
|
||||||
|
confirm, err := readPassword("Repeat Passphrase: ", false)
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("%v", err)
|
||||||
|
}
|
||||||
|
if auth != confirm {
|
||||||
|
utils.Fatalf("Passphrases did not match.")
|
||||||
|
}
|
||||||
|
passphrase = auth
|
||||||
}
|
}
|
||||||
confirm, err := readPassword("Repeat Passphrase: ", false)
|
acct, err := am.NewAccount(passphrase)
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("%v", err)
|
|
||||||
}
|
|
||||||
if auth != confirm {
|
|
||||||
utils.Fatalf("Passphrases did not match.")
|
|
||||||
}
|
|
||||||
acct, err := am.NewAccount(auth)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Could not create the account: %v", err)
|
utils.Fatalf("Could not create the account: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,10 @@ var (
|
|||||||
Name: "mine",
|
Name: "mine",
|
||||||
Usage: "Enable mining",
|
Usage: "Enable mining",
|
||||||
}
|
}
|
||||||
|
UnencryptedKeysFlag = cli.BoolFlag{
|
||||||
|
Name: "unencrypted-keys",
|
||||||
|
Usage: "disable private key disk encryption (for testing)",
|
||||||
|
}
|
||||||
|
|
||||||
LogFileFlag = cli.StringFlag{
|
LogFileFlag = cli.StringFlag{
|
||||||
Name: "logfile",
|
Name: "logfile",
|
||||||
@ -220,7 +224,12 @@ func GetChain(ctx *cli.Context) (*core.ChainManager, ethutil.Database, ethutil.D
|
|||||||
|
|
||||||
func GetAccountManager(ctx *cli.Context) *accounts.Manager {
|
func GetAccountManager(ctx *cli.Context) *accounts.Manager {
|
||||||
dataDir := ctx.GlobalString(DataDirFlag.Name)
|
dataDir := ctx.GlobalString(DataDirFlag.Name)
|
||||||
ks := crypto.NewKeyStorePassphrase(path.Join(dataDir, "keys"))
|
var ks crypto.KeyStore2
|
||||||
|
if ctx.GlobalBool(UnencryptedKeysFlag.Name) {
|
||||||
|
ks = crypto.NewKeyStorePlain(path.Join(dataDir, "plainkeys"))
|
||||||
|
} else {
|
||||||
|
ks = crypto.NewKeyStorePassphrase(path.Join(dataDir, "keys"))
|
||||||
|
}
|
||||||
return accounts.NewManager(ks)
|
return accounts.NewManager(ks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user