txs

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const CodecVersion = 0

Variables

This section is empty.

Functions

func IsSortedAndUniqueInitialStates

func IsSortedAndUniqueInitialStates(iss []*InitialState) bool

func IsSortedAndUniqueOperations

func IsSortedAndUniqueOperations(ops []*Operation, c codec.Manager) bool

func SortInitialStates

func SortInitialStates(iss []*InitialState)

func SortOperations

func SortOperations(ops []*Operation, c codec.Manager)

func SortOperationsWithSigners

func SortOperationsWithSigners(ops []*Operation, signers [][]*crypto.PrivateKeySECP256K1R, codec codec.Manager)

Types

type BaseTx

type BaseTx struct {
	axc.BaseTx `serialize:"true"`
}

BaseTx is the basis of all transactions.

func (*BaseTx) InitCtx

func (t *BaseTx) InitCtx(ctx *snow.Context)

func (*BaseTx) SyntacticVerify

func (t *BaseTx) SyntacticVerify(
	ctx *snow.Context,
	c codec.Manager,
	txFeeAssetID ids.ID,
	txFee uint64,
	_ uint64,
	_ int,
) error

func (*BaseTx) Visit

func (t *BaseTx) Visit(v Visitor) error

type CreateAssetTx

type CreateAssetTx struct {
	BaseTx       `serialize:"true"`
	Name         string          `serialize:"true" json:"name"`
	Symbol       string          `serialize:"true" json:"symbol"`
	Denomination byte            `serialize:"true" json:"denomination"`
	States       []*InitialState `serialize:"true" json:"initialStates"`
}

CreateAssetTx is a transaction that creates a new asset.

func (*CreateAssetTx) InitCtx

func (t *CreateAssetTx) InitCtx(ctx *snow.Context)

func (*CreateAssetTx) InitialStates

func (t *CreateAssetTx) InitialStates() []*InitialState

InitialStates track which virtual machines, and the initial state of these machines, this asset uses. The returned array should not be modified.

func (*CreateAssetTx) Sort

func (t *CreateAssetTx) Sort()

func (*CreateAssetTx) SyntacticVerify

func (t *CreateAssetTx) SyntacticVerify(
	ctx *snow.Context,
	c codec.Manager,
	txFeeAssetID ids.ID,
	_ uint64,
	txFee uint64,
	numFxs int,
) error

func (*CreateAssetTx) UTXOs

func (t *CreateAssetTx) UTXOs() []*axc.UTXO

UTXOs returns the UTXOs transaction is producing.

func (*CreateAssetTx) Visit

func (t *CreateAssetTx) Visit(v Visitor) error

type ExportTx

type ExportTx struct {
	BaseTx `serialize:"true"`

	// Which chain to send the funds to
	DestinationChain ids.ID `serialize:"true" json:"destinationChain"`

	// The outputs this transaction is sending to the other chain
	ExportedOuts []*axc.TransferableOutput `serialize:"true" json:"exportedOutputs"`
}

ExportTx is a transaction that exports an asset to another blockchain.

func (*ExportTx) InitCtx

func (t *ExportTx) InitCtx(ctx *snow.Context)

func (*ExportTx) SyntacticVerify

func (t *ExportTx) SyntacticVerify(
	ctx *snow.Context,
	c codec.Manager,
	txFeeAssetID ids.ID,
	txFee uint64,
	_ uint64,
	_ int,
) error

func (*ExportTx) Visit

func (t *ExportTx) Visit(v Visitor) error

type ImportTx

type ImportTx struct {
	BaseTx `serialize:"true"`

	// Which chain to consume the funds from
	SourceChain ids.ID `serialize:"true" json:"sourceChain"`

	// The inputs to this transaction
	ImportedIns []*axc.TransferableInput `serialize:"true" json:"importedInputs"`
}

ImportTx is a transaction that imports an asset from another blockchain.

func (*ImportTx) AssetIDs

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

AssetIDs returns the IDs of the assets this transaction depends on

func (*ImportTx) ConsumedAssetIDs

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

ConsumedAssetIDs returns the IDs of the assets this transaction consumes

func (*ImportTx) InputUTXOs

func (t *ImportTx) InputUTXOs() []*axc.UTXOID

InputUTXOs track which UTXOs this transaction is consuming.

func (*ImportTx) NumCredentials

func (t *ImportTx) NumCredentials() int

NumCredentials returns the number of expected credentials

func (*ImportTx) SyntacticVerify

func (t *ImportTx) SyntacticVerify(
	ctx *snow.Context,
	c codec.Manager,
	txFeeAssetID ids.ID,
	txFee uint64,
	_ uint64,
	numFxs int,
) error

SyntacticVerify that this import transaction is well-formed.

func (*ImportTx) Visit

func (t *ImportTx) Visit(v Visitor) error

type InitialState

type InitialState struct {
	FxIndex uint32         `serialize:"true" json:"fxIndex"`
	FxID    ids.ID         `serialize:"false" json:"fxID"`
	Outs    []verify.State `serialize:"true" json:"outputs"`
}

func (*InitialState) InitCtx

func (is *InitialState) InitCtx(ctx *snow.Context)

func (*InitialState) Sort

func (is *InitialState) Sort(c codec.Manager)

func (*InitialState) Verify

func (is *InitialState) Verify(c codec.Manager, numFxs int) error

type Operation

type Operation struct {
	axc.Asset `serialize:"true"`
	UTXOIDs   []*axc.UTXOID   `serialize:"true" json:"inputIDs"`
	FxID      ids.ID          `serialize:"false" json:"fxID"`
	Op        fxs.FxOperation `serialize:"true" json:"operation"`
}

func (*Operation) Verify

func (op *Operation) Verify(c codec.Manager) error

type OperationTx

type OperationTx struct {
	BaseTx `serialize:"true"`

	Ops []*Operation `serialize:"true" json:"operations"`
}

OperationTx is a transaction with no credentials.

func (*OperationTx) AssetIDs

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

AssetIDs returns the IDs of the assets this transaction depends on

func (*OperationTx) ConsumedAssetIDs

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

ConsumedAssetIDs returns the IDs of the assets this transaction consumes

func (*OperationTx) InitCtx

func (t *OperationTx) InitCtx(ctx *snow.Context)

func (*OperationTx) InputUTXOs

func (t *OperationTx) InputUTXOs() []*axc.UTXOID

func (*OperationTx) NumCredentials

func (t *OperationTx) NumCredentials() int

NumCredentials returns the number of expected credentials

func (*OperationTx) Operations

func (t *OperationTx) Operations() []*Operation

Operations track which ops this transaction is performing. The returned array should not be modified.

func (*OperationTx) SyntacticVerify

func (t *OperationTx) SyntacticVerify(
	ctx *snow.Context,
	c codec.Manager,
	txFeeAssetID ids.ID,
	txFee uint64,
	_ uint64,
	numFxs int,
) error

SyntacticVerify that this transaction is well-formed.

func (*OperationTx) UTXOs

func (t *OperationTx) UTXOs() []*axc.UTXO

UTXOs returns the UTXOs transaction is producing.

func (*OperationTx) Visit

func (t *OperationTx) Visit(v Visitor) error

type Parser

type Parser interface {
	Codec() codec.Manager
	GenesisCodec() codec.Manager

	Parse(bytes []byte) (*Tx, error)
	ParseGenesis(bytes []byte) (*Tx, error)

	InitializeTx(tx *Tx) error
	InitializeGenesisTx(tx *Tx) error
}

func NewCustomParser

func NewCustomParser(
	typeToFxIndex map[reflect.Type]int,
	clock *mockable.Clock,
	log logging.Logger,
	fxs []fxs.Fx,
) (Parser, error)

func NewParser

func NewParser(fxs []fxs.Fx) (Parser, error)

type Tx

type Tx struct {
	UnsignedTx `serialize:"true" json:"unsignedTx"`

	Creds []*fxs.FxCredential `serialize:"true" json:"credentials"` // The credentials of this transaction
}

Tx is the core operation that can be performed. The tx uses the UTXO model. Specifically, a txs inputs will consume previous txs outputs. A tx will be valid if the inputs have the authority to consume the outputs they are attempting to consume and the inputs consume sufficient state to produce the outputs.

func (*Tx) SignNFTFx

func (t *Tx) SignNFTFx(c codec.Manager, signers [][]*crypto.PrivateKeySECP256K1R) error

func (*Tx) SignPropertyFx

func (t *Tx) SignPropertyFx(c codec.Manager, signers [][]*crypto.PrivateKeySECP256K1R) error

func (*Tx) SignSECP256K1Fx

func (t *Tx) SignSECP256K1Fx(c codec.Manager, signers [][]*crypto.PrivateKeySECP256K1R) error

func (*Tx) SyntacticVerify

func (t *Tx) SyntacticVerify(
	ctx *snow.Context,
	c codec.Manager,
	txFeeAssetID ids.ID,
	txFee uint64,
	creationTxFee uint64,
	numFxs int,
) error

SyntacticVerify verifies that this transaction is well-formed.

type UnsignedTx

type UnsignedTx interface {
	snow.ContextInitializable

	Initialize(unsignedBytes, bytes []byte)
	ID() ids.ID
	UnsignedBytes() []byte
	Bytes() []byte

	ConsumedAssetIDs() ids.Set
	AssetIDs() ids.Set

	NumCredentials() int
	InputUTXOs() []*axc.UTXOID
	UTXOs() []*axc.UTXO

	SyntacticVerify(
		ctx *snow.Context,
		c codec.Manager,
		txFeeAssetID ids.ID,
		txFee uint64,
		creationTxFee uint64,
		numFxs int,
	) error
	Visit(visitor Visitor) error
}

type Visitor

type Visitor interface {
	BaseTx(*BaseTx) error
	CreateAssetTx(*CreateAssetTx) error
	OperationTx(*OperationTx) error
	ImportTx(*ImportTx) error
	ExportTx(*ExportTx) error
}

Allow vm to execute custom logic against the underlying transaction types.

Jump to

Keyboard shortcuts

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