wallet

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 26 Imported by: 15

Documentation

Index

Constants

View Source
const (
	EntropyBits = 256
	FileMode    = 0600
)

Config

Variables

This section is empty.

Functions

func GenerateNewMnemonic

func GenerateNewMnemonic() (string, error)

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

func (w *Wallet) DeletePassword() error

Delete the wallet password from disk, but retain it in memory if a local keystore is already loaded

func (*Wallet) GenerateValidatorKey

func (w *Wallet) GenerateValidatorKey(path string) ([]byte, error)

Generate a BLS validator key from the provided path, using the node wallet's seed as a basis

func (*Wallet) GetAddress

func (w *Wallet) GetAddress() (common.Address, bool)

Get the node address, if one is loaded

func (*Wallet) GetEthKeystore

func (w *Wallet) GetEthKeystore(password string) ([]byte, error)

Get the node account private key bytes

func (*Wallet) GetNodePrivateKeyBytes

func (w *Wallet) GetNodePrivateKeyBytes() ([]byte, error)

Get the node account private key bytes

func (*Wallet) GetPassword

func (w *Wallet) GetPassword() (string, bool, error)

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

func (w *Wallet) MasqueradeAsAddress(newAddress common.Address) error

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) Reload added in v0.3.0

func (w *Wallet) Reload(logger *slog.Logger) error

Reloads the wallet artifacts from disk

func (*Wallet) RestoreAddressToWallet

func (w *Wallet) RestoreAddressToWallet() error

End masquerading as another node address, and use the wallet's address (returning to read/write mode)

func (*Wallet) SerializeData

func (w *Wallet) SerializeData() (string, error)

Serialize the wallet data as JSON

func (*Wallet) SetPassword

func (w *Wallet) SetPassword(password string, save bool) error

Attempts to load the wallet keystore with the provided password if not set

func (*Wallet) SignMessage

func (w *Wallet) SignMessage(message []byte) ([]byte, error)

Sign a message with the wallet's private key

func (*Wallet) SignTransaction

func (w *Wallet) SignTransaction(serializedTx []byte) ([]byte, error)

Sign a transaction with the wallet's private key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL