2020-10-15 22:31:52 +00:00
|
|
|
package accounts
|
2020-07-14 00:58:06 +00:00
|
|
|
|
|
|
|
import (
|
2020-08-20 17:53:09 +00:00
|
|
|
"os"
|
|
|
|
|
2021-09-21 18:11:16 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/cmd"
|
2021-03-02 18:58:40 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/cmd/validator/flags"
|
2021-09-15 01:18:39 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/config/features"
|
2021-09-16 09:46:29 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/runtime/tos"
|
2021-03-03 17:05:37 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/validator/accounts"
|
|
|
|
"github.com/sirupsen/logrus"
|
2020-07-14 00:58:06 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
2021-03-03 17:05:37 +00:00
|
|
|
var log = logrus.WithField("prefix", "accounts")
|
|
|
|
|
|
|
|
// Commands for managing Prysm validator accounts.
|
|
|
|
var Commands = &cli.Command{
|
2020-10-15 22:31:52 +00:00
|
|
|
Name: "accounts",
|
2020-07-15 04:05:21 +00:00
|
|
|
Category: "accounts",
|
2021-06-26 19:00:33 +00:00
|
|
|
Usage: "defines commands for interacting with Ethereum validator accounts",
|
2020-07-15 04:05:21 +00:00
|
|
|
Subcommands: []*cli.Command{
|
2020-08-11 03:54:37 +00:00
|
|
|
{
|
|
|
|
Name: "delete",
|
|
|
|
Description: `deletes the selected accounts from a users wallet.`,
|
2020-10-11 15:26:59 +00:00
|
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
2020-08-11 03:54:37 +00:00
|
|
|
flags.WalletDirFlag,
|
|
|
|
flags.WalletPasswordFileFlag,
|
2020-08-11 23:15:06 +00:00
|
|
|
flags.DeletePublicKeysFlag,
|
2021-09-15 01:18:39 +00:00
|
|
|
features.Mainnet,
|
|
|
|
features.PyrmontTestnet,
|
|
|
|
features.PraterTestnet,
|
2020-10-20 20:12:49 +00:00
|
|
|
cmd.AcceptTosFlag,
|
2020-10-11 15:26:59 +00:00
|
|
|
}),
|
|
|
|
Before: func(cliCtx *cli.Context) error {
|
2020-10-21 15:13:46 +00:00
|
|
|
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return tos.VerifyTosAcceptedOrPrompt(cliCtx)
|
2020-08-11 03:54:37 +00:00
|
|
|
},
|
|
|
|
Action: func(cliCtx *cli.Context) error {
|
2021-09-15 01:18:39 +00:00
|
|
|
features.ConfigureValidator(cliCtx)
|
2021-03-03 17:05:37 +00:00
|
|
|
if err := accounts.DeleteAccountCli(cliCtx); err != nil {
|
2020-08-11 03:54:37 +00:00
|
|
|
log.Fatalf("Could not delete account: %v", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
},
|
2020-07-15 04:05:21 +00:00
|
|
|
{
|
|
|
|
Name: "list",
|
|
|
|
Description: "Lists all validator accounts in a user's wallet directory",
|
2020-10-11 15:26:59 +00:00
|
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
2020-07-15 04:05:21 +00:00
|
|
|
flags.WalletDirFlag,
|
2020-07-29 01:20:13 +00:00
|
|
|
flags.WalletPasswordFileFlag,
|
2020-07-15 04:05:21 +00:00
|
|
|
flags.ShowDepositDataFlag,
|
2020-10-15 16:08:52 +00:00
|
|
|
flags.ShowPrivateKeysFlag,
|
2021-02-26 15:00:05 +00:00
|
|
|
flags.ListValidatorIndices,
|
|
|
|
flags.BeaconRPCProviderFlag,
|
|
|
|
cmd.GrpcMaxCallRecvMsgSizeFlag,
|
|
|
|
flags.CertFlag,
|
|
|
|
flags.GrpcHeadersFlag,
|
|
|
|
flags.GrpcRetriesFlag,
|
|
|
|
flags.GrpcRetryDelayFlag,
|
2021-09-15 01:18:39 +00:00
|
|
|
features.Mainnet,
|
|
|
|
features.PyrmontTestnet,
|
|
|
|
features.PraterTestnet,
|
2020-10-20 20:12:49 +00:00
|
|
|
cmd.AcceptTosFlag,
|
2020-10-11 15:26:59 +00:00
|
|
|
}),
|
|
|
|
Before: func(cliCtx *cli.Context) error {
|
2020-10-21 15:13:46 +00:00
|
|
|
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return tos.VerifyTosAcceptedOrPrompt(cliCtx)
|
2020-07-15 04:05:21 +00:00
|
|
|
},
|
2020-07-22 02:04:08 +00:00
|
|
|
Action: func(cliCtx *cli.Context) error {
|
2021-09-15 01:18:39 +00:00
|
|
|
features.ConfigureValidator(cliCtx)
|
2021-03-03 17:05:37 +00:00
|
|
|
if err := accounts.ListAccountsCli(cliCtx); err != nil {
|
2020-07-23 00:11:00 +00:00
|
|
|
log.Fatalf("Could not list accounts: %v", err)
|
2020-07-22 02:04:08 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
2020-07-14 00:58:06 +00:00
|
|
|
},
|
2020-07-15 04:05:21 +00:00
|
|
|
{
|
2020-08-11 23:15:06 +00:00
|
|
|
Name: "backup",
|
|
|
|
Description: "backup accounts into EIP-2335 compliant keystore.json files zipped into a backup.zip file " +
|
|
|
|
"at a desired output directory. Accounts to backup can also " +
|
|
|
|
"be specified programmatically via a --backup-for-public-keys flag which specifies a comma-separated " +
|
|
|
|
"list of hex string public keys",
|
2020-10-11 15:26:59 +00:00
|
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
2020-07-15 04:05:21 +00:00
|
|
|
flags.WalletDirFlag,
|
2020-08-31 23:38:20 +00:00
|
|
|
flags.WalletPasswordFileFlag,
|
2020-07-23 03:10:23 +00:00
|
|
|
flags.BackupDirFlag,
|
2020-08-11 23:15:06 +00:00
|
|
|
flags.BackupPublicKeysFlag,
|
|
|
|
flags.BackupPasswordFile,
|
2021-09-15 01:18:39 +00:00
|
|
|
features.Mainnet,
|
|
|
|
features.PyrmontTestnet,
|
|
|
|
features.PraterTestnet,
|
2020-10-20 20:12:49 +00:00
|
|
|
cmd.AcceptTosFlag,
|
2020-10-11 15:26:59 +00:00
|
|
|
}),
|
|
|
|
Before: func(cliCtx *cli.Context) error {
|
2020-10-21 15:13:46 +00:00
|
|
|
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return tos.VerifyTosAcceptedOrPrompt(cliCtx)
|
2020-07-15 04:05:21 +00:00
|
|
|
},
|
2020-07-22 02:04:08 +00:00
|
|
|
Action: func(cliCtx *cli.Context) error {
|
2021-09-15 01:18:39 +00:00
|
|
|
features.ConfigureValidator(cliCtx)
|
2021-03-03 17:05:37 +00:00
|
|
|
if err := accounts.BackupAccountsCli(cliCtx); err != nil {
|
2020-08-11 23:15:06 +00:00
|
|
|
log.Fatalf("Could not backup accounts: %v", err)
|
2020-07-22 02:04:08 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
2020-07-14 00:58:06 +00:00
|
|
|
},
|
2020-07-15 04:05:21 +00:00
|
|
|
{
|
|
|
|
Name: "import",
|
2021-06-26 19:00:33 +00:00
|
|
|
Description: `imports Ethereum validator accounts stored in EIP-2335 keystore.json files from an external directory`,
|
2020-10-11 15:26:59 +00:00
|
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
2020-07-15 04:05:21 +00:00
|
|
|
flags.WalletDirFlag,
|
2020-07-28 14:18:22 +00:00
|
|
|
flags.KeysDirFlag,
|
2020-07-29 01:20:13 +00:00
|
|
|
flags.WalletPasswordFileFlag,
|
2020-08-02 20:02:04 +00:00
|
|
|
flags.AccountPasswordFileFlag,
|
2020-08-11 16:32:05 +00:00
|
|
|
flags.ImportPrivateKeyFileFlag,
|
2021-09-15 01:18:39 +00:00
|
|
|
features.Mainnet,
|
|
|
|
features.PyrmontTestnet,
|
|
|
|
features.PraterTestnet,
|
2020-10-20 20:12:49 +00:00
|
|
|
cmd.AcceptTosFlag,
|
2020-10-11 15:26:59 +00:00
|
|
|
}),
|
|
|
|
Before: func(cliCtx *cli.Context) error {
|
2020-10-21 15:13:46 +00:00
|
|
|
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return tos.VerifyTosAcceptedOrPrompt(cliCtx)
|
2020-07-15 04:05:21 +00:00
|
|
|
},
|
2020-07-22 02:04:08 +00:00
|
|
|
Action: func(cliCtx *cli.Context) error {
|
2021-09-15 01:18:39 +00:00
|
|
|
features.ConfigureValidator(cliCtx)
|
2021-03-03 17:05:37 +00:00
|
|
|
if err := accounts.ImportAccountsCli(cliCtx); err != nil {
|
2020-07-23 00:11:00 +00:00
|
|
|
log.Fatalf("Could not import accounts: %v", err)
|
2020-07-22 02:04:08 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
2020-07-14 00:58:06 +00:00
|
|
|
},
|
2020-08-20 17:53:09 +00:00
|
|
|
{
|
|
|
|
Name: "voluntary-exit",
|
|
|
|
Description: "Performs a voluntary exit on selected accounts",
|
2020-10-11 15:26:59 +00:00
|
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
2020-08-20 17:53:09 +00:00
|
|
|
flags.WalletDirFlag,
|
|
|
|
flags.WalletPasswordFileFlag,
|
|
|
|
flags.AccountPasswordFileFlag,
|
|
|
|
flags.VoluntaryExitPublicKeysFlag,
|
2020-09-09 18:29:17 +00:00
|
|
|
flags.BeaconRPCProviderFlag,
|
|
|
|
cmd.GrpcMaxCallRecvMsgSizeFlag,
|
|
|
|
flags.CertFlag,
|
|
|
|
flags.GrpcHeadersFlag,
|
|
|
|
flags.GrpcRetriesFlag,
|
|
|
|
flags.GrpcRetryDelayFlag,
|
2021-02-11 16:50:16 +00:00
|
|
|
flags.ExitAllFlag,
|
2021-09-15 01:18:39 +00:00
|
|
|
features.Mainnet,
|
|
|
|
features.PyrmontTestnet,
|
|
|
|
features.PraterTestnet,
|
2020-10-20 20:12:49 +00:00
|
|
|
cmd.AcceptTosFlag,
|
2020-10-11 15:26:59 +00:00
|
|
|
}),
|
|
|
|
Before: func(cliCtx *cli.Context) error {
|
2020-10-21 15:13:46 +00:00
|
|
|
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return tos.VerifyTosAcceptedOrPrompt(cliCtx)
|
2020-08-20 17:53:09 +00:00
|
|
|
},
|
|
|
|
Action: func(cliCtx *cli.Context) error {
|
2021-09-15 01:18:39 +00:00
|
|
|
features.ConfigureValidator(cliCtx)
|
2021-03-03 17:05:37 +00:00
|
|
|
if err := accounts.ExitAccountsCli(cliCtx, os.Stdin); err != nil {
|
2020-08-20 17:53:09 +00:00
|
|
|
log.Fatalf("Could not perform voluntary exit: %v", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
},
|
2020-07-14 00:58:06 +00:00
|
|
|
},
|
|
|
|
}
|