wallet

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 27 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAddressType describes an error in which the address type is invalid.
	ErrInvalidAddressType = errors.New("invalid address type")

	// ErrAddressExists describes an error in which the address already exist
	// in wallet.
	ErrAddressExists = errors.New("address already exists")

	// ErrTransactionExists indicates the transaction already exists in the wallet.
	ErrTransactionExists = errors.New("transaction already exists")
)

Functions

func CheckMnemonic added in v0.13.0

func CheckMnemonic(mnemonic string) error

CheckMnemonic is a wrapper for `vault.CheckMnemonic`.

func GenerateMnemonic

func GenerateMnemonic(entropy int) (string, error)

GenerateMnemonic is a wrapper for `vault.GenerateMnemonic`.

func OptionFee

func OptionFee(feeStr string) func(builder *txBuilder) error

OptionFee sets the transaction fee using a string input.

func OptionLockTime added in v0.15.0

func OptionLockTime(lockTime uint32) func(builder *txBuilder) error

OptionLockTime sets the lock time for the transaction.

func OptionMemo

func OptionMemo(memo string) func(builder *txBuilder) error

OptionMemo sets a memo or note for the transaction.

Types

type ExitsError added in v0.15.0

type ExitsError struct {
	Path string
}

ExitsError describes an error in which a wallet exists in the given path.

func (ExitsError) Error added in v0.15.0

func (e ExitsError) Error() string

type ListAddressOption added in v1.11.0

type ListAddressOption func(*listAddressConfig)

ListAddressOption is a functional option for ListAddresses.

func OnlyAccountAddresses added in v1.11.0

func OnlyAccountAddresses() ListAddressOption

OnlyAccountAddresses filters to show only account addresses (BLS and Ed25519).

func OnlyValidatorAddresses added in v1.11.0

func OnlyValidatorAddresses() ListAddressOption

OnlyValidatorAddresses filters to show only validator addresses.

func WithAddressType added in v1.11.0

func WithAddressType(addressType crypto.AddressType) ListAddressOption

WithAddressType filters addresses by the specified type.

func WithAddressTypes added in v1.11.0

func WithAddressTypes(addressTypes []crypto.AddressType) ListAddressOption

WithAddressTypes filters addresses by the specified type.

type ListTransactionsOption added in v1.11.0

type ListTransactionsOption func(*listTransactionsConfig)

ListTransactionsOption is a functional option for ListTransactions.

func WithAddress added in v1.11.0

func WithAddress(address string) ListTransactionsOption

WithAddress filters transactions by the specified address.

func WithCount added in v1.11.0

func WithCount(count int) ListTransactionsOption

WithCount sets the maximum number of transactions to return.

func WithDirection added in v1.11.0

func WithDirection(dir types.TxDirection) ListTransactionsOption

WithDirection filters transactions by direction (incoming or outgoing).

func WithSkip added in v1.11.0

func WithSkip(skip int) ListTransactionsOption

WithSkip sets the number of transactions to skip.

type NewAddressOption added in v1.11.0

type NewAddressOption func(*newAddressConfig)

NewAddressOption is a functional option for NewAddresa.

func WithPassword added in v1.11.0

func WithPassword(password string) NewAddressOption

WithPassword sets the password for address creation required for Ed25519 accounta.

type OpenWalletOption added in v1.11.0

type OpenWalletOption func(*openWalletConfig)

func WithBlockchainProvider added in v1.11.0

func WithBlockchainProvider(provider provider.IBlockchainProvider) OpenWalletOption

func WithEventPipe added in v1.11.0

func WithEventPipe(eventPipe pipeline.Pipeline[any]) OpenWalletOption

type TxOption

type TxOption func(builder *txBuilder) error

TxOption defines a function type used to apply options to a txBuilder.

type Wallet

type Wallet struct {
	// contains filtered or unexported fields
}

func Create

func Create(ctx context.Context, walletPath, mnemonic, password string,
	chain genesis.ChainType, opts ...OpenWalletOption,
) (*Wallet, error)

Create creates a wallet from mnemonic (seed phrase) and save it at the given path.

func New added in v1.11.0

func New(storage storage.IStorage, opts ...OpenWalletOption) (*Wallet, error)

func Open added in v0.10.0

func Open(ctx context.Context, walletPath string, opts ...OpenWalletOption) (*Wallet, error)

Open tries to open a wallet at the given path. It first tries the SQLite backend; if that fails, it falls back to the legacy JSON wallet format. A wallet can be opened in offline or online modes. Offline wallet doesn’t have any connection to any node. Online wallet has a connection to one of the pre-defined servers.

func (*Wallet) AddTransaction

func (t *Wallet) AddTransaction(txID tx.ID) error

func (*Wallet) AddressCount

func (a *Wallet) AddressCount() int

AddressCount returns the number of addresses inside the wallet.

func (*Wallet) AddressInfo

func (a *Wallet) AddressInfo(addr string) (*types.AddressInfo, error)

func (*Wallet) AddressLabel added in v1.11.0

func (a *Wallet) AddressLabel(addr string) string

AddressLabel returns label of the given addresa.

func (*Wallet) Balance

func (w *Wallet) Balance(addrStr string) (amount.Amount, error)

Balance returns balance of the account associated with the address..

func (*Wallet) BroadcastTransaction

func (w *Wallet) BroadcastTransaction(trx *tx.Tx) (string, error)

func (*Wallet) Close added in v1.11.0

func (w *Wallet) Close()

func (*Wallet) HasAddress added in v1.11.0

func (a *Wallet) HasAddress(addr string) bool

func (*Wallet) ImportBLSPrivateKey added in v1.5.0

func (a *Wallet) ImportBLSPrivateKey(password string, prv *bls.PrivateKey) error

func (*Wallet) ImportEd25519PrivateKey added in v1.6.0

func (a *Wallet) ImportEd25519PrivateKey(password string, prv *ed25519.PrivateKey) error

func (*Wallet) Info added in v1.6.0

func (w *Wallet) Info() *types.WalletInfo

func (*Wallet) IsEncrypted

func (w *Wallet) IsEncrypted() bool

func (*Wallet) ListAddresses added in v1.11.0

func (a *Wallet) ListAddresses(opts ...ListAddressOption) []types.AddressInfo

func (*Wallet) ListTransactions added in v1.11.0

func (t *Wallet) ListTransactions(opts ...ListTransactionsOption) []*types.TransactionInfo

func (*Wallet) MakeBondTx

func (w *Wallet) MakeBondTx(sender, receiver, pubKey string, amt amount.Amount,
	options ...TxOption,
) (*tx.Tx, error)

MakeBondTx creates a new bond transaction based on the given parameters.

func (*Wallet) MakeTransferTx added in v0.13.0

func (w *Wallet) MakeTransferTx(sender, receiver string, amt amount.Amount,
	options ...TxOption,
) (*tx.Tx, error)

MakeTransferTx creates a new transfer transaction based on the given parameters.

func (*Wallet) MakeUnbondTx

func (w *Wallet) MakeUnbondTx(addr string, opts ...TxOption) (*tx.Tx, error)

MakeUnbondTx creates a new unbond transaction based on the given parameters.

func (*Wallet) MakeWithdrawTx

func (w *Wallet) MakeWithdrawTx(sender, receiver string, amt amount.Amount,
	options ...TxOption,
) (*tx.Tx, error)

MakeWithdrawTx creates a new withdraw transaction based on the given parameters.

func (*Wallet) Mnemonic

func (w *Wallet) Mnemonic(password string) (string, error)

func (*Wallet) Neuter added in v1.8.0

func (w *Wallet) Neuter(path string) error

Neuter clones the wallet and neuters it and saves it at the given path.

func (*Wallet) NewAddress added in v1.11.0

func (a *Wallet) NewAddress(addressType crypto.AddressType, label string, opts ...NewAddressOption,
) (*types.AddressInfo, error)

func (*Wallet) NewBLSAccountAddress added in v0.15.0

func (a *Wallet) NewBLSAccountAddress(label string) (*types.AddressInfo, error)

NewBLSAccountAddress create a new BLS-based account address and associates it with the given label.

func (*Wallet) NewEd25519AccountAddress added in v1.5.0

func (a *Wallet) NewEd25519AccountAddress(label, password string) (*types.AddressInfo, error)

NewEd25519AccountAddress create a new Ed25519-based account address and associates it with the given label. The password is required to access the master private key needed for address generation.

func (*Wallet) NewValidatorAddress added in v0.15.0

func (a *Wallet) NewValidatorAddress(label string) (*types.AddressInfo, error)

NewValidatorAddress creates a new BLS validator address and associates it with the given label.

func (*Wallet) Path

func (w *Wallet) Path() string

func (*Wallet) PrivateKey

func (a *Wallet) PrivateKey(password, addr string) (crypto.PrivateKey, error)

func (*Wallet) PrivateKeys added in v0.10.0

func (a *Wallet) PrivateKeys(password string, addrs []string) ([]crypto.PrivateKey, error)

func (*Wallet) RecoveryAddresses added in v1.10.0

func (w *Wallet) RecoveryAddresses(ctx context.Context, password string,
	eventFunc func(addr string),
) error

RecoveryAddresses recovers active addresses in the wallet.

func (*Wallet) SetAddressLabel added in v1.11.0

func (a *Wallet) SetAddressLabel(addr, label string) error

SetAddressLabel updates the label of the given addresa.

func (*Wallet) SetDefaultFee added in v1.9.0

func (w *Wallet) SetDefaultFee(fee amount.Amount) error

func (*Wallet) SetProvider added in v1.11.0

func (w *Wallet) SetProvider(provider provider.IBlockchainProvider)

SetProvider sets the blockchain provider for the wallet.

func (*Wallet) SignMessage added in v1.4.0

func (w *Wallet) SignMessage(password, addr, msg string) (string, error)

func (*Wallet) SignTransaction

func (w *Wallet) SignTransaction(password string, trx *tx.Tx) error

func (*Wallet) Stake

func (w *Wallet) Stake(addrStr string) (amount.Amount, error)

Stake returns stake of the validator associated with the address..

func (*Wallet) TotalBalance added in v1.1.0

func (w *Wallet) TotalBalance() (amount.Amount, error)

TotalBalance return the total available balance of the wallet.

func (*Wallet) TotalStake added in v1.6.0

func (w *Wallet) TotalStake() (amount.Amount, error)

TotalStake return total available stake of the wallet.

func (*Wallet) UpdatePassword

func (w *Wallet) UpdatePassword(oldPassword, newPassword string, opts ...encrypter.Option) error

func (*Wallet) Version added in v1.5.0

func (w *Wallet) Version() int

Directories

Path Synopsis
Package manager is a generated GoMock package.
Package manager is a generated GoMock package.
Package provider is a generated GoMock package.
Package provider is a generated GoMock package.
Package storage is a generated GoMock package.
Package storage is a generated GoMock package.

Jump to

Keyboard shortcuts

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