wallet

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ArbitraryDataMaxSize is the maximum size of the arbitrary data field on a transaction
	ArbitraryDataMaxSize = 83

	// WorkerCount is the number of workers used to process information about explorer addresses
	WorkerCount = 25
)

Variables

View Source
var (
	// ErrWalletExists indicates that a wallet with that name allready exists when trying to create a new wallet
	ErrWalletExists = errors.New("A wallet with that name already exists")
	// ErrNoSuchWallet indicates that there is no wallet for a given name when trying to load a wallet
	ErrNoSuchWallet = errors.New("A wallet with that name does not exist")
	// ErrTooMuchData indicates that the there is too much data to add to the transction
	ErrTooMuchData = errors.New("Too much data is being supplied to the transaction")
	// ErrInsufficientWalletFunds indicates that the wallet does not have sufficient funds to fund the transaction
	ErrInsufficientWalletFunds = errors.New("Insufficient funds to create this transaction")
)

Functions

func Dir

func Dir(name string) string

Dir returns the directory where the data is stored for a named wallet

func PersistDir

func PersistDir() string

PersistDir is the directory in which the light wallet data is stored

func UserHomeDir

func UserHomeDir() string

UserHomeDir gets the home directory of the current user

Types

type Backend

type Backend interface {
	// CheckAddress returns all interesting transactions and blocks related to a given unlockhash
	CheckAddress(types.UnlockHash) ([]api.ExplorerBlock, []api.ExplorerTransaction, error)
	// CurrentHeight returns the current chain height
	CurrentHeight() (types.BlockHeight, error)
	// SendTxn sends a txn to the backend to ultimately include it in the transactionpool
	SendTxn(types.Transaction) (types.TransactionID, error)
	// GetChainConstants gets the currently active chain constants for this backend
	GetChainConstants() (modules.DaemonConstants, error)
	// Name returns a static name for this backend, to allow loading and saving
	Name() string
}

Backend is the minimal interface required by a Wallet to have a view of the chain

type SpendableOutputs

type SpendableOutputs map[types.CoinOutputID]types.CoinOutput

SpendableOutputs maps CoinOutputID's to their corresponding actual output

type Wallet

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

Wallet represents a seed, and some derived info used to spend the associated funds

func Load

func Load(name string) (*Wallet, error)

Load loads persistent data for a wallet with a given name, and restores the wallets state

func New

func New(name string, keysToLoad uint64, backendName string) (*Wallet, error)

New creates a new wallet with a random seed

func NewWalletFromMnemonic

func NewWalletFromMnemonic(name string, mnemonic string, keysToLoad uint64, backendName string) (*Wallet, error)

NewWalletFromMnemonic creates a new wallet from a given mnemonic

func NewWalletFromSeed

func NewWalletFromSeed(name string, seed modules.Seed, keysToLoad uint64, backendName string) (*Wallet, error)

NewWalletFromSeed creates a new wallet with a given seed

func (*Wallet) GetBalance

func (w *Wallet) GetBalance() (types.Currency, types.Currency, error)

GetBalance returns the current unlocked and locked balance for the wallet

func (*Wallet) GetChainConstants

func (w *Wallet) GetChainConstants() (modules.DaemonConstants, error)

GetChainConstants returns the chainconstatns of the underlying network

func (*Wallet) ListAddresses

func (w *Wallet) ListAddresses() []types.UnlockHash

ListAddresses returns all currently loaded addresses

func (*Wallet) LoadKeys

func (w *Wallet) LoadKeys(amount uint64) error

LoadKeys loads `amount` additional keys in the wallet and saves the wallet state

func (*Wallet) Mnemonic

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

Mnemonic returns the human readable form of the seed

func (*Wallet) TransferCoins

func (w *Wallet) TransferCoins(amount types.Currency, to types.UnlockConditionProxy, data []byte, newRefundAddress bool) (types.TransactionID, error)

TransferCoins transfers coins by creating and submitting a V1 transaction. Data can optionally be included.

func (*Wallet) TransferCoinsMulti

func (w *Wallet) TransferCoinsMulti(amounts []types.Currency, conditions []types.UnlockConditionProxy, data []byte, newRefundAddress bool) (types.TransactionID, error)

TransferCoinsMulti transfers coins by creating and submitting a V1 transaction, with multiple outputs. Data can optionally be included.

Jump to

Keyboard shortcuts

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