accounts

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: GPL-3.0 Imports: 50 Imported by: 1

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

View Source
const (

	// ArchiveFilename specifies the name of the backup. Exported for tests.
	ArchiveFilename = "backup.zip"
)
View Source
const ExitPassphrase = "Exit my validator"

ExitPassphrase exported for use in test.

Variables

View Source
var (
	ErrIncorrectWordNumber = errors.New("incorrect number of words provided")
	ErrEmptyMnemonic       = errors.New("phrase cannot be empty")
)
View Source
var (

	// ErrCouldNotInitializeKeymanager informs about failed keymanager initialization
	ErrCouldNotInitializeKeymanager = "could not initialize keymanager"
)

Functions

func CreateLocalKeymanagerWallet

func CreateLocalKeymanagerWallet(_ context.Context, wallet *wallet.Wallet) error

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,
	forceExit bool,
) (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

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 ValidateMnemonic

func ValidateMnemonic(mnemonic string) error

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) WalletCreate

func (acm *AccountsCLIManager) WalletCreate(ctx context.Context) (*wallet.Wallet, error)

WalletCreate creates wallet specified by configuration options.

func (*AccountsCLIManager) WalletRecover

func (acm *AccountsCLIManager) WalletRecover(ctx context.Context) (*wallet.Wallet, error)

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

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

func WithBackupsDir(backupsDir string) Option

WithBackupsDir specifies the directory backups are written to.

func WithBackupsPassword

func WithBackupsPassword(backupsPassword string) Option

WithBackupsPassword specifies the password for backups.

func WithBeaconRESTApiProvider

func WithBeaconRESTApiProvider(beaconApiEndpoint string) Option

WithBeaconRESTApiProvider provides a beacon node REST API endpoint to the accounts cli manager.

func WithBeaconRPCProvider

func WithBeaconRPCProvider(provider string) Option

WithBeaconRPCProvider provides a beacon node endpoint to the accounts cli manager.

func WithDeletePublicKeys

func WithDeletePublicKeys(deletePublicKeys bool) Option

WithDeletePublicKeys indicates whether to delete the public keys.

func WithExitJSONOutputPath

func WithExitJSONOutputPath(outputPath string) Option

func WithFilteredPubKeys

func WithFilteredPubKeys(filteredPubKeys []bls.PublicKey) Option

WithFilteredPubKeys adds public key strings parsed from CLI.

func WithFormattedPubKeys

func WithFormattedPubKeys(formattedPubKeys []string) Option

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

func WithGRPCHeaders(headers []string) Option

WithGRPCHeaders adds grpc headers used when connecting to beacon nodes in the accounts cli manager.

func WithImportPrivateKeys

func WithImportPrivateKeys(importPrivateKeys bool) Option

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 WithKeymanagerType

func WithKeymanagerType(k keymanager.Kind) Option

WithKeymanagerType provides a keymanager to the accounts cli manager.

func WithKeysDir

func WithKeysDir(keysDir string) Option

WithKeysDir specifies the directory keys are read from.

func WithListValidatorIndices

func WithListValidatorIndices() Option

WithListValidatorIndices enables displaying validator indices in the accounts cli manager.

func WithMnemonic

func WithMnemonic(mnemonic string) Option

WithMnemonic specifies the password for backups.

func WithMnemonic25thWord

func WithMnemonic25thWord(mnemonic25thWord string) Option

WithMnemonic25thWord specifies the password for backups.

func WithMnemonicLanguage

func WithMnemonicLanguage(mnemonicLanguage string) Option

WithMnemonicLanguage specifies the language used for the mnemonic passphrase.

func WithNumAccounts

func WithNumAccounts(numAccounts int) Option

WithNumAccounts specifies the number of accounts.

func WithPasswordFilePath

func WithPasswordFilePath(passwordFilePath string) Option

WithPasswordFilePath specifies where the password is stored.

func WithPrivateKeyFile

func WithPrivateKeyFile(privateKeyFile string) Option

WithPrivateKeyFile specifies the private key path.

func WithRawPubKeys

func WithRawPubKeys(rawPubKeys [][]byte) Option

WithRawPubKeys adds raw public key bytes parsed from CLI.

func WithReadPasswordFile

func WithReadPasswordFile(readPasswordFile bool) Option

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 WithSkipMnemonicConfirm

func WithSkipMnemonicConfirm(s bool) Option

WithSkipMnemonicConfirm indicates whether to skip the mnemonic confirmation.

func WithWallet

func WithWallet(wallet *wallet.Wallet) Option

WithWallet provides a wallet to the accounts cli manager.

func WithWalletDir

func WithWalletDir(walletDir string) Option

WithWalletDir specifies the password for backups.

func WithWalletKeyCount

func WithWalletKeyCount(walletKeyCount int) Option

WithWalletKeyCount tracks the number of keys in a wallet.

func WithWalletPassword

func WithWalletPassword(walletPassword string) Option

WithWalletPassword specifies the password for backups.

type PerformExitCfg

type PerformExitCfg struct {
	ValidatorClient  iface.ValidatorClient
	NodeClient       iface.NodeClient
	Keymanager       keymanager.IKeymanager
	RawPubKeys       [][]byte
	FormattedPubKeys []string
	OutputDirectory  string
}

PerformExitCfg for account voluntary exits.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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