wallet

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 22 Imported by: 7

Documentation

Index

Constants

View Source
const (
	NetworkMainNet = Network(0)
	NetworkTestNet = Network(1)
)

Variables

View Source
var (
	// ErrInvalidCRC describes an error in which the wallet CRC is invalid.
	ErrInvalidCRC = errors.New("invalid CRC")

	// 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 GenerateMnemonic

func GenerateMnemonic(entropy int) string

GenerateMnemonic is a wrapper for `vault.GenerateMnemonic.

func NewErrWalletExits

func NewErrWalletExits(path string) error

func OptionFee

func OptionFee(fee int64) func(builder *txBuilder) error

func OptionMemo

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

func OptionSequence

func OptionSequence(seq int32) func(builder *txBuilder) error

func OptionStamp

func OptionStamp(stamp string) func(builder *txBuilder) error

Types

type ErrWalletExits

type ErrWalletExits struct {
	Path string
}

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

func (ErrWalletExits) Error

func (e ErrWalletExits) Error() string

type HistoryInfo

type HistoryInfo struct {
	TxID        string
	Time        *time.Time
	PayloadType string
	Desc        string
	Amount      int64
}

type Network

type Network uint8

type TxOption

type TxOption func(builder *txBuilder) error

type Wallet

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

func Create

func Create(path, mnemonic, password string, net Network) (*Wallet, error)

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

func Open added in v0.10.0

func Open(path string, offline bool) (*Wallet, error)

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) AccountSequence added in v0.10.0

func (w *Wallet) AccountSequence(addrStr string) (int32, error)

AccountSequence returns the sequence of the account associated with the address.

func (*Wallet) AddTransaction

func (w *Wallet) AddTransaction(id tx.ID) error

func (*Wallet) AddressCount

func (w *Wallet) AddressCount() int

AddressCount returns the number of addresses inside the wallet.

func (*Wallet) AddressInfo

func (w *Wallet) AddressInfo(addr string) *vault.AddressInfo

func (*Wallet) AddressLabels

func (w *Wallet) AddressLabels() []vault.AddressInfo

func (*Wallet) Balance

func (w *Wallet) Balance(addrStr string) (int64, 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) CalculateFee

func (w *Wallet) CalculateFee(amount int64) int64

TODO: query fee from grpc client

func (*Wallet) Connect

func (w *Wallet) Connect(addr string) error

func (*Wallet) Contains

func (w *Wallet) Contains(addr string) bool

func (*Wallet) DeriveNewAddress

func (w *Wallet) DeriveNewAddress(label string) (string, error)

func (*Wallet) GetHistory

func (w *Wallet) GetHistory(addr string) []HistoryInfo

func (*Wallet) ImportPrivateKey

func (w *Wallet) ImportPrivateKey(password string, prv crypto.PrivateKey) error

func (*Wallet) IsEncrypted

func (w *Wallet) IsEncrypted() bool

func (*Wallet) IsOffline

func (w *Wallet) IsOffline() bool

func (*Wallet) Label

func (w *Wallet) Label(addr string) string

Label returns label of addr.

func (*Wallet) MakeBondTx

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

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

func (*Wallet) MakeSendTx

func (w *Wallet) MakeSendTx(sender, receiver string, amount int64,
	options ...TxOption) (*tx.Tx, error)

MakeSendTx creates a new send 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, amount int64,
	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) Name

func (w *Wallet) Name() string

func (*Wallet) Path

func (w *Wallet) Path() string

func (*Wallet) PrivateKey

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

func (*Wallet) PrivateKeys added in v0.10.0

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

func (*Wallet) Save

func (w *Wallet) Save() error

func (*Wallet) SetLabel

func (w *Wallet) SetLabel(addr, label string) error

SetLabel sets label for addr.

func (*Wallet) SignTransaction

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

func (*Wallet) Stake

func (w *Wallet) Stake(addrStr string) (int64, error)

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

func (*Wallet) UpdatePassword

func (w *Wallet) UpdatePassword(oldPassword, newPassword string) error

func (*Wallet) ValidatorSequence added in v0.10.0

func (w *Wallet) ValidatorSequence(addrStr string) (int32, error)

ValidatorSequence returns the sequence of the validator associated with the address.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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