accounts

package
v4.14.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 8 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address interface {
	// ID is an identifier for the address.
	ID() string
	EncodeForHumans() string
}

Address models a blockchain address to which coins can be sent.

type AddressAndAmount

type AddressAndAmount struct {
	Address string
	// Amount is the amount sent to or received on the address in a transaction.
	Amount coin.Amount
	// Ours is true if the address is one of our receive addresses.
	Ours bool
}

AddressAndAmount holds an address and the corresponding amount.

type Balance

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

Balance contains the available and incoming balance of an account.

func NewBalance

func NewBalance(available coin.Amount, incoming coin.Amount) *Balance

NewBalance creates a new balance with the given amounts.

func (*Balance) Available

func (balance *Balance) Available() coin.Amount

Available returns the sum of all unspent coins in the account. The amounts of unconfirmed outgoing transfers are no longer included (but their change is).

func (*Balance) Incoming

func (balance *Balance) Incoming() coin.Amount

Incoming returns the sum of all unconfirmed transfers coming into the account.

type Event

type Event string

Event instances are sent to the onEvent callback of the wallet.

const (
	// EventStatusChanged is fired when the status changes. Check the status using Initialized().
	EventStatusChanged Event = "statusChanged"

	// EventSyncStarted is fired when syncing with the blockchain starts. This happens in the very
	// beginning for the initial sync, and repeatedly afterwards when the wallet is updated (new
	// transactions, confirmations, etc.).
	EventSyncStarted Event = "syncstarted"

	// EventSyncDone follows EventSyncStarted.
	EventSyncDone Event = "syncdone"

	// EventHeadersSynced is fired when the headers finished syncing.
	EventHeadersSynced Event = "headersSynced"

	// EventFeeTargetsChanged is fired when the fee targets change.
	EventFeeTargetsChanged Event = "feeTargetsChanged"
)

type FeeTarget

type FeeTarget interface {
	Code() FeeTargetCode
}

FeeTarget interface has priority codes. Coin specific methods are implemented in corresponding coins

type FeeTargetCode

type FeeTargetCode string

FeeTargetCode models the code of a fee target. See the constants below.

const (
	// FeeTargetCodeLow is the low priority fee target.
	FeeTargetCodeLow FeeTargetCode = "low"

	// FeeTargetCodeEconomy is the economy priority fee target.
	FeeTargetCodeEconomy FeeTargetCode = "economy"

	// FeeTargetCodeNormal is the normal priority fee target.
	FeeTargetCodeNormal FeeTargetCode = "normal"

	// FeeTargetCodeHigh is the high priority fee target.
	FeeTargetCodeHigh FeeTargetCode = "high"

	// DefaultFeeTarget is the default fee target
	DefaultFeeTarget = FeeTargetCodeNormal
)

func NewFeeTargetCode

func NewFeeTargetCode(code string) (FeeTargetCode, error)

NewFeeTargetCode checks if the code is valid and returns a FeeTargetCode in that case.

type Info

type Info struct {
	SigningConfiguration *signing.Configuration `json:"signingConfiguration"`
}

Info holds account information.

type Interface

type Interface interface {
	Info() *Info
	// Code is a identifier for the account (to identify the account in databases, apis, etc.).
	Code() string
	Coin() coin.Coin
	// Name returns a human readable long name.
	Name() string
	// Initialize only starts the initialization, the account is not initialized right afterwards.
	Initialize() error
	Initialized() bool
	Offline() bool
	FatalError() bool
	Close()
	Notifier() Notifier
	Transactions() ([]Transaction, error)
	Balance() (*Balance, error)
	// Creates, signs and broadcasts a transaction. Returns keystore.ErrSigningAborted on user
	// abort.
	SendTx(string, coin.SendAmount, FeeTargetCode, map[wire.OutPoint]struct{}, []byte) error
	FeeTargets() ([]FeeTarget, FeeTargetCode)
	TxProposal(string, coin.SendAmount, FeeTargetCode, map[wire.OutPoint]struct{}, []byte) (
		coin.Amount, coin.Amount, coin.Amount, error)
	GetUnusedReceiveAddresses() []Address
	CanVerifyAddresses() (bool, bool, error)
	VerifyAddress(addressID string) (bool, error)
	ConvertToLegacyAddress(addressID string) (btcutil.Address, error)
	Keystores() *keystore.Keystores
	RateUpdater() *rates.RateUpdater
}

Interface is the API of a Account.

type Notifier

type Notifier interface {
	// Put adds the id to the 'unnotified' set, unless it is already in the 'seen' set.
	Put(id []byte) error
	// Delete removes the id from all sets.
	Delete(id []byte) error
	// UnnotifiedCount returns the number ids in the 'unnotified' set.
	UnnotifiedCount() (int, error)
	// MarkAllNotified moves all ids from the 'unnotified' set to the 'seen' set.
	MarkAllNotified() error
}

Notifier juggles transaction IDs for the purpose of notifications and unread counts.

type Transaction

type Transaction interface {
	// Fee is nil for a receiving tx. The fee is only displayed (and relevant) when sending funds
	// from the wallet.
	Fee() *coin.Amount

	// Time of confirmation. nil for unconfirmed tx or when the headers are not synced yet.
	Timestamp() *time.Time

	// ID is the tx ID.
	ID() string

	// NumConfirmations is the number of confirmations. 0 for unconfirmed.
	NumConfirmations() int

	// Status is the tx status. See TxStatus docs for details.
	Status() TxStatus

	// Type returns the type of the transaction.
	Type() TxType

	// Amount is always >0 and is the amount received or sent (not including the fee).
	Amount() coin.Amount

	// Addresses money was sent to / received on.
	Addresses() []AddressAndAmount
}

Transaction models a transaction with common transaction info.

type TxStatus

type TxStatus string

TxStatus is the the status of the tx and helps the frontend show the appropriate information.

const (
	// TxStatusPending means the tx is unconfirmed.
	TxStatusPending TxStatus = "pending"
	// TxStatusComplete means the tx is complete, depending on the number of confirmations needed
	// for the respective coin.
	TxStatusComplete TxStatus = "complete"
	// TxStatusFailed means the tx is confirmed but considered failed, e.g. a ETH transaction which
	TxStatusFailed TxStatus = "failed"
)

type TxType

type TxType string

TxType is a type of transaction. See the TxType* constants.

const (
	// TxTypeReceive is a tx which sends funds to our account.
	TxTypeReceive TxType = "receive"
	// TxTypeSend is a tx which sends funds out of our account.
	TxTypeSend TxType = "send"
	// TxTypeSendSelf is a tx from out account to our account.
	TxTypeSendSelf TxType = "sendSelf"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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