Documentation
¶
Index ¶
- Constants
- 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 CRCNotMatchError
- type Config
- type ExitsError
- type HistoryInfo
- type Info
- type Manager
- func (wm *Manager) AddressHistory(walletName, address string) ([]HistoryInfo, error)
- func (wm *Manager) CreateWallet(walletName, password string) (string, error)
- func (wm *Manager) GetAddressInfo(walletName, address string) (*vault.AddressInfo, error)
- func (wm *Manager) GetNewAddress(walletName, label, password string, addressType crypto.AddressType) (*vault.AddressInfo, error)
- func (*Manager) GetValidatorAddress(publicKey string) (string, error)
- func (wm *Manager) ListAddress(walletName string) ([]vault.AddressInfo, error)
- func (wm *Manager) ListWallet() ([]string, error)
- func (wm *Manager) LoadWallet(walletName, serverAddr string) error
- func (wm *Manager) RestoreWallet(walletName, mnemonic, password string) error
- func (wm *Manager) SetAddressLabel(walletName, address, label string) error
- func (wm *Manager) SignMessage(walletName, password, addr, msg string) (string, error)
- func (wm *Manager) SignRawTransaction(walletName, password string, rawTx []byte) (txID, data []byte, err error)
- func (wm *Manager) TotalBalance(walletName string) (amount.Amount, error)
- func (wm *Manager) TotalStake(walletName string) (amount.Amount, error)
- func (wm *Manager) UnloadWallet(walletName string) error
- func (wm *Manager) WalletInfo(walletName string) (*Info, error)
- type Option
- type Store
- type TxOption
- type UnsupportedVersionError
- type Wallet
- func (w *Wallet) AddTransaction(txID tx.ID) error
- func (w *Wallet) AddressCount() int
- func (w *Wallet) AddressFromPath(p string) *vault.AddressInfo
- func (w *Wallet) AddressInfo(addr string) *vault.AddressInfo
- func (w *Wallet) AddressInfos() []vault.AddressInfo
- func (w *Wallet) AllAccountAddresses() []vault.AddressInfo
- func (w *Wallet) AllValidatorAddresses() []vault.AddressInfo
- func (w *Wallet) Balance(addrStr string) (amount.Amount, error)
- func (w *Wallet) BroadcastTransaction(trx *tx.Tx) (string, error)
- func (w *Wallet) CoinType() uint32
- func (w *Wallet) Contains(addr string) bool
- func (w *Wallet) CreationTime() time.Time
- func (w *Wallet) History(addr string) []HistoryInfo
- func (w *Wallet) ImportBLSPrivateKey(password string, prv *bls.PrivateKey) error
- func (w *Wallet) ImportEd25519PrivateKey(password string, prv *ed25519.PrivateKey) error
- func (w *Wallet) Info() *Info
- func (w *Wallet) IsEncrypted() bool
- func (w *Wallet) IsOffline() bool
- func (w *Wallet) Label(addr string) string
- 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) Name() string
- func (w *Wallet) Network() genesis.ChainType
- func (w *Wallet) Neuter(path string) *Wallet
- func (w *Wallet) NewBLSAccountAddress(label string) (*vault.AddressInfo, error)
- func (w *Wallet) NewEd25519AccountAddress(label, password string) (*vault.AddressInfo, error)
- func (w *Wallet) NewValidatorAddress(label string) (*vault.AddressInfo, error)
- func (w *Wallet) Path() string
- func (w *Wallet) PrivateKey(password, addr string) (crypto.PrivateKey, error)
- func (w *Wallet) PrivateKeys(password string, addrs []string) ([]crypto.PrivateKey, error)
- func (w *Wallet) RecoveryAddresses(ctx context.Context, password string, eventFunc func(addr string)) error
- func (w *Wallet) Save() error
- func (w *Wallet) SetDefaultFee(fee amount.Amount)
- func (w *Wallet) SetLabel(addr, label string) error
- 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 ¶
const ( Version1 = 1 // Initial version VersionLatest = Version1 )
Variables ¶
var ( // ErrInvalidNetwork describes an error in which the network is invalid. ErrInvalidNetwork = errors.New("invalid network") // ErrOffline describes an error in which the wallet is offline. ErrOffline = errors.New("wallet is in offline mode") // ErrHistoryExists describes an error in which the transaction already exists // in history. ErrHistoryExists = errors.New("transaction already exists") )
Functions ¶
func CheckMnemonic ¶
CheckMnemonic is a wrapper for `vault.CheckMnemonic`.
func GenerateMnemonic ¶
GenerateMnemonic is a wrapper for `vault.GenerateMnemonic`.
func OptionLockTime ¶
OptionLockTime sets the lock time for the transaction.
func OptionMemo ¶
OptionMemo sets a memo or note for the transaction.
Types ¶
type CRCNotMatchError ¶
CRCNotMatchError describes an error in which the wallet CRC is not matched.
func (CRCNotMatchError) Error ¶
func (e CRCNotMatchError) Error() string
type Config ¶
type Config struct {
// private config
WalletsDir string `toml:"-"`
ChainType genesis.ChainType `toml:"-"`
}
func DefaultConfig ¶
func DefaultConfig() *Config
type ExitsError ¶
type ExitsError struct {
Path string
}
ExitsError describes an error in which a wallet exists in the given path.
func (ExitsError) Error ¶
func (e ExitsError) Error() string
type HistoryInfo ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewWalletManager ¶
func (*Manager) AddressHistory ¶
func (wm *Manager) AddressHistory( walletName, address string, ) ([]HistoryInfo, error)
func (*Manager) CreateWallet ¶
func (*Manager) GetAddressInfo ¶
func (wm *Manager) GetAddressInfo(walletName, address string) (*vault.AddressInfo, error)
func (*Manager) GetNewAddress ¶
func (wm *Manager) GetNewAddress( walletName, label, password string, addressType crypto.AddressType, ) (*vault.AddressInfo, error)
func (*Manager) GetValidatorAddress ¶
func (*Manager) ListAddress ¶
func (wm *Manager) ListAddress(walletName string) ([]vault.AddressInfo, error)
func (*Manager) ListWallet ¶
func (*Manager) LoadWallet ¶
func (*Manager) RestoreWallet ¶
func (*Manager) SetAddressLabel ¶
func (*Manager) SignMessage ¶
func (*Manager) SignRawTransaction ¶
func (*Manager) TotalBalance ¶
func (*Manager) TotalStake ¶
func (*Manager) UnloadWallet ¶
type Store ¶
type Store struct {
Version int `json:"version"`
UUID uuid.UUID `json:"uuid"`
CreatedAt time.Time `json:"created_at"`
Network genesis.ChainType `json:"network"`
VaultCRC uint32 `json:"crc"`
Vault *vault.Vault `json:"vault"`
History history `json:"history"`
}
func (*Store) UpgradeWallet ¶
func (*Store) ValidateCRC ¶
type TxOption ¶
type TxOption func(builder *txBuilder) error
TxOption defines a function type used to apply options to a txBuilder.
type UnsupportedVersionError ¶
UnsupportedVersionError indicates the wallet version is incompatible with the software's supported version.
func (UnsupportedVersionError) Error ¶
func (e UnsupportedVersionError) Error() string
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
func Create ¶
func Create(walletPath, mnemonic, password string, chain genesis.ChainType, options ...Option, ) (*Wallet, error)
Create creates a wallet from mnemonic (seed phrase) and save it at the given path.
func Open ¶
Open tries to open a wallet at the given path. If the wallet doesn’t exist on this path, it returns an error. 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) AddressCount ¶
AddressCount returns the number of addresses inside the wallet.
func (*Wallet) AddressFromPath ¶
func (w *Wallet) AddressFromPath(p string) *vault.AddressInfo
func (*Wallet) AddressInfo ¶
func (w *Wallet) AddressInfo(addr string) *vault.AddressInfo
func (*Wallet) AddressInfos ¶
func (w *Wallet) AddressInfos() []vault.AddressInfo
func (*Wallet) AllAccountAddresses ¶
func (w *Wallet) AllAccountAddresses() []vault.AddressInfo
func (*Wallet) AllValidatorAddresses ¶
func (w *Wallet) AllValidatorAddresses() []vault.AddressInfo
func (*Wallet) BroadcastTransaction ¶
func (*Wallet) CreationTime ¶
func (*Wallet) History ¶
func (w *Wallet) History(addr string) []HistoryInfo
func (*Wallet) ImportBLSPrivateKey ¶
func (w *Wallet) ImportBLSPrivateKey(password string, prv *bls.PrivateKey) error
func (*Wallet) ImportEd25519PrivateKey ¶
func (w *Wallet) ImportEd25519PrivateKey(password string, prv *ed25519.PrivateKey) error
func (*Wallet) IsEncrypted ¶
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 ¶
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) NewBLSAccountAddress ¶
func (w *Wallet) NewBLSAccountAddress(label string) (*vault.AddressInfo, error)
NewBLSAccountAddress create a new BLS-based account address and associates it with the given label.
func (*Wallet) NewEd25519AccountAddress ¶
func (w *Wallet) NewEd25519AccountAddress(label, password string) (*vault.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 ¶
func (w *Wallet) NewValidatorAddress(label string) (*vault.AddressInfo, error)
NewValidatorAddress creates a new BLS validator address and associates it with the given label.
func (*Wallet) PrivateKey ¶
func (w *Wallet) PrivateKey(password, addr string) (crypto.PrivateKey, error)
func (*Wallet) PrivateKeys ¶
func (*Wallet) RecoveryAddresses ¶ added in v0.2.0
func (w *Wallet) RecoveryAddresses(ctx context.Context, password string, eventFunc func(addr string), ) error
RecoveryAddresses recovers active addresses in the wallet.
func (*Wallet) SetDefaultFee ¶
func (*Wallet) SignMessage ¶
func (*Wallet) SignTransaction ¶
func (*Wallet) TotalBalance ¶
TotalBalance return the total available balance of the wallet.
func (*Wallet) TotalStake ¶
TotalStake return total available stake of the wallet.