Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateNewMnemonic() (string, error)
- type IWalletManager
- type Wallet
- func (w *Wallet) CreateNewLocalWallet(derivationPath string, walletIndex uint, password string, savePassword bool) (string, error)
- func (w *Wallet) DeletePassword() error
- func (w *Wallet) GenerateValidatorKey(path string) ([]byte, error)
- func (w *Wallet) GetAddress() (common.Address, bool)
- func (w *Wallet) GetEthKeystore(password string) ([]byte, error)
- func (w *Wallet) GetNodePrivateKeyBytes() ([]byte, error)
- func (w *Wallet) GetPassword() (string, bool, error)
- func (w *Wallet) GetStatus() (wallet.WalletStatus, error)
- func (w *Wallet) GetTransactor() (*bind.TransactOpts, error)
- func (w *Wallet) MasqueradeAsAddress(newAddress common.Address) error
- func (w *Wallet) Recover(derivationPath string, walletIndex uint, mnemonic string, password string, ...) error
- func (w *Wallet) Reload(logger *slog.Logger) error
- func (w *Wallet) RestoreAddressToWallet() error
- func (w *Wallet) SerializeData() (string, error)
- func (w *Wallet) SetPassword(password string, save bool) error
- func (w *Wallet) SignMessage(message []byte) ([]byte, error)
- func (w *Wallet) SignTransaction(serializedTx []byte) ([]byte, error)
Constants ¶
const ( EntropyBits = 256 FileMode = 0600 )
Config
Variables ¶
var ( // Attempted to do an operation requiring a wallet, but it's not loaded ErrWalletNotLoaded = errors.New("wallet is not loaded") // Attempted to load a wallet keystore, but it's already loaded ErrWalletAlreadyLoaded = errors.New("wallet is already loaded, nothing to do") // Attempted to create a new wallet, but one is already present ErrKeystoreAlreadyPresent = errors.New("wallet keystore is already present - please delete it before creating a new wallet") // Attempted to load a keystore, but it's not on disk ErrKeystoreNotPresent = errors.New("keystore not present, wallet must be initialized or recovered first") // Attempted to do an operation that is not supported by the loaded wallet type ErrNotSupported = errors.New("loaded wallet type does not support this operation") // Provided password is not correct to unlock the wallet keystore ErrInvalidPassword = errors.New("provided password is not correct for the loaded wallet") )
Errors
Functions ¶
func GenerateNewMnemonic ¶
Generate a new random mnemonic and seed
Types ¶
type IWalletManager ¶
type IWalletManager interface { // The type of wallet GetType() wallet.WalletType // The wallet address GetAddress() (common.Address, error) // A transactor that can sign transactions GetTransactor() (*bind.TransactOpts, error) // Sign a message with the wallet's private key SignMessage(message []byte) ([]byte, error) // Sign a transaction with the wallet's private key SignTransaction(serializedTx []byte) ([]byte, error) // Serialize the wallet data as JSON SerializeData() (string, error) }
Interface for wallet managers
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
Wallet
func NewWallet ¶
func NewWallet(logger *slog.Logger, walletDataPath string, walletAddressPath string, passwordFilePath string, chainID uint) (*Wallet, error)
Create new wallet
func TestRecovery ¶
func TestRecovery(derivationPath string, walletIndex uint, mnemonic string, chainID uint) (*Wallet, error)
Recover a wallet keystore from a mnemonic - only used for testing mnemonics
func (*Wallet) CreateNewLocalWallet ¶
func (w *Wallet) CreateNewLocalWallet(derivationPath string, walletIndex uint, password string, savePassword bool) (string, error)
Initialize the wallet from a random seed
func (*Wallet) DeletePassword ¶
Delete the wallet password from disk, but retain it in memory if a local keystore is already loaded
func (*Wallet) GenerateValidatorKey ¶
Generate a BLS validator key from the provided path, using the node wallet's seed as a basis
func (*Wallet) GetAddress ¶
Get the node address, if one is loaded
func (*Wallet) GetEthKeystore ¶
Get the node account private key bytes
func (*Wallet) GetNodePrivateKeyBytes ¶
Get the node account private key bytes
func (*Wallet) GetPassword ¶
Retrieves the wallet's password
func (*Wallet) GetStatus ¶
func (w *Wallet) GetStatus() (wallet.WalletStatus, error)
Gets the status of the wallet and its artifacts
func (*Wallet) GetTransactor ¶
func (w *Wallet) GetTransactor() (*bind.TransactOpts, error)
Get the transactor that can sign transactions
func (*Wallet) MasqueradeAsAddress ¶
Masquerade as another node address, running all node functions as that address (in read only mode)
func (*Wallet) Recover ¶
func (w *Wallet) Recover(derivationPath string, walletIndex uint, mnemonic string, password string, savePassword bool, testMode bool) error
Recover a local wallet from a mnemonic
func (*Wallet) RestoreAddressToWallet ¶
End masquerading as another node address, and use the wallet's address (returning to read/write mode)
func (*Wallet) SerializeData ¶
Serialize the wallet data as JSON
func (*Wallet) SetPassword ¶
Attempts to load the wallet keystore with the provided password if not set
func (*Wallet) SignMessage ¶
Sign a message with the wallet's private key