account

package
v0.0.0-...-4e0ae02 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2016 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package account stores and tracks accounts within a Chain Core.

Index

Constants

View Source
const PinName = "account"

PinName is used to identify the pin associated with the account block processor.

Variables

View Source
var (
	// ErrInsufficient indicates the account doesn't contain enough
	// units of the requested asset to satisfy the reservation.
	// New units must be deposited into the account in order to
	// satisfy the request; change will not be sufficient.
	ErrInsufficient = errors.New("reservation found insufficient funds")

	// ErrReserved indicates that a reservation could not be
	// satisfied because some of the outputs were already reserved.
	// When those reservations are finalized into a transaction
	// (and no other transaction spends funds from the account),
	// new change outputs will be created
	// in sufficient amounts to satisfy the request.
	ErrReserved = errors.New("reservation found outputs already reserved")
)
View Source
var ErrDuplicateAlias = errors.New("duplicate account alias")

Functions

This section is empty.

Types

type Account

type Account struct {
	*signers.Signer
	Alias string
	Tags  map[string]interface{}
}

type Manager

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

Manager stores accounts and their associated control programs.

func NewManager

func NewManager(db *sql.DB, chain *protocol.Chain, pinStore *pin.Store) *Manager

func (*Manager) AnnotateTxs

func (m *Manager) AnnotateTxs(ctx context.Context, txs []map[string]interface{}) error

AnnotateTxs adds account data to transactions

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, xpubs []string, quorum int, alias string, tags map[string]interface{}, clientToken *string) (*Account, error)

Create creates a new Account.

func (*Manager) CreateControlProgram

func (m *Manager) CreateControlProgram(ctx context.Context, accountID string, change bool) ([]byte, error)

CreateControlProgram creates a control program that is tied to the Account and stores it in the database.

func (*Manager) DecodeControlAction

func (m *Manager) DecodeControlAction(data []byte) (txbuilder.Action, error)

func (*Manager) DecodeSpendAction

func (m *Manager) DecodeSpendAction(data []byte) (txbuilder.Action, error)

func (*Manager) DecodeSpendUTXOAction

func (m *Manager) DecodeSpendUTXOAction(data []byte) (txbuilder.Action, error)

func (*Manager) ExpireReservations

func (m *Manager) ExpireReservations(ctx context.Context, period time.Duration)

ExpireReservations removes reservations that have expired periodically. It blocks until the context is canceled.

func (*Manager) FindByAlias

func (m *Manager) FindByAlias(ctx context.Context, alias string) (*signers.Signer, error)

FindByAlias retrieves an account's Signer record by its alias

func (*Manager) IndexAccounts

func (m *Manager) IndexAccounts(indexer Saver)

func (*Manager) NewControlAction

func (m *Manager) NewControlAction(amt bc.AssetAmount, accountID string, refData chainjson.Map) txbuilder.Action

func (*Manager) NewSpendAction

func (m *Manager) NewSpendAction(amt bc.AssetAmount, accountID string, refData chainjson.Map, clientToken *string) txbuilder.Action

func (*Manager) NewSpendUTXOAction

func (m *Manager) NewSpendUTXOAction(outpoint bc.Outpoint) txbuilder.Action

func (*Manager) ProcessBlocks

func (m *Manager) ProcessBlocks(ctx context.Context)

type Saver

type Saver interface {
	SaveAnnotatedAccount(context.Context, string, map[string]interface{}) error
}

A Saver is responsible for saving an annotated account object. for indexing and retrieval. If the Core is configured not to provide search services, SaveAnnotatedAccount can be a no-op.

Jump to

Keyboard shortcuts

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