walletutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInsufficientBalance = errors.New("insufficient balance")

ErrInsufficientBalance is returned when there aren't enough unused outputs to cover the requested amount.

Functions

func SumOutputs

func SumOutputs(outputs []types.SiacoinElement) (sum types.Currency)

SumOutputs returns the total value of the supplied outputs.

Types

type DBStore

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

A DBStore stores wallet state in a MySQL database.

func NewDBStore

func NewDBStore(db *sql.DB, seed, network string, logger *zap.Logger) (*DBStore, types.ChainIndex, error)

NewDBStore returns a new DBStore.

func (*DBStore) Address

func (s *DBStore) Address() types.Address

Address implements api.Wallet.

func (*DBStore) Annotate

func (s *DBStore) Annotate(txns []types.Transaction) (ptxns []wallet.PoolTransaction)

Annotate implements api.Wallet.

func (*DBStore) ProcessChainApplyUpdate

func (s *DBStore) ProcessChainApplyUpdate(cau *chain.ApplyUpdate, mayCommit bool) (err error)

ProcessChainApplyUpdate implements chain.Subscriber.

func (*DBStore) ProcessChainRevertUpdate

func (s *DBStore) ProcessChainRevertUpdate(cru *chain.RevertUpdate) (err error)

ProcessChainRevertUpdate implements chain.Subscriber.

func (*DBStore) UnspentOutputs

func (s *DBStore) UnspentOutputs() (sces []types.SiacoinElement, sfes []types.SiafundElement, err error)

UnspentOutputs implements api.Wallet.

type Wallet

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

func NewWallet

func NewWallet(db *sql.DB, seed, seedZen, dir string, cm *chain.Manager, cmZen *chain.Manager, syncer *syncer.Syncer, syncerZen *syncer.Syncer) (*Wallet, error)

NewWallet returns a wallet that is stored in a MySQL database.

func (*Wallet) Address

func (w *Wallet) Address(network string) types.Address

Address implements api.Wallet.

func (*Wallet) Annotate

func (w *Wallet) Annotate(network string, txns []types.Transaction) ([]wallet.PoolTransaction, error)

Annotate implements api.Wallet.

func (*Wallet) Close

func (w *Wallet) Close()

Close shuts down the wallet.

func (*Wallet) Fund

func (w *Wallet) Fund(network string, txn *types.Transaction, amount types.Currency, useUnconfirmed bool) (parents []types.Transaction, toSign []types.Hash256, err error)

Fund adds Siacoin inputs with the required amount to the transaction.

func (*Wallet) Key

func (w *Wallet) Key(network string) types.PrivateKey

Key implements api.Wallet.

func (*Wallet) Redistribute

func (w *Wallet) Redistribute(network string, amount types.Currency, outputs int) error

Redistribute creates a specified number of new outputs and distributes the funds between them.

func (*Wallet) Release

func (w *Wallet) Release(txns ...types.Transaction)

Release marks the inputs as unused.

func (*Wallet) Sign

func (w *Wallet) Sign(network string, txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields)

Sign adds signatures corresponding to toSign elements to the transaction.

func (*Wallet) UnspentOutputs

func (w *Wallet) UnspentOutputs(network string) ([]types.SiacoinElement, []types.SiafundElement, error)

UnspentOutputs implements api.Wallet.

Jump to

Keyboard shortcuts

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