Documentation ¶
Index ¶
- Constants
- Variables
- func Exists(walletDir string) error
- type Config
- type Wallet
- func (w *Wallet) AccountsDir() string
- func (w *Wallet) FileNameAtPath(ctx context.Context, filePath string, fileName string) (string, error)
- func (w *Wallet) InitializeKeymanager(ctx context.Context, skipMnemonicConfirm bool) (v2keymanager.IKeymanager, error)
- func (w *Wallet) KeymanagerKind() v2keymanager.Kind
- func (w *Wallet) LockWalletConfigFile(ctx context.Context) error
- func (w *Wallet) Password() string
- func (w *Wallet) ReadEncryptedSeedFromDisk(ctx context.Context) (io.ReadCloser, error)
- func (w *Wallet) ReadFileAtPath(ctx context.Context, filePath string, fileName string) ([]byte, error)
- func (w *Wallet) ReadKeymanagerConfigFromDisk(ctx context.Context) (io.ReadCloser, error)
- func (w *Wallet) SaveHashedPassword(ctx context.Context) error
- func (w *Wallet) SaveWallet() error
- func (w *Wallet) SetPassword(newPass string)
- func (w *Wallet) UnlockWalletConfigFile() error
- func (w *Wallet) WriteEncryptedSeedToDisk(ctx context.Context, encoded []byte) error
- func (w *Wallet) WriteFileAtPath(ctx context.Context, filePath string, fileName string, data []byte) error
- func (w *Wallet) WriteKeymanagerConfigToDisk(ctx context.Context, encoded []byte) error
Constants ¶
const ( // KeymanagerConfigFileName for the keymanager used by the wallet: direct, derived, or remote. KeymanagerConfigFileName = "keymanageropts.json" // HashedPasswordFileName for the wallet. HashedPasswordFileName = "hash" // DirectoryPermissions for directories created under the wallet path. DirectoryPermissions = os.ModePerm // NewWalletPasswordPromptText for wallet creation. NewWalletPasswordPromptText = "New wallet password" // WalletPasswordPromptText for wallet unlocking. WalletPasswordPromptText = "Wallet password" // ConfirmPasswordPromptText for confirming a wallet password. ConfirmPasswordPromptText = "Confirm password" )
Variables ¶
var ( // ErrNoWalletFound signifies there was no wallet directory found on-disk. ErrNoWalletFound = errors.New( "no wallet found at path, please create a new wallet using `./prysm.sh validator wallet-v2 create`", ) // ErrWalletExists is an error returned when a wallet already exists in the path provided. ErrWalletExists = errors.New("you already have a wallet at the specified path. You can " + "edit your wallet configuration by running ./prysm.sh validator wallet-v2 edit-config", ) // KeymanagerKindSelections as friendly text. KeymanagerKindSelections = map[v2keymanager.Kind]string{ v2keymanager.Derived: "HD Wallet (Recommended)", v2keymanager.Direct: "Non-HD Wallet (Most Basic)", v2keymanager.Remote: "Remote Signing Wallet (Advanced)", } // ValidateExistingPass checks that an input cannot be empty. ValidateExistingPass = func(input string) error { if input == "" { return errors.New("password input cannot be empty") } return nil } )
Functions ¶
Types ¶
type Config ¶
type Config struct { WalletDir string KeymanagerKind v2keymanager.Kind WalletPassword string }
Config to open a wallet programmatically.
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 OpenWallet ¶
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 OpenWalletOrElseCli ¶
func OpenWalletOrElseCli(cliCtx *cli.Context, otherwise func(cliCtx *cli.Context) (*Wallet, error)) (*Wallet, error)
OpenWalletOrElseCli tries to open the wallet and if it fails or no wallet is found, invokes a callback function.
func (*Wallet) FileNameAtPath ¶
func (w *Wallet) FileNameAtPath(ctx context.Context, filePath string, fileName string) (string, error)
FileNameAtPath return the full file name for the requested file. It allows for finding the file with a regex pattern.
func (*Wallet) InitializeKeymanager ¶
func (w *Wallet) InitializeKeymanager( ctx context.Context, skipMnemonicConfirm bool, ) (v2keymanager.IKeymanager, error)
InitializeKeymanager 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) LockWalletConfigFile ¶
LockWalletConfigFile lock read and write to wallet file in order to prevent two validators from using the same keys.
func (*Wallet) ReadEncryptedSeedFromDisk ¶
ReadEncryptedSeedFromDisk reads the encrypted wallet seed configuration from within the wallet path.
func (*Wallet) ReadFileAtPath ¶
func (w *Wallet) ReadFileAtPath(ctx context.Context, filePath string, fileName string) ([]byte, error)
ReadFileAtPath within the wallet directory given the desired path and filename.
func (*Wallet) ReadKeymanagerConfigFromDisk ¶
ReadKeymanagerConfigFromDisk opens a keymanager config file for reading if it exists at the wallet path.
func (*Wallet) SaveHashedPassword ¶
SaveHashedPassword to disk for the wallet.
func (*Wallet) SaveWallet ¶
SaveWallet persists the wallet's directories to disk.
func (*Wallet) SetPassword ¶
SetPassword sets a new password for the wallet.
func (*Wallet) UnlockWalletConfigFile ¶
UnlockWalletConfigFile unlock wallet file. should be called before client is closing in order to remove the file lock.
func (*Wallet) WriteEncryptedSeedToDisk ¶
WriteEncryptedSeedToDisk writes the encrypted wallet seed configuration within the wallet path.