Documentation
¶
Index ¶
- Variables
- func CheckMnemonic(mnemonic string) error
- func GenerateMnemonic(entropy int) (string, error)
- func OptionFee(feeStr string) func(builder *txBuilder) error
- func OptionLockTime(lockTime uint32) func(builder *txBuilder) error
- func OptionMemo(memo string) func(builder *txBuilder) error
- type ExitsError
- type ListAddressOption
- type ListTransactionsOption
- type NewAddressOption
- type OpenWalletOption
- type TxOption
- type Wallet
- func (t *Wallet) AddTransaction(txID tx.ID) error
- func (a *Wallet) AddressCount() int
- func (a *Wallet) AddressInfo(addr string) (*types.AddressInfo, error)
- func (a *Wallet) AddressLabel(addr string) string
- func (w *Wallet) Balance(addrStr string) (amount.Amount, error)
- func (w *Wallet) BroadcastTransaction(trx *tx.Tx) (string, error)
- func (w *Wallet) Close()
- func (a *Wallet) HasAddress(addr string) bool
- func (a *Wallet) ImportBLSPrivateKey(password string, prv *bls.PrivateKey) error
- func (a *Wallet) ImportEd25519PrivateKey(password string, prv *ed25519.PrivateKey) error
- func (w *Wallet) Info() *types.WalletInfo
- func (w *Wallet) IsEncrypted() bool
- func (a *Wallet) ListAddresses(opts ...ListAddressOption) []types.AddressInfo
- func (t *Wallet) ListTransactions(opts ...ListTransactionsOption) []*types.TransactionInfo
- func (w *Wallet) MakeBondTx(sender, receiver, pubKey string, amt amount.Amount, options ...TxOption) (*tx.Tx, error)
- func (w *Wallet) MakeTransferTx(sender, receiver string, amt amount.Amount, options ...TxOption) (*tx.Tx, error)
- func (w *Wallet) MakeUnbondTx(addr string, opts ...TxOption) (*tx.Tx, error)
- func (w *Wallet) MakeWithdrawTx(sender, receiver string, amt amount.Amount, options ...TxOption) (*tx.Tx, error)
- func (w *Wallet) Mnemonic(password string) (string, error)
- func (w *Wallet) Neuter(path string) error
- func (a *Wallet) NewAddress(addressType crypto.AddressType, label string, opts ...NewAddressOption) (*types.AddressInfo, error)
- func (a *Wallet) NewBLSAccountAddress(label string) (*types.AddressInfo, error)
- func (a *Wallet) NewEd25519AccountAddress(label, password string) (*types.AddressInfo, error)
- func (a *Wallet) NewValidatorAddress(label string) (*types.AddressInfo, error)
- func (w *Wallet) Path() string
- func (a *Wallet) PrivateKey(password, addr string) (crypto.PrivateKey, error)
- func (a *Wallet) PrivateKeys(password string, addrs []string) ([]crypto.PrivateKey, error)
- func (w *Wallet) RecoveryAddresses(ctx context.Context, password string, eventFunc func(addr string)) error
- func (a *Wallet) SetAddressLabel(addr, label string) error
- func (w *Wallet) SetDefaultFee(fee amount.Amount) error
- func (w *Wallet) SetProvider(provider provider.IBlockchainProvider)
- func (w *Wallet) SignMessage(password, addr, msg string) (string, error)
- func (w *Wallet) SignTransaction(password string, trx *tx.Tx) error
- func (w *Wallet) Stake(addrStr string) (amount.Amount, error)
- func (w *Wallet) TotalBalance() (amount.Amount, error)
- func (w *Wallet) TotalStake() (amount.Amount, error)
- func (w *Wallet) UpdatePassword(oldPassword, newPassword string, opts ...encrypter.Option) error
- func (w *Wallet) Version() int
Constants ¶
This section is empty.
Variables ¶
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
CheckMnemonic is a wrapper for `vault.CheckMnemonic`.
func GenerateMnemonic ¶
GenerateMnemonic is a wrapper for `vault.GenerateMnemonic`.
func OptionLockTime ¶ added in v0.15.0
OptionLockTime sets the lock time for the transaction.
func OptionMemo ¶
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
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 (*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
AddressLabel returns label of the given addresa.
func (*Wallet) BroadcastTransaction ¶
func (*Wallet) HasAddress ¶ added in v1.11.0
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 (*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 ¶
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) Neuter ¶ added in v1.8.0
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) 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
SetAddressLabel updates the label of the given addresa.
func (*Wallet) SetDefaultFee ¶ added in v1.9.0
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 (*Wallet) SignTransaction ¶
func (*Wallet) TotalBalance ¶ added in v1.1.0
TotalBalance return the total available balance of the wallet.
func (*Wallet) TotalStake ¶ added in v1.6.0
TotalStake return total available stake of the wallet.
func (*Wallet) UpdatePassword ¶
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. |