mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
Merge 7f3a97d060 into 46e5583993
This commit is contained in:
commit
11924b8b67
1 changed files with 16 additions and 7 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/ecdsa"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
|
@ -165,14 +166,15 @@ changing your password is only possible interactively.
|
||||||
utils.PasswordFileFlag,
|
utils.PasswordFileFlag,
|
||||||
utils.LightKDFFlag,
|
utils.LightKDFFlag,
|
||||||
},
|
},
|
||||||
ArgsUsage: "<keyFile>",
|
ArgsUsage: "[<keyFile>]",
|
||||||
Description: `
|
Description: `
|
||||||
geth account import <keyfile>
|
geth account import [<keyfile>]
|
||||||
|
|
||||||
Imports an unencrypted private key from <keyfile> and creates a new account.
|
Imports an unencrypted private key in hexadecimal format and creates a new
|
||||||
Prints the address.
|
account, then prints the address.
|
||||||
|
|
||||||
The keyfile is assumed to contain an unencrypted private key in hexadecimal format.
|
The key will be read from <keyfile> if specified, otherwise you are prompted
|
||||||
|
for the key interactively.
|
||||||
|
|
||||||
The account is saved in encrypted format, you are prompted for a passphrase.
|
The account is saved in encrypted format, you are prompted for a passphrase.
|
||||||
|
|
||||||
|
|
@ -359,10 +361,17 @@ func importWallet(ctx *cli.Context) error {
|
||||||
|
|
||||||
func accountImport(ctx *cli.Context) error {
|
func accountImport(ctx *cli.Context) error {
|
||||||
keyfile := ctx.Args().First()
|
keyfile := ctx.Args().First()
|
||||||
|
var key *ecdsa.PrivateKey
|
||||||
|
var err error
|
||||||
if len(keyfile) == 0 {
|
if len(keyfile) == 0 {
|
||||||
utils.Fatalf("keyfile must be given as argument")
|
keystr, prompterr := console.Stdin.PromptInput("Key: ")
|
||||||
|
if prompterr != nil {
|
||||||
|
utils.Fatalf("Error reading private key %v", err)
|
||||||
|
}
|
||||||
|
key, err = crypto.HexToECDSA(keystr)
|
||||||
|
} else {
|
||||||
|
key, err = crypto.LoadECDSA(keyfile)
|
||||||
}
|
}
|
||||||
key, err := crypto.LoadECDSA(keyfile)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Failed to load the private key: %v", err)
|
utils.Fatalf("Failed to load the private key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue