Documentation
¶
Index ¶
- Constants
- Variables
- func Exists(walletDir string) (bool, error)
- func IsValid(walletDir string) (bool, error)
- type Config
- type Wallet
- func (w *Wallet) AccountsDir() string
- func (w *Wallet) FileNameAtPath(_ context.Context, filePath, fileName string) (string, error)
- func (w *Wallet) InitializeKeymanager(ctx context.Context, skipMnemonicConfirm bool) (keymanager.IKeymanager, error)
- func (w *Wallet) KeymanagerKind() keymanager.Kind
- func (w *Wallet) LockWalletConfigFile(_ context.Context) error
- func (w *Wallet) Password() string
- func (w *Wallet) ReadEncryptedSeedFromDisk(_ context.Context) (io.ReadCloser, error)
- func (w *Wallet) ReadFileAtPath(_ context.Context, filePath, fileName string) ([]byte, error)
- func (w *Wallet) ReadKeymanagerConfigFromDisk(_ context.Context) (io.ReadCloser, error)
- func (w *Wallet) SaveWallet() error
- func (w *Wallet) UnlockWalletConfigFile() error
- func (w *Wallet) WriteEncryptedSeedToDisk(_ context.Context, encoded []byte) error
- func (w *Wallet) WriteFileAtPath(_ context.Context, filePath, fileName string, data []byte) error
- func (w *Wallet) WriteKeymanagerConfigToDisk(_ context.Context, encoded []byte) error
Constants ¶
const ( // KeymanagerConfigFileName for the keymanager used by the wallet: imported, derived, or remote. KeymanagerConfigFileName = "keymanageropts.json" // 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" // CheckExistsErrMsg for when there is an error while checking for a wallet CheckExistsErrMsg = "could not check if wallet exists" // CheckValidityErrMsg for when there is an error while checking wallet validity CheckValidityErrMsg = "could not check if wallet is valid" // InvalidWalletErrMsg for when a directory does not contain a valid wallet InvalidWalletErrMsg = "directory does not contain valid wallet" )
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 create`", ) // KeymanagerKindSelections as friendly text. KeymanagerKindSelections = map[keymanager.Kind]string{ keymanager.Imported: "Imported Wallet (Recommended)", keymanager.Derived: "HD Wallet (Least secure)", keymanager.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 keymanager.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 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 imported, 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 ¶
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, ) (keymanager.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() keymanager.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 ¶
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) SaveWallet ¶
SaveWallet persists the wallet's directories to disk.
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.
func (*Wallet) WriteFileAtPath ¶
WriteFileAtPath within the wallet directory given the desired path, filename, and raw data.