Documentation ¶
Index ¶
- Constants
- Variables
- func Dir(name string) string
- func PersistDir() string
- func UserHomeDir() string
- type Backend
- type SpendableOutputs
- type Wallet
- func Load(name string) (*Wallet, error)
- func New(name string, keysToLoad uint64, backendName string) (*Wallet, error)
- func NewWalletFromMnemonic(name string, mnemonic string, keysToLoad uint64, backendName string) (*Wallet, error)
- func NewWalletFromSeed(name string, seed modules.Seed, keysToLoad uint64, backendName string) (*Wallet, error)
- func (w *Wallet) GetBalance() (types.Currency, types.Currency, error)
- func (w *Wallet) GetChainConstants() (modules.DaemonConstants, error)
- func (w *Wallet) ListAddresses() []types.UnlockHash
- func (w *Wallet) LoadKeys(amount uint64) error
- func (w *Wallet) Mnemonic() (string, error)
- func (w *Wallet) TransferCoins(amount types.Currency, to types.UnlockConditionProxy, data []byte, ...) (types.TransactionID, error)
- func (w *Wallet) TransferCoinsMulti(amounts []types.Currency, conditions []types.UnlockConditionProxy, data []byte, ...) (types.TransactionID, error)
Constants ¶
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 ¶
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 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 ¶
Load loads persistent data for a wallet with a given name, and restores the wallets state
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 ¶
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 ¶
LoadKeys loads `amount` additional keys in the wallet and saves the wallet state
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.