2016-03-17 07:09:18 -05:00
|
|
|
// Copyright 2016 The go-ethereum Authors
|
|
|
|
// This file is part of go-ethereum.
|
|
|
|
//
|
|
|
|
// go-ethereum is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// go-ethereum is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-11-15 03:15:15 -06:00
|
|
|
"errors"
|
2016-03-17 07:09:18 -05:00
|
|
|
"fmt"
|
2022-05-16 04:59:35 -05:00
|
|
|
"os"
|
2024-11-15 03:15:15 -06:00
|
|
|
"strings"
|
2016-03-17 07:09:18 -05:00
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/accounts"
|
2017-01-24 03:49:20 -06:00
|
|
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
2016-03-17 07:09:18 -05:00
|
|
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
2024-11-15 03:15:15 -06:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2016-04-04 18:08:50 -05:00
|
|
|
"github.com/ethereum/go-ethereum/crypto"
|
2022-06-27 11:22:36 -05:00
|
|
|
"github.com/urfave/cli/v2"
|
2016-03-17 07:09:18 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-06-27 11:22:36 -05:00
|
|
|
walletCommand = &cli.Command{
|
2017-05-23 10:45:26 -05:00
|
|
|
Name: "wallet",
|
|
|
|
Usage: "Manage Ethereum presale wallets",
|
|
|
|
ArgsUsage: "",
|
2016-03-17 07:09:18 -05:00
|
|
|
Description: `
|
2017-05-23 10:45:26 -05:00
|
|
|
geth wallet import /path/to/my/presale.wallet
|
|
|
|
|
|
|
|
will prompt for your password and imports your ether presale account.
|
|
|
|
It can be used non-interactively with the --password option taking a
|
|
|
|
passwordfile as argument containing the wallet password in plaintext.`,
|
2022-06-27 11:22:36 -05:00
|
|
|
Subcommands: []*cli.Command{
|
2017-05-23 10:45:26 -05:00
|
|
|
{
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2017-05-23 10:45:26 -05:00
|
|
|
Name: "import",
|
|
|
|
Usage: "Import Ethereum presale wallet",
|
|
|
|
ArgsUsage: "<keyFile>",
|
2022-06-27 11:22:36 -05:00
|
|
|
Action: importWallet,
|
2017-05-23 10:45:26 -05:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
utils.DataDirFlag,
|
|
|
|
utils.KeyStoreDirFlag,
|
|
|
|
utils.PasswordFileFlag,
|
|
|
|
utils.LightKDFFlag,
|
|
|
|
},
|
|
|
|
Description: `
|
|
|
|
geth wallet [options] /path/to/my/presale.wallet
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2017-05-23 10:45:26 -05:00
|
|
|
will prompt for your password and imports your ether presale account.
|
|
|
|
It can be used non-interactively with the --password option taking a
|
|
|
|
passwordfile as argument containing the wallet password in plaintext.`,
|
|
|
|
},
|
|
|
|
},
|
2016-11-10 05:00:09 -06:00
|
|
|
}
|
2017-05-23 10:45:26 -05:00
|
|
|
|
2022-06-27 11:22:36 -05:00
|
|
|
accountCommand = &cli.Command{
|
|
|
|
Name: "account",
|
|
|
|
Usage: "Manage accounts",
|
2016-03-17 07:09:18 -05:00
|
|
|
Description: `
|
|
|
|
|
2017-04-28 05:38:49 -05:00
|
|
|
Manage accounts, list all existing accounts, import a private key into a new
|
|
|
|
account, create a new account or update an existing account.
|
2016-03-17 07:09:18 -05:00
|
|
|
|
|
|
|
It supports interactive mode, when you are prompted for password as well as
|
|
|
|
non-interactive mode where passwords are supplied via a given password file.
|
|
|
|
Non-interactive mode is only meant for scripted use on test networks or known
|
|
|
|
safe environments.
|
|
|
|
|
|
|
|
Make sure you remember the password you gave when creating a new account (with
|
|
|
|
either new or import). Without it you are not able to unlock your account.
|
|
|
|
|
|
|
|
Note that exporting your key in unencrypted format is NOT supported.
|
|
|
|
|
2016-06-08 09:00:18 -05:00
|
|
|
Keys are stored under <DATADIR>/keystore.
|
2016-03-17 07:09:18 -05:00
|
|
|
It is safe to transfer the entire directory or the individual keys therein
|
|
|
|
between ethereum nodes by simply copying.
|
|
|
|
|
2017-04-28 05:38:49 -05:00
|
|
|
Make sure you backup your keys regularly.`,
|
2022-06-27 11:22:36 -05:00
|
|
|
Subcommands: []*cli.Command{
|
2016-03-17 07:09:18 -05:00
|
|
|
{
|
2017-04-28 05:38:49 -05:00
|
|
|
Name: "list",
|
|
|
|
Usage: "Print summary of existing accounts",
|
2022-06-27 11:22:36 -05:00
|
|
|
Action: accountList,
|
2017-04-28 05:38:49 -05:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
utils.DataDirFlag,
|
|
|
|
utils.KeyStoreDirFlag,
|
|
|
|
},
|
2016-11-10 05:00:09 -06:00
|
|
|
Description: `
|
2017-04-28 05:38:49 -05:00
|
|
|
Print a short summary of all accounts`,
|
2016-03-17 07:09:18 -05:00
|
|
|
},
|
|
|
|
{
|
2017-04-28 05:38:49 -05:00
|
|
|
Name: "new",
|
|
|
|
Usage: "Create a new account",
|
2022-06-27 11:22:36 -05:00
|
|
|
Action: accountCreate,
|
2017-04-28 05:38:49 -05:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
utils.DataDirFlag,
|
|
|
|
utils.KeyStoreDirFlag,
|
|
|
|
utils.PasswordFileFlag,
|
|
|
|
utils.LightKDFFlag,
|
|
|
|
},
|
2016-03-17 07:09:18 -05:00
|
|
|
Description: `
|
2016-11-10 05:00:09 -06:00
|
|
|
geth account new
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2017-04-28 05:38:49 -05:00
|
|
|
Creates a new account and prints the address.
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2019-08-12 04:00:38 -05:00
|
|
|
The account is saved in encrypted format, you are prompted for a password.
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2019-08-12 04:00:38 -05:00
|
|
|
You must remember this password to unlock your account in the future.
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2019-08-12 04:00:38 -05:00
|
|
|
For non-interactive use the password can be specified with the --password flag:
|
2016-03-17 07:09:18 -05:00
|
|
|
|
|
|
|
Note, this is meant to be used for testing only, it is a bad idea to save your
|
|
|
|
password to file or expose in any other way.
|
2016-11-10 05:00:09 -06:00
|
|
|
`,
|
2016-03-17 07:09:18 -05:00
|
|
|
},
|
|
|
|
{
|
2016-11-10 05:00:09 -06:00
|
|
|
Name: "update",
|
|
|
|
Usage: "Update an existing account",
|
2022-06-27 11:22:36 -05:00
|
|
|
Action: accountUpdate,
|
2016-11-10 05:00:09 -06:00
|
|
|
ArgsUsage: "<address>",
|
2017-04-28 05:38:49 -05:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
utils.DataDirFlag,
|
|
|
|
utils.KeyStoreDirFlag,
|
|
|
|
utils.LightKDFFlag,
|
|
|
|
},
|
2016-03-17 07:09:18 -05:00
|
|
|
Description: `
|
2016-11-10 05:00:09 -06:00
|
|
|
geth account update <address>
|
2016-03-17 07:09:18 -05:00
|
|
|
|
|
|
|
Update an existing account.
|
|
|
|
|
|
|
|
The account is saved in the newest version in encrypted format, you are prompted
|
2019-08-12 04:00:38 -05:00
|
|
|
for a password to unlock the account and another to save the updated file.
|
2016-03-17 07:09:18 -05:00
|
|
|
|
|
|
|
This same command can therefore be used to migrate an account of a deprecated
|
|
|
|
format to the newest format or change the password for an account.
|
|
|
|
|
2019-08-12 04:00:38 -05:00
|
|
|
For non-interactive use the password can be specified with the --password flag:
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2017-04-28 05:38:49 -05:00
|
|
|
geth account update [options] <address>
|
2016-03-17 07:09:18 -05:00
|
|
|
|
|
|
|
Since only one password can be given, only format update can be performed,
|
|
|
|
changing your password is only possible interactively.
|
2016-11-10 05:00:09 -06:00
|
|
|
`,
|
2016-03-17 07:09:18 -05:00
|
|
|
},
|
|
|
|
{
|
2017-04-28 05:38:49 -05:00
|
|
|
Name: "import",
|
|
|
|
Usage: "Import a private key into a new account",
|
2022-06-27 11:22:36 -05:00
|
|
|
Action: accountImport,
|
2017-04-28 05:38:49 -05:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
utils.DataDirFlag,
|
|
|
|
utils.KeyStoreDirFlag,
|
|
|
|
utils.PasswordFileFlag,
|
|
|
|
utils.LightKDFFlag,
|
|
|
|
},
|
2016-11-10 05:00:09 -06:00
|
|
|
ArgsUsage: "<keyFile>",
|
2016-03-17 07:09:18 -05:00
|
|
|
Description: `
|
2016-11-10 05:00:09 -06:00
|
|
|
geth account import <keyfile>
|
2016-03-17 07:09:18 -05:00
|
|
|
|
|
|
|
Imports an unencrypted private key from <keyfile> and creates a new account.
|
|
|
|
Prints the address.
|
|
|
|
|
|
|
|
The keyfile is assumed to contain an unencrypted private key in hexadecimal format.
|
|
|
|
|
2019-08-12 04:00:38 -05:00
|
|
|
The account is saved in encrypted format, you are prompted for a password.
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2019-08-12 04:00:38 -05:00
|
|
|
You must remember this password to unlock your account in the future.
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2019-08-12 04:00:38 -05:00
|
|
|
For non-interactive use the password can be specified with the -password flag:
|
2016-03-17 07:09:18 -05:00
|
|
|
|
2017-04-28 05:38:49 -05:00
|
|
|
geth account import [options] <keyfile>
|
2016-03-17 07:09:18 -05:00
|
|
|
|
|
|
|
Note:
|
|
|
|
As you can directly copy your encrypted accounts to another ethereum instance,
|
|
|
|
this import mechanism is not needed when you transfer an account between
|
|
|
|
nodes.
|
2016-11-10 05:00:09 -06:00
|
|
|
`,
|
2016-03-17 07:09:18 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2023-04-27 05:57:29 -05:00
|
|
|
// makeAccountManager creates an account manager with backends
|
|
|
|
func makeAccountManager(ctx *cli.Context) *accounts.Manager {
|
|
|
|
cfg := loadBaseConfig(ctx)
|
2024-11-15 03:15:15 -06:00
|
|
|
am := accounts.NewManager(nil)
|
2023-04-27 05:57:29 -05:00
|
|
|
keydir, isEphemeral, err := cfg.Node.GetKeyStoreDir()
|
|
|
|
if err != nil {
|
|
|
|
utils.Fatalf("Failed to get the keystore directory: %v", err)
|
|
|
|
}
|
|
|
|
if isEphemeral {
|
|
|
|
utils.Fatalf("Can't use ephemeral directory as keystore path")
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := setAccountManagerBackends(&cfg.Node, am, keydir); err != nil {
|
|
|
|
utils.Fatalf("Failed to set account manager backends: %v", err)
|
|
|
|
}
|
|
|
|
return am
|
|
|
|
}
|
|
|
|
|
2016-06-10 03:23:00 -05:00
|
|
|
func accountList(ctx *cli.Context) error {
|
2023-04-27 05:57:29 -05:00
|
|
|
am := makeAccountManager(ctx)
|
2017-02-07 04:47:34 -06:00
|
|
|
var index int
|
2023-04-27 05:57:29 -05:00
|
|
|
for _, wallet := range am.Wallets() {
|
2017-02-07 04:47:34 -06:00
|
|
|
for _, account := range wallet.Accounts() {
|
2017-02-08 07:53:02 -06:00
|
|
|
fmt.Printf("Account #%d: {%x} %s\n", index, account.Address, &account.URL)
|
2017-02-07 04:47:34 -06:00
|
|
|
index++
|
|
|
|
}
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
2023-04-27 05:57:29 -05:00
|
|
|
|
2016-06-10 03:23:00 -05:00
|
|
|
return nil
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
|
|
|
|
2024-11-15 03:15:15 -06:00
|
|
|
// readPasswordFromFile reads the first line of the given file, trims line endings,
|
|
|
|
// and returns the password and whether the reading was successful.
|
|
|
|
func readPasswordFromFile(path string) (string, bool) {
|
|
|
|
if path == "" {
|
|
|
|
return "", false
|
2016-04-01 11:10:58 -05:00
|
|
|
}
|
2024-11-15 03:15:15 -06:00
|
|
|
text, err := os.ReadFile(path)
|
|
|
|
if err != nil {
|
|
|
|
utils.Fatalf("Failed to read password file: %v", err)
|
2016-04-01 11:10:58 -05:00
|
|
|
}
|
2024-11-15 03:15:15 -06:00
|
|
|
lines := strings.Split(string(text), "\n")
|
|
|
|
if len(lines) == 0 {
|
|
|
|
return "", false
|
2016-04-01 11:10:58 -05:00
|
|
|
}
|
2024-11-15 03:15:15 -06:00
|
|
|
// Sanitise DOS line endings.
|
|
|
|
return strings.TrimRight(lines[0], "\r"), true
|
2016-04-01 11:10:58 -05:00
|
|
|
}
|
|
|
|
|
2016-03-17 07:09:18 -05:00
|
|
|
// accountCreate creates a new account into the keystore defined by the CLI flags.
|
2016-06-10 03:23:00 -05:00
|
|
|
func accountCreate(ctx *cli.Context) error {
|
2023-04-27 05:57:29 -05:00
|
|
|
cfg := loadBaseConfig(ctx)
|
|
|
|
keydir, isEphemeral, err := cfg.Node.GetKeyStoreDir()
|
2017-11-20 10:39:53 -06:00
|
|
|
if err != nil {
|
2023-04-27 05:57:29 -05:00
|
|
|
utils.Fatalf("Failed to get the keystore directory: %v", err)
|
|
|
|
}
|
|
|
|
if isEphemeral {
|
|
|
|
utils.Fatalf("Can't use ephemeral directory as keystore path")
|
2017-11-20 10:39:53 -06:00
|
|
|
}
|
2021-08-25 15:34:22 -05:00
|
|
|
scryptN := keystore.StandardScryptN
|
|
|
|
scryptP := keystore.StandardScryptP
|
|
|
|
if cfg.Node.UseLightweightKDF {
|
|
|
|
scryptN = keystore.LightScryptN
|
|
|
|
scryptP = keystore.LightScryptP
|
|
|
|
}
|
2017-11-20 10:39:53 -06:00
|
|
|
|
2024-11-15 03:15:15 -06:00
|
|
|
password, ok := readPasswordFromFile(ctx.Path(utils.PasswordFileFlag.Name))
|
|
|
|
if !ok {
|
|
|
|
password = utils.GetPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true)
|
|
|
|
}
|
2019-05-07 07:49:51 -05:00
|
|
|
account, err := keystore.StoreKey(keydir, password, scryptN, scryptP)
|
2017-11-20 10:39:53 -06:00
|
|
|
|
2016-03-17 07:09:18 -05:00
|
|
|
if err != nil {
|
2017-02-22 09:22:50 -06:00
|
|
|
utils.Fatalf("Failed to create account: %v", err)
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
2019-05-07 07:49:51 -05:00
|
|
|
fmt.Printf("\nYour new key was generated\n\n")
|
|
|
|
fmt.Printf("Public address of the key: %s\n", account.Address.Hex())
|
|
|
|
fmt.Printf("Path of the secret key file: %s\n\n", account.URL.Path)
|
|
|
|
fmt.Printf("- You can share your public address with anyone. Others need it to interact with you.\n")
|
|
|
|
fmt.Printf("- You must NEVER share the secret key with anyone! The key controls access to your funds!\n")
|
|
|
|
fmt.Printf("- You must BACKUP your key file! Without the key, it's impossible to access account funds!\n")
|
|
|
|
fmt.Printf("- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!\n\n")
|
2016-06-10 03:23:00 -05:00
|
|
|
return nil
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// accountUpdate transitions an account from a previous format to the current
|
|
|
|
// one, also providing the possibility to change the pass-phrase.
|
2016-06-10 03:23:00 -05:00
|
|
|
func accountUpdate(ctx *cli.Context) error {
|
2022-06-27 11:22:36 -05:00
|
|
|
if ctx.Args().Len() == 0 {
|
2017-02-22 09:22:50 -06:00
|
|
|
utils.Fatalf("No accounts specified to update")
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
2023-04-27 05:57:29 -05:00
|
|
|
am := makeAccountManager(ctx)
|
|
|
|
backends := am.Backends(keystore.KeyStoreType)
|
2023-04-03 04:08:06 -05:00
|
|
|
if len(backends) == 0 {
|
|
|
|
utils.Fatalf("Keystore is not available")
|
|
|
|
}
|
|
|
|
ks := backends[0].(*keystore.KeyStore)
|
2017-01-24 03:49:20 -06:00
|
|
|
|
2022-06-27 11:22:36 -05:00
|
|
|
for _, addr := range ctx.Args().Slice() {
|
2024-11-15 03:15:15 -06:00
|
|
|
if !common.IsHexAddress(addr) {
|
|
|
|
return errors.New("address must be specified in hexadecimal form")
|
|
|
|
}
|
|
|
|
account := accounts.Account{Address: common.HexToAddress(addr)}
|
|
|
|
newPassword := utils.GetPassPhrase("Please give a NEW password. Do not forget this password.", true)
|
|
|
|
updateFn := func(attempt int) error {
|
|
|
|
prompt := fmt.Sprintf("Please provide the OLD password for account %s | Attempt %d/%d", addr, attempt+1, 3)
|
|
|
|
password := utils.GetPassPhrase(prompt, false)
|
|
|
|
return ks.Update(account, password, newPassword)
|
|
|
|
}
|
|
|
|
// let user attempt unlock thrice.
|
|
|
|
err := updateFn(0)
|
|
|
|
for attempts := 1; attempts < 3 && errors.Is(err, keystore.ErrDecrypt); attempts++ {
|
|
|
|
err = updateFn(attempts)
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("could not update account: %w", err)
|
2017-04-28 05:38:49 -05:00
|
|
|
}
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
2016-06-10 03:23:00 -05:00
|
|
|
return nil
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
|
|
|
|
2016-06-10 03:23:00 -05:00
|
|
|
func importWallet(ctx *cli.Context) error {
|
2022-06-27 11:22:36 -05:00
|
|
|
if ctx.Args().Len() != 1 {
|
|
|
|
utils.Fatalf("keyfile must be given as the only argument")
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
2022-06-27 11:22:36 -05:00
|
|
|
keyfile := ctx.Args().First()
|
2022-05-16 04:59:35 -05:00
|
|
|
keyJSON, err := os.ReadFile(keyfile)
|
2016-03-17 07:09:18 -05:00
|
|
|
if err != nil {
|
2017-02-22 09:22:50 -06:00
|
|
|
utils.Fatalf("Could not read wallet file: %v", err)
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
|
|
|
|
2023-04-27 05:57:29 -05:00
|
|
|
am := makeAccountManager(ctx)
|
|
|
|
backends := am.Backends(keystore.KeyStoreType)
|
2023-04-03 04:08:06 -05:00
|
|
|
if len(backends) == 0 {
|
|
|
|
utils.Fatalf("Keystore is not available")
|
|
|
|
}
|
2024-11-15 03:15:15 -06:00
|
|
|
password, ok := readPasswordFromFile(ctx.Path(utils.PasswordFileFlag.Name))
|
|
|
|
if !ok {
|
|
|
|
password = utils.GetPassPhrase("", false)
|
|
|
|
}
|
2023-04-03 04:08:06 -05:00
|
|
|
ks := backends[0].(*keystore.KeyStore)
|
2024-11-15 03:15:15 -06:00
|
|
|
acct, err := ks.ImportPreSaleKey(keyJSON, password)
|
2016-03-17 07:09:18 -05:00
|
|
|
if err != nil {
|
2017-02-22 09:22:50 -06:00
|
|
|
utils.Fatalf("%v", err)
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
2016-03-02 18:15:42 -06:00
|
|
|
fmt.Printf("Address: {%x}\n", acct.Address)
|
2016-06-10 03:23:00 -05:00
|
|
|
return nil
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
|
|
|
|
2016-06-10 03:23:00 -05:00
|
|
|
func accountImport(ctx *cli.Context) error {
|
2022-06-27 11:22:36 -05:00
|
|
|
if ctx.Args().Len() != 1 {
|
|
|
|
utils.Fatalf("keyfile must be given as the only argument")
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
2022-06-27 11:22:36 -05:00
|
|
|
keyfile := ctx.Args().First()
|
2016-04-04 18:08:50 -05:00
|
|
|
key, err := crypto.LoadECDSA(keyfile)
|
|
|
|
if err != nil {
|
2017-02-22 09:22:50 -06:00
|
|
|
utils.Fatalf("Failed to load the private key: %v", err)
|
2016-04-04 18:08:50 -05:00
|
|
|
}
|
2023-04-27 05:57:29 -05:00
|
|
|
am := makeAccountManager(ctx)
|
|
|
|
backends := am.Backends(keystore.KeyStoreType)
|
2023-04-03 04:08:06 -05:00
|
|
|
if len(backends) == 0 {
|
|
|
|
utils.Fatalf("Keystore is not available")
|
|
|
|
}
|
|
|
|
ks := backends[0].(*keystore.KeyStore)
|
2024-11-15 03:15:15 -06:00
|
|
|
password, ok := readPasswordFromFile(ctx.Path(utils.PasswordFileFlag.Name))
|
|
|
|
if !ok {
|
|
|
|
password = utils.GetPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true)
|
|
|
|
}
|
|
|
|
acct, err := ks.ImportECDSA(key, password)
|
2016-03-17 07:09:18 -05:00
|
|
|
if err != nil {
|
2017-02-22 09:22:50 -06:00
|
|
|
utils.Fatalf("Could not create the account: %v", err)
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|
2016-03-02 18:15:42 -06:00
|
|
|
fmt.Printf("Address: {%x}\n", acct.Address)
|
2016-06-10 03:23:00 -05:00
|
|
|
return nil
|
2016-03-17 07:09:18 -05:00
|
|
|
}
|