avax

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: BSD-3-Clause Imports: 17 Imported by: 43

Documentation

Index

Constants

View Source
const MaxMemoSize = 256

MaxMemoSize is the maximum number of bytes in the memo field

Variables

This section is empty.

Functions

func IsSortedAndUniqueTransferableInputs

func IsSortedAndUniqueTransferableInputs(ins []*TransferableInput) bool

IsSortedAndUniqueTransferableInputs ...

func IsSortedAndUniqueTransferableInputsWithSigners

func IsSortedAndUniqueTransferableInputsWithSigners(ins []*TransferableInput, signers [][]*crypto.PrivateKeySECP256K1R) bool

IsSortedAndUniqueTransferableInputsWithSigners returns true if the inputs are sorted and unique

func IsSortedAndUniqueUTXOIDs

func IsSortedAndUniqueUTXOIDs(utxos []*UTXOID) bool

IsSortedAndUniqueUTXOIDs ...

func IsSortedTransferableOutputs

func IsSortedTransferableOutputs(outs []*TransferableOutput, c codec.Manager) bool

IsSortedTransferableOutputs returns true if output objects are sorted

func SortTransferableInputs

func SortTransferableInputs(ins []*TransferableInput)

SortTransferableInputs ...

func SortTransferableInputsWithSigners

func SortTransferableInputsWithSigners(ins []*TransferableInput, signers [][]*crypto.PrivateKeySECP256K1R)

SortTransferableInputsWithSigners sorts the inputs and signers based on the input's utxo ID

func SortTransferableOutputs

func SortTransferableOutputs(outs []*TransferableOutput, c codec.Manager)

SortTransferableOutputs sorts output objects

func SortUTXOIDs

func SortUTXOIDs(utxos []*UTXOID)

SortUTXOIDs ...

func UniqueID

func UniqueID(id ids.ID, prefix uint64, cacher cache.Cacher) ids.ID

UniqueID returns a unique identifier

func VerifyTx

func VerifyTx(
	feeAmount uint64,
	feeAssetID ids.ID,
	allIns [][]*TransferableInput,
	allOuts [][]*TransferableOutput,
	c codec.Manager,
) error

VerifyTx verifies that the inputs and outputs flowcheck, including a fee. Additionally, this verifies that the inputs and outputs are sorted.

Types

type Addressable

type Addressable interface {
	Addresses() [][]byte
}

Addressable is the interface a feature extension must provide to be able to be tracked as a part of the utxo set for a set of addresses

type Amounter

type Amounter interface {
	// Amount returns how much value this element represents of the asset in its
	// transaction.
	Amount() uint64
}

Amounter is a data structure that has an amount of something associated with it

type Asset

type Asset struct {
	ID ids.ID `serialize:"true" json:"assetID"`
}

Asset ...

func (*Asset) AssetID

func (asset *Asset) AssetID() ids.ID

AssetID returns the ID of the contained asset

func (*Asset) Verify

func (asset *Asset) Verify() error

Verify implements the verify.Verifiable interface

type BaseTx

type BaseTx struct {
	Metadata

	NetworkID    uint32                `serialize:"true" json:"networkID"`    // ID of the network this chain lives on
	BlockchainID ids.ID                `serialize:"true" json:"blockchainID"` // ID of the chain on which this transaction exists (prevents replay attacks)
	Outs         []*TransferableOutput `serialize:"true" json:"outputs"`      // The outputs of this transaction
	Ins          []*TransferableInput  `serialize:"true" json:"inputs"`       // The inputs to this transaction
	Memo         []byte                `serialize:"true" json:"memo"`         // Memo field contains arbitrary bytes, up to maxMemoSize
}

BaseTx is the basis of all standard transactions.

func (*BaseTx) AssetIDs

func (t *BaseTx) AssetIDs() ids.Set

AssetIDs returns the IDs of the assets this transaction depends on

func (*BaseTx) ConsumedAssetIDs

func (t *BaseTx) ConsumedAssetIDs() ids.Set

ConsumedAssetIDs returns the IDs of the assets this transaction consumes

func (*BaseTx) InputUTXOs

func (t *BaseTx) InputUTXOs() []*UTXOID

InputUTXOs track which UTXOs this transaction is consuming.

func (*BaseTx) MetadataVerify

func (t *BaseTx) MetadataVerify(ctx *snow.Context) error

MetadataVerify ensures that transaction metadata is valid

func (*BaseTx) NumCredentials

func (t *BaseTx) NumCredentials() int

NumCredentials returns the number of expected credentials

func (*BaseTx) UTXOs

func (t *BaseTx) UTXOs() []*UTXO

UTXOs returns the UTXOs transaction is producing.

type FlowChecker

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

FlowChecker ...

func NewFlowChecker

func NewFlowChecker() *FlowChecker

NewFlowChecker ...

func (*FlowChecker) Consume

func (fc *FlowChecker) Consume(assetID ids.ID, amount uint64)

Consume ...

func (*FlowChecker) Produce

func (fc *FlowChecker) Produce(assetID ids.ID, amount uint64)

Produce ...

func (*FlowChecker) Verify

func (fc *FlowChecker) Verify() error

Verify ...

type Metadata

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

Metadata ...

func (*Metadata) Bytes

func (md *Metadata) Bytes() []byte

Bytes returns the binary representation of this data

func (*Metadata) ID

func (md *Metadata) ID() ids.ID

ID returns the unique ID of this data

func (*Metadata) Initialize

func (md *Metadata) Initialize(unsignedBytes, bytes []byte)

Initialize set the bytes and ID

func (*Metadata) UnsignedBytes

func (md *Metadata) UnsignedBytes() []byte

UnsignedBytes returns the unsigned binary representation of this data

func (*Metadata) Verify

func (md *Metadata) Verify() error

Verify implements the verify.Verifiable interface

type PrefixedState

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

PrefixedState wraps a state object. By prefixing the state, there will be no collisions between different types of objects that have the same hash.

func NewPrefixedState

func NewPrefixedState(
	db database.Database,
	genesisCodec,
	codec codec.Manager,
	myChain,
	peerChain ids.ID,
) *PrefixedState

NewPrefixedState ...

func (*PrefixedState) FundUTXO

func (s *PrefixedState) FundUTXO(utxo *UTXO) error

FundUTXO adds the provided utxo to the database

func (*PrefixedState) Funds

func (s *PrefixedState) Funds(addr []byte, start ids.ID, limit int) ([]ids.ID, error)

Funds returns the mapping from the 32 byte representation of an address to a list of utxo IDs that reference the address. All returned UTXO IDs have IDs greater than [start]. (ids.Empty is the "least" ID.) Returns at most [limit] UTXO IDs.

func (*PrefixedState) SpendUTXO

func (s *PrefixedState) SpendUTXO(utxoID ids.ID) error

SpendUTXO consumes the provided utxo.

func (*PrefixedState) UTXO

func (s *PrefixedState) UTXO(id ids.ID) (*UTXO, error)

UTXO attempts to load a utxo from storage.

type State

type State struct {
	Cache        cache.Cacher
	DB           database.Database
	GenesisCodec codec.Manager
	Codec        codec.Manager
}

State is a thin wrapper around a database to provide, caching, serialization, and de-serialization.

func (*State) AddID

func (s *State) AddID(key []byte, id ids.ID) error

AddID saves an ID to the prefixed database

func (*State) IDs

func (s *State) IDs(key []byte, start []byte, limit int) ([]ids.ID, error)

IDs returns the slice of IDs associated with [id], starting after [start]. If start is ids.Empty, starts at beginning. Returns at most [limit] IDs.

func (*State) RemoveID

func (s *State) RemoveID(key []byte, id ids.ID) error

RemoveID removes an ID from the prefixed database

func (*State) SetStatus

func (s *State) SetStatus(id ids.ID, status choices.Status) error

SetStatus saves a status in storage.

func (*State) SetUTXO

func (s *State) SetUTXO(id ids.ID, utxo *UTXO) error

SetUTXO saves the provided utxo to storage.

func (*State) Status

func (s *State) Status(id ids.ID) (choices.Status, error)

Status returns a status from storage.

func (*State) UTXO

func (s *State) UTXO(id ids.ID) (*UTXO, error)

UTXO attempts to load a utxo from storage.

type TestAddressable

type TestAddressable struct {
	TestTransferable `serialize:"true"`

	Addrs [][]byte `serialize:"true"`
}

TestAddressable ...

func (*TestAddressable) Addresses

func (a *TestAddressable) Addresses() [][]byte

Addresses ...

type TestTransferable

type TestTransferable struct {
	TestVerifiable

	Val uint64 `serialize:"true"`
}

TestTransferable ...

func (*TestTransferable) Amount

func (t *TestTransferable) Amount() uint64

Amount ...

type TestVerifiable

type TestVerifiable struct{ Err error }

TestVerifiable ...

func (*TestVerifiable) Verify

func (v *TestVerifiable) Verify() error

Verify ...

func (*TestVerifiable) VerifyState

func (v *TestVerifiable) VerifyState() error

VerifyState ...

type TransferableIn

type TransferableIn interface {
	verify.Verifiable
	Amounter
}

TransferableIn is the interface a feature extension must provide to transfer value between features extensions.

type TransferableInput

type TransferableInput struct {
	UTXOID `serialize:"true"`
	Asset  `serialize:"true"`

	In TransferableIn `serialize:"true" json:"input"`
}

TransferableInput ...

func (*TransferableInput) Input

func (in *TransferableInput) Input() TransferableIn

Input returns the feature extension input that this Input is using.

func (*TransferableInput) Verify

func (in *TransferableInput) Verify() error

Verify implements the verify.Verifiable interface

type TransferableOut

type TransferableOut interface {
	verify.State
	Amounter
}

TransferableOut is the interface a feature extension must provide to transfer value between features extensions.

type TransferableOutput

type TransferableOutput struct {
	Asset `serialize:"true"`

	Out TransferableOut `serialize:"true" json:"output"`
}

TransferableOutput ...

func (*TransferableOutput) Output

func (out *TransferableOutput) Output() TransferableOut

Output returns the feature extension output that this Output is using.

func (*TransferableOutput) Verify

func (out *TransferableOutput) Verify() error

Verify implements the verify.Verifiable interface

type UTXO

type UTXO struct {
	UTXOID `serialize:"true"`
	Asset  `serialize:"true"`

	Out verify.State `serialize:"true" json:"output"`
}

UTXO ...

func (*UTXO) Verify

func (utxo *UTXO) Verify() error

Verify implements the verify.Verifiable interface

type UTXOID

type UTXOID struct {
	// Serialized:
	TxID        ids.ID `serialize:"true" json:"txID"`
	OutputIndex uint32 `serialize:"true" json:"outputIndex"`

	// Symbol is false if the UTXO should be part of the DB
	Symbol bool `json:"-"`
	// contains filtered or unexported fields
}

UTXOID ...

func (*UTXOID) InputID

func (utxo *UTXOID) InputID() ids.ID

InputID returns a unique ID of the UTXO that this input is spending

func (*UTXOID) InputSource

func (utxo *UTXOID) InputSource() (ids.ID, uint32)

InputSource returns the source of the UTXO that this input is spending

func (*UTXOID) Symbolic

func (utxo *UTXOID) Symbolic() bool

Symbolic returns if this is the ID of a UTXO in the DB, or if it is a symbolic input

func (*UTXOID) Verify

func (utxo *UTXOID) Verify() error

Verify implements the verify.Verifiable interface

Jump to

Keyboard shortcuts

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