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 derived, HD wallets and remote-signing capable configurations.
Index ¶
- Constants
- Variables
- func ListAccounts(cliCtx *cli.Context) error
- func NewAccount(cliCtx *cli.Context) error
- type Wallet
- func (w *Wallet) AccountNames() ([]string, error)
- func (w *Wallet) AccountsDir() string
- func (w *Wallet) CreateKeymanager(ctx context.Context) (v2keymanager.IKeymanager, error)
- func (w *Wallet) ExistingKeyManager(ctx context.Context) (v2keymanager.IKeymanager, error)
- func (w *Wallet) KeymanagerKind() v2keymanager.Kind
- func (w *Wallet) ReadFileForAccount(accountName string, fileName string) ([]byte, error)
- func (w *Wallet) ReadKeymanagerConfigFromDisk(ctx context.Context) (io.ReadCloser, error)
- func (w *Wallet) ReadPasswordForAccount(accountName string) (string, error)
- func (w *Wallet) WriteAccountToDisk(ctx context.Context, password string) (string, error)
- func (w *Wallet) WriteFileForAccount(ctx context.Context, accountName string, fileName string, data []byte) error
- func (w *Wallet) WriteKeymanagerConfigToDisk(ctx context.Context, encoded []byte) error
- type WalletConfig
Constants ¶
const ( // WalletDefaultDirName for accounts-v2. WalletDefaultDirName = ".prysm-wallet-v2" // PasswordsDefaultDirName where account passwords are stored. PasswordsDefaultDirName = ".prysm-wallet-v2-passwords" )
Variables ¶
var Commands = &cli.Command{ Name: "accounts-v2", Category: "accounts-v2", Usage: "defines commands for interacting with eth2 validator accounts (work in progress)", Subcommands: []*cli.Command{ { Name: "new", Description: `creates a new validator account for eth2. If no account exists at the wallet path, creates a new wallet for a user based on specified input, capable of creating a direct, derived, or remote wallet. this command outputs a deposit data string which is required to become a validator in eth2.`, Flags: []cli.Flag{ flags.WalletDirFlag, flags.WalletPasswordsDirFlag, }, Action: NewAccount, }, { Name: "list", Description: "Lists all validator accounts in a user's wallet directory", Flags: []cli.Flag{ flags.WalletDirFlag, flags.WalletPasswordsDirFlag, flags.ShowDepositDataFlag, }, Action: ListAccounts, }, }, }
Commands for accounts-v2 for Prysm validators.
var ( // ErrNoWalletFound signifies there is no data at the given wallet path. ErrNoWalletFound = errors.New("no wallet found at path") )
Functions ¶
func ListAccounts ¶
func ListAccounts(cliCtx *cli.Context) error
ListAccounts displays all available validator accounts in a Prysm wallet.
func NewAccount ¶
func NewAccount(cliCtx *cli.Context) error
NewAccount creates a new validator account from user input. If a user does not have an initialized wallet at the specified wallet path, this method will create a new wallet and ask user for input for their new wallet's available options.
Types ¶
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
Wallet is a primitive in Prysm's v2 account management which has the capability of creating new accounts, reading existing accounts, and providing secure access to eth2 secrets depending on an associated keymanager (either direct, derived, or remote signing enabled).
func CreateWallet ¶
func CreateWallet(ctx context.Context, cfg *WalletConfig) (*Wallet, error)
CreateWallet given a set of configuration options, will leverage a keymanager to create and write a new wallet to disk for a Prysm validator.
func OpenWallet ¶
func OpenWallet(ctx context.Context, cfg *WalletConfig) (*Wallet, error)
OpenWallet instantiates a wallet from a specified path. It checks the type of keymanager associated with the wallet by reading files in the wallet path, if applicable. If a wallet does not exist, returns an appropriate error.
func (*Wallet) AccountNames ¶
AccountNames reads all account names at the wallet's path.
func (*Wallet) CreateKeymanager ¶
func (w *Wallet) CreateKeymanager(ctx context.Context) (v2keymanager.IKeymanager, error)
CreateKeymanager determines if a config file exists in the wallet, it reads the config file and initializes the keymanager that way. Otherwise, writes a new configuration file to the wallet and returns the initialized keymanager for use.
func (*Wallet) ExistingKeyManager ¶
func (w *Wallet) ExistingKeyManager( ctx context.Context, ) (v2keymanager.IKeymanager, error)
ExistingKeyManager reads a keymanager config from disk at the wallet path, unmarshals it based on the wallet's keymanager kind, and returns its value.
func (*Wallet) KeymanagerKind ¶
func (w *Wallet) KeymanagerKind() v2keymanager.Kind
KeymanagerKind used by the wallet.
func (*Wallet) ReadFileForAccount ¶
ReadFileForAccount from the wallet's accounts directory.
func (*Wallet) ReadKeymanagerConfigFromDisk ¶
ReadKeymanagerConfigFromDisk opens a keymanager config file for reading if it exists at the wallet path.
func (*Wallet) ReadPasswordForAccount ¶
ReadPasswordForAccount when given an account name from the wallet's passwords' path.
func (*Wallet) WriteAccountToDisk ¶
WriteAccountToDisk creates an account directory under a unique namespace within the wallet's path. It additionally writes the account's password to the wallet's passwords directory. Returns the unique account name.
func (*Wallet) WriteFileForAccount ¶
func (w *Wallet) WriteFileForAccount(ctx context.Context, accountName string, fileName string, data []byte) error
WriteFileForAccount stores a unique file and its data under an account namespace in the wallet's directory on-disk. Creates the file if it does not exist and writes over it otherwise.
type WalletConfig ¶
type WalletConfig struct { PasswordsDir string WalletDir string KeymanagerKind v2keymanager.Kind }
WalletConfig for a wallet struct, containing important information such as the passwords directory, the wallet's directory, and keymanager.