Documentation
¶
Index ¶
- Constants
- func GenerateNewMnemonic() (string, error)
- type AddressManager
- type IWalletManager
- type LocalWalletManager
- func (m *LocalWalletManager) GenerateValidatorKey(path string) ([]byte, error)
- func (m *LocalWalletManager) GetAddress() (common.Address, error)
- func (m *LocalWalletManager) GetEthKeystore(password string) ([]byte, error)
- func (m *LocalWalletManager) GetPrivateKey() *ecdsa.PrivateKey
- func (m *LocalWalletManager) GetTransactor() (*bind.TransactOpts, error)
- func (m *LocalWalletManager) GetType() sharedtypes.WalletType
- func (m *LocalWalletManager) InitializeKeystore(derivationPath string, walletIndex uint, mnemonic string, password string) (*sharedtypes.LocalWalletData, error)
- func (m *LocalWalletManager) LoadWallet(data *sharedtypes.LocalWalletData, password string) error
- func (m *LocalWalletManager) SerializeData() (string, error)
- func (m *LocalWalletManager) SignMessage(message []byte) ([]byte, error)
- func (m *LocalWalletManager) SignTransaction(serializedTx []byte) ([]byte, error)
- func (m *LocalWalletManager) VerifyPassword(password string) (bool, error)
- type PasswordManager
- 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() (sharedtypes.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) 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 DefaultNodeKeyPath = "m/44'/60'/0'/0/%d" LedgerLiveNodeKeyPath = "m/44'/60'/%d/0/0" MyEtherWalletNodeKeyPath = "m/44'/60'/0'/%d" )
Config
Variables ¶
This section is empty.
Functions ¶
func GenerateNewMnemonic ¶ added in v0.2.3
Generate a new random mnemonic and seed
Types ¶
type AddressManager ¶
type AddressManager struct {
// contains filtered or unexported fields
}
Simple class to wrap the node's address file
func NewAddressManager ¶
func NewAddressManager(path string) *AddressManager
Creates a new address manager
func (*AddressManager) GetAddress ¶
func (m *AddressManager) GetAddress() (common.Address, bool)
Get the cached address
func (*AddressManager) LoadAddress ¶
func (m *AddressManager) LoadAddress() (common.Address, bool, error)
Gets the address saved on disk. Returns false if the address file doesn't exist.
func (*AddressManager) SetAddress ¶ added in v0.2.3
func (m *AddressManager) SetAddress(newAddress common.Address)
Sets the node address without saving it to disk
func (*AddressManager) SetAndSaveAddress ¶
func (m *AddressManager) SetAndSaveAddress(newAddress common.Address) error
Sets the node address and saves it to disk
type IWalletManager ¶
type IWalletManager interface { // The type of wallet GetType() types.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 LocalWalletManager ¶
type LocalWalletManager struct {
// contains filtered or unexported fields
}
Simple class to wrap a node's local wallet keystore. Note that this does *not* manage the wallet data file on disk, though it does manage the legacy keystore used by some integrations.
func NewLocalWalletManager ¶
func NewLocalWalletManager(chainID uint) *LocalWalletManager
Creates a new wallet manager for local wallets
func (*LocalWalletManager) GenerateValidatorKey ¶
func (m *LocalWalletManager) GenerateValidatorKey(path string) ([]byte, error)
Generate the validator key with the provided path, using the wallet's seed as the root
func (*LocalWalletManager) GetAddress ¶
func (m *LocalWalletManager) GetAddress() (common.Address, error)
Get the pubkey of the loaded node wallet, or false if one isn't loaded yet
func (*LocalWalletManager) GetEthKeystore ¶
func (m *LocalWalletManager) GetEthKeystore(password string) ([]byte, error)
Get the legacy keystore in Geth format
func (*LocalWalletManager) GetPrivateKey ¶
func (m *LocalWalletManager) GetPrivateKey() *ecdsa.PrivateKey
Get the private key if it's been loaded
func (*LocalWalletManager) GetTransactor ¶
func (m *LocalWalletManager) GetTransactor() (*bind.TransactOpts, error)
Get the transactor for the wallet
func (*LocalWalletManager) GetType ¶
func (m *LocalWalletManager) GetType() sharedtypes.WalletType
Get the type of this wallet manager
func (*LocalWalletManager) InitializeKeystore ¶
func (m *LocalWalletManager) InitializeKeystore(derivationPath string, walletIndex uint, mnemonic string, password string) (*sharedtypes.LocalWalletData, error)
Initialize a new keystore from a mnemonic and derivation info, derive the corresponding key, and load it all up
func (*LocalWalletManager) LoadWallet ¶
func (m *LocalWalletManager) LoadWallet(data *sharedtypes.LocalWalletData, password string) error
Load the node wallet's private key from the keystore
func (*LocalWalletManager) SerializeData ¶
func (m *LocalWalletManager) SerializeData() (string, error)
Serialize the wallet data as JSON
func (*LocalWalletManager) SignMessage ¶
func (m *LocalWalletManager) SignMessage(message []byte) ([]byte, error)
Signs a message with the node wallet's private key
func (*LocalWalletManager) SignTransaction ¶
func (m *LocalWalletManager) SignTransaction(serializedTx []byte) ([]byte, error)
Signs a transaction with the node wallet's private key
func (*LocalWalletManager) VerifyPassword ¶
func (m *LocalWalletManager) VerifyPassword(password string) (bool, error)
Verifies that the provided password is correct for this wallet's keystore
type PasswordManager ¶
type PasswordManager struct {
// contains filtered or unexported fields
}
Simple class to wrap the node's password file
func NewPasswordManager ¶
func NewPasswordManager(path string) *PasswordManager
Creates a new password manager
func (*PasswordManager) DeletePassword ¶
func (m *PasswordManager) DeletePassword() error
Delete the password from disk
func (*PasswordManager) GetPasswordFromDisk ¶
func (m *PasswordManager) GetPasswordFromDisk() (string, bool, error)
Gets the password saved on disk. Returns nil if the password file doesn't exist.
func (*PasswordManager) SavePassword ¶
func (m *PasswordManager) SavePassword(password string) error
Save the password to disk
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
Wallet
func NewWallet ¶
func NewWallet(log *log.ColorLogger, 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() (sharedtypes.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 moe)
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