Documentation ¶
Overview ¶
Package accounts 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 Ethereum.
Index ¶
- Constants
- Variables
- func CreateAndSaveWalletCli(cliCtx *cli.Context) (*wallet.Wallet, error)
- func CreateLocalKeymanagerWallet(_ context.Context, wallet *wallet.Wallet) error
- func CreateWalletWithKeymanager(ctx context.Context, cfg *CreateWalletConfig) (*wallet.Wallet, error)
- func DeleteAccount(ctx context.Context, cfg *DeleteConfig) error
- func FilterExitAccountsFromUserInput(cliCtx *cli.Context, r io.Reader, ...) (rawPubKeys [][]byte, formattedPubKeys []string, err error)
- func FilterPublicKeysFromUserInput(cliCtx *cli.Context, publicKeysFlag *cli.StringFlag, ...) ([]bls.PublicKey, error)
- func ImportAccounts(ctx context.Context, cfg *ImportAccountsConfig) ([]*ethpbservice.ImportedKeystoreStatus, error)
- func PerformVoluntaryExit(ctx context.Context, cfg PerformExitCfg) (rawExitedKeys [][]byte, formattedExitedKeys []string, err error)
- func RecoverWallet(ctx context.Context, cfg *RecoverWalletConfig) (*wallet.Wallet, error)
- func RecoverWalletCli(cliCtx *cli.Context) error
- func ValidateMnemonic(mnemonic string) error
- type AccountsCLIManager
- func (acm *AccountsCLIManager) Backup(ctx context.Context) error
- func (acm *AccountsCLIManager) Delete(ctx context.Context) error
- func (acm *AccountsCLIManager) Exit(ctx context.Context) error
- func (acm *AccountsCLIManager) Import(ctx context.Context) error
- func (acm *AccountsCLIManager) List(ctx context.Context) error
- func (acm *AccountsCLIManager) WalletEdit(ctx context.Context) error
- type CreateWalletConfig
- type DeleteConfig
- type ImportAccountsConfig
- type Option
- func WithBackupsDir(backupsDir string) Option
- func WithBackupsPassword(backupsPassword string) Option
- func WithBeaconRPCProvider(provider string) Option
- func WithDeletePublicKeys(deletePublicKeys bool) Option
- func WithFilteredPubKeys(filteredPubKeys []bls.PublicKey) Option
- func WithFormattedPubKeys(formattedPubKeys []string) Option
- func WithGRPCDialOpts(opts []grpc.DialOption) Option
- func WithGRPCHeaders(headers []string) Option
- func WithImportPrivateKeys(importPrivateKeys bool) Option
- func WithKeymanager(km keymanager.IKeymanager) Option
- func WithKeymanagerOpts(kmo *remote.KeymanagerOpts) Option
- func WithKeysDir(keysDir string) Option
- func WithListValidatorIndices() Option
- func WithPasswordFilePath(passwordFilePath string) Option
- func WithPrivateKeyFile(privateKeyFile string) Option
- func WithRawPubKeys(rawPubKeys [][]byte) Option
- func WithReadPasswordFile(readPasswordFile bool) Option
- func WithShowDepositData() Option
- func WithShowPrivateKeys() Option
- func WithWallet(wallet *wallet.Wallet) Option
- func WithWalletKeyCount(walletKeyCount int) Option
- type PerformExitCfg
- type RecoverWalletConfig
Constants ¶
const (
// ArchiveFilename specifies the name of the backup. Exported for tests.
ArchiveFilename = "backup.zip"
)
const ExitPassphrase = "Exit my validator"
ExitPassphrase exported for use in test.
Variables ¶
var ( ErrIncorrectWordNumber = errors.New("incorrect number of words provided") ErrEmptyMnemonic = errors.New("phrase cannot be empty") )
var (
// ErrCouldNotInitializeKeymanager informs about failed keymanager initialization
ErrCouldNotInitializeKeymanager = "could not initialize keymanager"
)
Functions ¶
func CreateAndSaveWalletCli ¶
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 ¶
func CreateWalletWithKeymanager(ctx context.Context, cfg *CreateWalletConfig) (*wallet.Wallet, error)
CreateWalletWithKeymanager specified by configuration options.
func DeleteAccount ¶
func DeleteAccount(ctx context.Context, cfg *DeleteConfig) error
DeleteAccount performs the deletion on the Keymanager.
func FilterExitAccountsFromUserInput ¶
func FilterExitAccountsFromUserInput( cliCtx *cli.Context, r io.Reader, validatingPublicKeys [][fieldparams.BLSPubkeyLength]byte, ) (rawPubKeys [][]byte, formattedPubKeys []string, err error)
FilterExitAccountsFromUserInput selects which accounts to exit from the CLI.
func FilterPublicKeysFromUserInput ¶
func FilterPublicKeysFromUserInput( cliCtx *cli.Context, publicKeysFlag *cli.StringFlag, validatingPublicKeys [][fieldparams.BLSPubkeyLength]byte, selectionPrompt string, ) ([]bls.PublicKey, error)
FilterPublicKeysFromUserInput collects the set of public keys from the command line or an interactive session.
func ImportAccounts ¶
func ImportAccounts(ctx context.Context, cfg *ImportAccountsConfig) ([]*ethpbservice.ImportedKeystoreStatus, error)
ImportAccounts can import external, EIP-2335 compliant keystore.json files as new accounts into the Prysm validator wallet.
func PerformVoluntaryExit ¶
func PerformVoluntaryExit( ctx context.Context, cfg PerformExitCfg, ) (rawExitedKeys [][]byte, formattedExitedKeys []string, err error)
PerformVoluntaryExit uses gRPC clients to submit a voluntary exit message to a beacon node.
func RecoverWallet ¶
RecoverWallet uses a menmonic seed phrase to recover a wallet into the path provided.
func RecoverWalletCli ¶
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.
func ValidateMnemonic ¶
ValidateMnemonic ensures that it is not empty and that the count of the words are as specified(currently 24).
Types ¶
type AccountsCLIManager ¶
type AccountsCLIManager struct {
// contains filtered or unexported fields
}
AccountsCLIManager defines a struct capable of performing various validator wallet account operations via the command line.
func NewCLIManager ¶
func NewCLIManager(opts ...Option) (*AccountsCLIManager, error)
NewCLIManager allows for managing validator accounts via CLI commands.
func (*AccountsCLIManager) Backup ¶
func (acm *AccountsCLIManager) Backup(ctx context.Context) error
Backup 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 Ethereum consensus clients.
func (*AccountsCLIManager) Delete ¶
func (acm *AccountsCLIManager) Delete(ctx context.Context) error
Delete the accounts that the user requests to be deleted from the wallet.
func (*AccountsCLIManager) Exit ¶
func (acm *AccountsCLIManager) Exit(ctx context.Context) error
Exit performs a voluntary exit on one or more accounts.
func (*AccountsCLIManager) Import ¶
func (acm *AccountsCLIManager) Import(ctx context.Context) error
Import 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 (*AccountsCLIManager) List ¶
func (acm *AccountsCLIManager) List(ctx context.Context) error
List pretty-prints accounts in the wallet.
func (*AccountsCLIManager) WalletEdit ¶
func (acm *AccountsCLIManager) WalletEdit(ctx context.Context) error
WalletEdit changes a user's on-disk wallet configuration: remote gRPC credentials for remote signing, derivation paths for HD wallets, etc.
type CreateWalletConfig ¶
type CreateWalletConfig struct { SkipMnemonicConfirm bool NumAccounts int RemoteKeymanagerOpts *remote.KeymanagerOpts Web3SignerSetupConfig *remoteweb3signer.SetupConfig WalletCfg *wallet.Config Mnemonic25thWord string }
CreateWalletConfig defines the parameters needed to call the create wallet functions.
func ExtractWalletCreationConfigFromCli ¶
func ExtractWalletCreationConfigFromCli(cliCtx *cli.Context, keymanagerKind keymanager.Kind) (*CreateWalletConfig, error)
ExtractWalletCreationConfigFromCli prompts the user for wallet creation input.
type DeleteConfig ¶
type DeleteConfig struct { Keymanager keymanager.IKeymanager DeletePublicKeys [][]byte }
DeleteConfig specifies parameters for the accounts delete command.
type ImportAccountsConfig ¶
type ImportAccountsConfig struct { Keystores []*keymanager.Keystore Importer keymanager.Importer AccountPassword string }
ImportAccountsConfig defines values to run the import accounts function.
type Option ¶
type Option func(acc *AccountsCLIManager) error
Option type for configuring the accounts cli manager.
func WithBackupsDir ¶
WithBackupsDir specifies the directory backups are written to.
func WithBackupsPassword ¶
WithBackupsPassword specifies the password for backups.
func WithBeaconRPCProvider ¶
WithBeaconRPCProvider provides a beacon node endpoint to the accounts cli manager.
func WithDeletePublicKeys ¶
WithDeletePublicKeys indicates whether to delete the public keys.
func WithFilteredPubKeys ¶
WithFilteredPubKeys adds public key strings parsed from CLI.
func WithFormattedPubKeys ¶
WithFormattedPubKeys adds formatted public key strings parsed from CLI.
func WithGRPCDialOpts ¶
func WithGRPCDialOpts(opts []grpc.DialOption) Option
WithGRPCDialOpts adds grpc opts needed to connect to beacon nodes in the accounts cli manager.
func WithGRPCHeaders ¶
WithGRPCHeaders adds grpc headers used when connecting to beacon nodes in the accounts cli manager.
func WithImportPrivateKeys ¶
WithImportPrivateKeys indicates whether to import private keys as accounts.
func WithKeymanager ¶
func WithKeymanager(km keymanager.IKeymanager) Option
WithKeymanager provides a keymanager to the accounts cli manager.
func WithKeymanagerOpts ¶
func WithKeymanagerOpts(kmo *remote.KeymanagerOpts) Option
WithKeymanagerOpts provides a keymanager configuration to the accounts cli manager.
func WithKeysDir ¶
WithKeysDir specifies the directory keys are read from.
func WithListValidatorIndices ¶
func WithListValidatorIndices() Option
WithListValidatorIndices enables displaying validator indices in the accounts cli manager.
func WithPasswordFilePath ¶
WithPasswordFilePath specifies where the password is stored.
func WithPrivateKeyFile ¶
WithPrivateKeyFile specifies the private key path.
func WithRawPubKeys ¶
WithRawPubKeys adds raw public key bytes parsed from CLI.
func WithReadPasswordFile ¶
WithReadPasswordFile indicates whether to read the password from a file.
func WithShowDepositData ¶
func WithShowDepositData() Option
WithShowDepositData enables displaying deposit data in the accounts cli manager.
func WithShowPrivateKeys ¶
func WithShowPrivateKeys() Option
WithShowPrivateKeys enables displaying private keys in the accounts cli manager.
func WithWallet ¶
WithWallet provides a wallet to the accounts cli manager.
func WithWalletKeyCount ¶
WithWalletKeyCount tracks the number of keys in a wallet.
type PerformExitCfg ¶
type PerformExitCfg struct { ValidatorClient ethpb.BeaconNodeValidatorClient NodeClient ethpb.NodeClient Keymanager keymanager.IKeymanager RawPubKeys [][]byte FormattedPubKeys []string }
PerformExitCfg for account voluntary exits.