accounts

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2021 License: GPL-3.0 Imports: 45 Imported by: 18

Documentation

Overview

Package v2 defines a new model for accounts management in Prysm, using best practices for user security, UX, and extensibility via different wallet types including HD wallets, imported (non-HD) wallets, and remote-signing capable configurations. This model is compliant with the EIP-2333, EIP-2334, and EIP-2335 standards for key management in eth2.

Index

Constants

This section is empty.

Variables

View Source
var AccountCommands = &cli.Command{
	Name:     "accounts",
	Category: "accounts",
	Usage:    "defines commands for interacting with eth2 validator accounts",
	Subcommands: []*cli.Command{
		{
			Name:        "delete",
			Description: `deletes the selected accounts from a users wallet.`,
			Flags: cmd.WrapFlags([]cli.Flag{
				flags.WalletDirFlag,
				flags.WalletPasswordFileFlag,
				flags.DeletePublicKeysFlag,
				featureconfig.Mainnet,
				featureconfig.PyrmontTestnet,
				featureconfig.ToledoTestnet,
				cmd.AcceptTosFlag,
			}),
			Before: func(cliCtx *cli.Context) error {
				if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
					return err
				}
				return tos.VerifyTosAcceptedOrPrompt(cliCtx)
			},
			Action: func(cliCtx *cli.Context) error {
				featureconfig.ConfigureValidator(cliCtx)
				if err := DeleteAccountCli(cliCtx); err != nil {
					log.Fatalf("Could not delete account: %v", err)
				}
				return nil
			},
		},
		{
			Name:        "list",
			Description: "Lists all validator accounts in a user's wallet directory",
			Flags: cmd.WrapFlags([]cli.Flag{
				flags.WalletDirFlag,
				flags.WalletPasswordFileFlag,
				flags.ShowDepositDataFlag,
				flags.ShowPrivateKeysFlag,
				featureconfig.Mainnet,
				featureconfig.PyrmontTestnet,
				featureconfig.ToledoTestnet,
				cmd.AcceptTosFlag,
			}),
			Before: func(cliCtx *cli.Context) error {
				if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
					return err
				}
				return tos.VerifyTosAcceptedOrPrompt(cliCtx)
			},
			Action: func(cliCtx *cli.Context) error {
				featureconfig.ConfigureValidator(cliCtx)
				if err := ListAccountsCli(cliCtx); err != nil {
					log.Fatalf("Could not list accounts: %v", err)
				}
				return nil
			},
		},
		{
			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",
			Flags: cmd.WrapFlags([]cli.Flag{
				flags.WalletDirFlag,
				flags.WalletPasswordFileFlag,
				flags.BackupDirFlag,
				flags.BackupPublicKeysFlag,
				flags.BackupPasswordFile,
				featureconfig.Mainnet,
				featureconfig.PyrmontTestnet,
				featureconfig.ToledoTestnet,
				cmd.AcceptTosFlag,
			}),
			Before: func(cliCtx *cli.Context) error {
				if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
					return err
				}
				return tos.VerifyTosAcceptedOrPrompt(cliCtx)
			},
			Action: func(cliCtx *cli.Context) error {
				featureconfig.ConfigureValidator(cliCtx)
				if err := BackupAccountsCli(cliCtx); err != nil {
					log.Fatalf("Could not backup accounts: %v", err)
				}
				return nil
			},
		},
		{
			Name:        "import",
			Description: `imports eth2 validator accounts stored in EIP-2335 keystore.json files from an external directory`,
			Flags: cmd.WrapFlags([]cli.Flag{
				flags.WalletDirFlag,
				flags.KeysDirFlag,
				flags.WalletPasswordFileFlag,
				flags.AccountPasswordFileFlag,
				flags.ImportPrivateKeyFileFlag,
				featureconfig.Mainnet,
				featureconfig.PyrmontTestnet,
				featureconfig.ToledoTestnet,
				cmd.AcceptTosFlag,
			}),
			Before: func(cliCtx *cli.Context) error {
				if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
					return err
				}
				return tos.VerifyTosAcceptedOrPrompt(cliCtx)
			},
			Action: func(cliCtx *cli.Context) error {
				featureconfig.ConfigureValidator(cliCtx)
				if err := ImportAccountsCli(cliCtx); err != nil {
					log.Fatalf("Could not import accounts: %v", err)
				}
				return nil
			},
		},
		{
			Name:        "voluntary-exit",
			Description: "Performs a voluntary exit on selected accounts",
			Flags: cmd.WrapFlags([]cli.Flag{
				flags.WalletDirFlag,
				flags.WalletPasswordFileFlag,
				flags.AccountPasswordFileFlag,
				flags.VoluntaryExitPublicKeysFlag,
				flags.BeaconRPCProviderFlag,
				cmd.GrpcMaxCallRecvMsgSizeFlag,
				flags.CertFlag,
				flags.GrpcHeadersFlag,
				flags.GrpcRetriesFlag,
				flags.GrpcRetryDelayFlag,
				flags.ExitAllFlag,
				featureconfig.Mainnet,
				featureconfig.PyrmontTestnet,
				featureconfig.ToledoTestnet,
				cmd.AcceptTosFlag,
			}),
			Before: func(cliCtx *cli.Context) error {
				if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
					return err
				}
				return tos.VerifyTosAcceptedOrPrompt(cliCtx)
			},
			Action: func(cliCtx *cli.Context) error {
				featureconfig.ConfigureValidator(cliCtx)
				if err := ExitAccountsCli(cliCtx, os.Stdin); err != nil {
					log.Fatalf("Could not perform voluntary exit: %v", err)
				}
				return nil
			},
		},
	},
}

AccountCommands for Prysm validators.

View Source
var (

	// MsgCouldNotInitializeKeymanager informs about failed keymanager initialization
	ErrCouldNotInitializeKeymanager = "could not initialize keymanager"
)
View Source
var WalletCommands = &cli.Command{
	Name:     "wallet",
	Category: "wallet",
	Usage:    "defines commands for interacting with eth2 validator wallets",
	Subcommands: []*cli.Command{
		{
			Name: "create",
			Usage: "creates a new wallet with a desired type of keymanager: " +
				"either on-disk (imported), derived, or using remote credentials",
			Flags: cmd.WrapFlags([]cli.Flag{
				flags.WalletDirFlag,
				flags.KeymanagerKindFlag,
				flags.GrpcRemoteAddressFlag,
				flags.DisableRemoteSignerTlsFlag,
				flags.RemoteSignerCertPathFlag,
				flags.RemoteSignerKeyPathFlag,
				flags.RemoteSignerCACertPathFlag,
				flags.WalletPasswordFileFlag,
				flags.Mnemonic25thWordFileFlag,
				flags.SkipMnemonic25thWordCheckFlag,
				featureconfig.Mainnet,
				featureconfig.PyrmontTestnet,
				featureconfig.ToledoTestnet,
				cmd.AcceptTosFlag,
			}),
			Before: func(cliCtx *cli.Context) error {
				if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
					return err
				}
				return tos.VerifyTosAcceptedOrPrompt(cliCtx)
			},
			Action: func(cliCtx *cli.Context) error {
				featureconfig.ConfigureValidator(cliCtx)
				if _, err := CreateAndSaveWalletCli(cliCtx); err != nil {
					log.Fatalf("Could not create a wallet: %v", err)
				}
				return nil
			},
		},
		{
			Name:  "edit-config",
			Usage: "edits a wallet configuration options, such as gRPC connection credentials and TLS certificates",
			Flags: cmd.WrapFlags([]cli.Flag{
				flags.WalletDirFlag,
				flags.WalletPasswordFileFlag,
				flags.GrpcRemoteAddressFlag,
				flags.DisableRemoteSignerTlsFlag,
				flags.RemoteSignerCertPathFlag,
				flags.RemoteSignerKeyPathFlag,
				flags.RemoteSignerCACertPathFlag,
				featureconfig.Mainnet,
				featureconfig.PyrmontTestnet,
				featureconfig.ToledoTestnet,
				cmd.AcceptTosFlag,
			}),
			Before: func(cliCtx *cli.Context) error {
				if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
					return err
				}
				return tos.VerifyTosAcceptedOrPrompt(cliCtx)
			},
			Action: func(cliCtx *cli.Context) error {
				featureconfig.ConfigureValidator(cliCtx)
				if err := EditWalletConfigurationCli(cliCtx); err != nil {
					log.Fatalf("Could not edit wallet configuration: %v", err)
				}
				return nil
			},
		},
		{
			Name:  "recover",
			Usage: "uses a derived wallet seed recovery phase to recreate an existing HD wallet",
			Flags: cmd.WrapFlags([]cli.Flag{
				flags.WalletDirFlag,
				flags.MnemonicFileFlag,
				flags.WalletPasswordFileFlag,
				flags.NumAccountsFlag,
				flags.Mnemonic25thWordFileFlag,
				flags.SkipMnemonic25thWordCheckFlag,
				featureconfig.Mainnet,
				featureconfig.PyrmontTestnet,
				featureconfig.ToledoTestnet,
				cmd.AcceptTosFlag,
			}),
			Before: func(cliCtx *cli.Context) error {
				if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
					return err
				}
				return tos.VerifyTosAcceptedOrPrompt(cliCtx)
			},
			Action: func(cliCtx *cli.Context) error {
				featureconfig.ConfigureValidator(cliCtx)
				if err := RecoverWalletCli(cliCtx); err != nil {
					log.Fatalf("Could not recover wallet: %v", err)
				}
				return nil
			},
		},
	},
}

WalletCommands for accounts for Prysm validators.

Functions

func BackupAccountsCli added in v1.0.0

func BackupAccountsCli(cliCtx *cli.Context) error

BackupAccountsCli allows users to select validator accounts from their wallet and export them as a backup.zip file containing the keys as EIP-2335 compliant keystore.json files, which are compatible with importing in other eth2 clients.

func CreateAndSaveWalletCli added in v1.0.0

func CreateAndSaveWalletCli(cliCtx *cli.Context) (*wallet.Wallet, error)

CreateAndSaveWalletCli from user input with a desired keymanager. If a wallet already exists in the path, it suggests the user alternatives such as how to edit their existing wallet configuration.

func CreateWalletWithKeymanager added in v1.0.0

func CreateWalletWithKeymanager(ctx context.Context, cfg *CreateWalletConfig) (*wallet.Wallet, error)

CreateWalletWithKeymanager specified by configuration options.

func DeleteAccount added in v1.0.0

func DeleteAccount(ctx context.Context, cfg *Config) error

DeleteAccount deletes the accounts that the user requests to be deleted from the wallet.

func DeleteAccountCli added in v1.0.0

func DeleteAccountCli(cliCtx *cli.Context) error

DeleteAccountCli deletes the accounts that the user requests to be deleted from the wallet. This function uses the CLI to extract necessary values.

func DisableAccountsCli added in v1.0.0

func DisableAccountsCli(cliCtx *cli.Context) error

DisableAccountsCli disables via CLI the accounts that the user requests to be disabled from the wallet

func EditWalletConfigurationCli added in v1.0.0

func EditWalletConfigurationCli(cliCtx *cli.Context) error

EditWalletConfigurationCli for a user's on-disk wallet, being able to change things such as remote gRPC credentials for remote signing, derivation paths for HD wallets, and more.

func EnableAccountsCli added in v1.0.0

func EnableAccountsCli(cliCtx *cli.Context) error

EnableAccountsCli enables via CLI the accounts that the user requests to be enabled from the wallet

func ExitAccountsCli added in v1.0.0

func ExitAccountsCli(cliCtx *cli.Context, r io.Reader) error

ExitAccountsCli performs a voluntary exit on one or more accounts.

func ImportAccounts added in v1.0.0

func ImportAccounts(ctx context.Context, cfg *ImportAccountsConfig) error

ImportAccounts can import external, EIP-2335 compliant keystore.json files as new accounts into the Prysm validator wallet.

func ImportAccountsCli added in v1.0.0

func ImportAccountsCli(cliCtx *cli.Context) error

ImportAccountsCli can import external, EIP-2335 compliant keystore.json files as new accounts into the Prysm validator wallet. This uses the CLI to extract values necessary to run the function.

func ListAccountsCli added in v1.0.0

func ListAccountsCli(cliCtx *cli.Context) error

ListAccountsCli displays all available validator accounts in a Prysm wallet.

func RecoverWallet added in v1.0.0

func RecoverWallet(ctx context.Context, cfg *RecoverWalletConfig) (*wallet.Wallet, error)

RecoverWallet uses a menmonic seed phrase to recover a wallet into the path provided.

func RecoverWalletCli added in v1.0.0

func RecoverWalletCli(cliCtx *cli.Context) error

RecoverWalletCli uses a menmonic seed phrase to recover a wallet into the path provided. This uses the CLI to extract necessary values to run the function.

Types

type Config added in v1.2.0

type Config struct {
	Wallet            *wallet.Wallet
	Keymanager        keymanager.IKeymanager
	DisablePublicKeys [][]byte
	EnablePublicKeys  [][]byte
	DeletePublicKeys  [][]byte
}

Config specifies parameters to run to delete, enable, disable accounts.

type CreateWalletConfig added in v1.0.0

type CreateWalletConfig struct {
	WalletCfg            *wallet.Config
	RemoteKeymanagerOpts *remote.KeymanagerOpts
	SkipMnemonicConfirm  bool
	Mnemonic25thWord     string
	NumAccounts          int
}

CreateWalletConfig defines the parameters needed to call the create wallet functions.

type ImportAccountsConfig added in v1.0.0

type ImportAccountsConfig struct {
	Keystores       []*keymanager.Keystore
	Keymanager      *imported.Keymanager
	AccountPassword string
}

ImportAccountsConfig defines values to run the import accounts function.

type RecoverWalletConfig added in v1.0.0

type RecoverWalletConfig struct {
	WalletDir        string
	WalletPassword   string
	Mnemonic         string
	NumAccounts      int
	Mnemonic25thWord string
}

RecoverWalletConfig to run the recover wallet function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL