Documentation ¶
Index ¶
- Constants
- Variables
- func Exists(walletDir string) (bool, error)
- func InputPassword(cliCtx *cli.Context, passwordFileFlag *cli.StringFlag, promptText string, ...) (string, 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, cfg iface.InitKeymanagerConfig) (keymanager.IKeymanager, error)
- func (w *Wallet) KeymanagerKind() keymanager.Kind
- func (w *Wallet) Password() string
- 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) 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, remote, or web3signer. KeymanagerConfigFileName = "keymanageropts.json" // NewWalletPasswordPromptText for wallet creation. NewWalletPasswordPromptText = "New wallet password" // PasswordPromptText for wallet unlocking. PasswordPromptText = "Wallet password" // ConfirmPasswordPromptText for confirming a wallet password. ConfirmPasswordPromptText = "Confirm password" // DefaultWalletPasswordFile used to store a wallet password with appropriate permissions // if a user signs up via the Prysm web UI via RPC. DefaultWalletPasswordFile = "walletpassword.txt" // 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. You can create a new wallet with `validator wallet create`. " + "If you already did, perhaps you created a wallet in a custom directory, which you can specify using " + "`--wallet-dir=/path/to/my/wallet`", ) // KeymanagerKindSelections as friendly text. KeymanagerKindSelections = map[keymanager.Kind]string{ keymanager.Local: "Imported Wallet (Recommended)", keymanager.Derived: "HD Wallet", keymanager.Remote: "Remote Signing Wallet (Advanced)", keymanager.Web3Signer: "Consensys Web3Signer (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 ¶
func InputPassword ¶
func InputPassword( cliCtx *cli.Context, passwordFileFlag *cli.StringFlag, promptText string, confirmPassword bool, passwordValidator func(input string) error, ) (string, error)
InputPassword prompts for a password and optionally for password confirmation. The password is validated according to custom rules.
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 Ethereum proof of stake secrets depending on an associated keymanager (either imported, derived, or remote signing enabled).
func NewWalletForWeb3Signer ¶
func NewWalletForWeb3Signer() *Wallet
NewWalletForWeb3Signer returns a new wallet for web3 signer which is temporary and not stored locally.
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, cfg iface.InitKeymanagerConfig) (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) 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) WriteFileAtPath ¶
WriteFileAtPath within the wallet directory given the desired path, filename, and raw data.