Help us shape the future of Go! Take the 2026 Go Developer Survey

txs

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Overview

Package txs is a generated GoMock package.

Index

Constants

View Source
const CodecVersion = 0

CodecVersion is the current default codec version

Variables

View Source
var (
	ErrNilInitialState  = errors.New("nil initial state is not valid")
	ErrNilFxOutput      = errors.New("nil feature extension output is not valid")
	ErrOutputsNotSorted = errors.New("outputs not sorted")
	ErrUnknownFx        = errors.New("unknown feature extension")
)
View Source
var (
	ErrNilOperation              = errors.New("nil operation is not valid")
	ErrNilFxOperation            = errors.New("nil fx operation is not valid")
	ErrNotSortedAndUniqueUTXOIDs = errors.New("utxo IDs not sorted and unique")
)

Functions

func IsSortedAndUniqueOperations

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

func SortOperations

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

func SortOperationsWithSigners

func SortOperationsWithSigners(ops []*Operation, signers [][]*secp256k1.PrivateKey, codec codec.Manager)

Types

type BaseTx

type BaseTx struct {
	lux.BaseTx `serialize:"true"`
	// contains filtered or unexported fields
}

BaseTx is the basis of all transactions.

func (*BaseTx) Bytes

func (t *BaseTx) Bytes() []byte

func (*BaseTx) InitRuntime added in v1.24.12

func (t *BaseTx) InitRuntime(rt *runtime.Runtime)

func (*BaseTx) InitializeRuntime added in v1.24.12

func (t *BaseTx) InitializeRuntime(rt *runtime.Runtime) error

InitializeRuntime initializes the context for this transaction

func (*BaseTx) InitializeWithRuntime added in v1.24.12

func (tx *BaseTx) InitializeWithRuntime(rt *runtime.Runtime) error

InitializeWithRuntime initializes the transaction with Runtime

func (*BaseTx) InputIDs

func (t *BaseTx) InputIDs() set.Set[ids.ID]

func (*BaseTx) InputUTXOs added in v1.11.14

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

InputUTXOs returns the UTXOIDs this transaction is consuming

func (*BaseTx) NumCredentials added in v1.11.14

func (t *BaseTx) NumCredentials() int

NumCredentials returns the number of expected credentials

func (*BaseTx) SetBytes

func (t *BaseTx) SetBytes(bytes []byte)

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) InitRuntime added in v1.24.12

func (t *CreateAssetTx) InitRuntime(rt *runtime.Runtime)

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) InitializeRuntime added in v1.24.12

func (t *CreateAssetTx) InitializeRuntime(rt *runtime.Runtime) error

InitializeRuntime initializes the context for this transaction

func (*CreateAssetTx) InitializeWithRuntime added in v1.24.12

func (tx *CreateAssetTx) InitializeWithRuntime(rt *runtime.Runtime) error

InitializeWithRuntime initializes the transaction with Runtime

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 []*lux.TransferableOutput `serialize:"true" json:"exportedOutputs"`
}

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

func (*ExportTx) InitRuntime added in v1.24.12

func (t *ExportTx) InitRuntime(rt *runtime.Runtime)

func (*ExportTx) InitializeRuntime added in v1.24.12

func (t *ExportTx) InitializeRuntime(rt *runtime.Runtime) error

InitializeRuntime initializes the context for this transaction

func (*ExportTx) InitializeWithRuntime added in v1.24.12

func (tx *ExportTx) InitializeWithRuntime(rt *runtime.Runtime) error

InitializeWithRuntime initializes the transaction with Runtime

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 []*lux.TransferableInput `serialize:"true" json:"importedInputs"`
}

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

func (*ImportTx) InitRuntime added in v1.24.12

func (t *ImportTx) InitRuntime(rt *runtime.Runtime)

func (*ImportTx) InitializeRuntime added in v1.24.12

func (t *ImportTx) InitializeRuntime(rt *runtime.Runtime) error

InitializeRuntime initializes the context for this transaction

func (*ImportTx) InitializeWithRuntime added in v1.24.12

func (tx *ImportTx) InitializeWithRuntime(rt *runtime.Runtime) error

InitializeWithRuntime initializes the transaction with Runtime

func (*ImportTx) InputIDs

func (t *ImportTx) InputIDs() set.Set[ids.ID]

func (*ImportTx) InputUTXOs

func (t *ImportTx) InputUTXOs() []*lux.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) 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) Compare

func (is *InitialState) Compare(other *InitialState) int

func (*InitialState) InitRuntime added in v1.24.12

func (is *InitialState) InitRuntime(rt *runtime.Runtime)

func (*InitialState) Sort

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

func (*InitialState) Verify

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

type MockUnsignedTx added in v1.1.11

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

MockUnsignedTx is a mock of UnsignedTx interface.

func NewMockUnsignedTx added in v1.1.11

func NewMockUnsignedTx(ctrl *gomock.Controller) *MockUnsignedTx

NewMockUnsignedTx creates a new mock instance.

func (*MockUnsignedTx) Bytes added in v1.1.11

func (m *MockUnsignedTx) Bytes() []byte

Bytes mocks base method.

func (*MockUnsignedTx) EXPECT added in v1.1.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockUnsignedTx) InitRuntime added in v1.24.12

func (m *MockUnsignedTx) InitRuntime(arg0 context.Context)

InitRuntime mocks base method.

func (*MockUnsignedTx) InitializeRuntime added in v1.24.12

func (m *MockUnsignedTx) InitializeRuntime(arg0 context.Context) error

InitializeRuntime mocks base method.

func (*MockUnsignedTx) InputIDs added in v1.1.11

func (m *MockUnsignedTx) InputIDs() set.Set[ids.ID]

InputIDs mocks base method.

func (*MockUnsignedTx) InputUTXOs added in v1.1.11

func (m *MockUnsignedTx) InputUTXOs() []*lux.UTXOID

InputUTXOs mocks base method.

func (*MockUnsignedTx) NumCredentials added in v1.1.11

func (m *MockUnsignedTx) NumCredentials() int

NumCredentials mocks base method.

func (*MockUnsignedTx) SetBytes added in v1.1.11

func (m *MockUnsignedTx) SetBytes(unsignedBytes []byte)

SetBytes mocks base method.

func (*MockUnsignedTx) Visit added in v1.1.11

func (m *MockUnsignedTx) Visit(visitor Visitor) error

Visit mocks base method.

type MockUnsignedTxMockRecorder added in v1.1.11

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

MockUnsignedTxMockRecorder is the mock recorder for MockUnsignedTx.

func (*MockUnsignedTxMockRecorder) Bytes added in v1.1.11

func (mr *MockUnsignedTxMockRecorder) Bytes() *gomock.Call

Bytes indicates an expected call of Bytes.

func (*MockUnsignedTxMockRecorder) InitRuntime added in v1.24.12

func (mr *MockUnsignedTxMockRecorder) InitRuntime(arg0 any) *gomock.Call

InitRuntime indicates an expected call of InitRuntime.

func (*MockUnsignedTxMockRecorder) InitializeRuntime added in v1.24.12

func (mr *MockUnsignedTxMockRecorder) InitializeRuntime(arg0 any) *gomock.Call

InitializeRuntime indicates an expected call of InitializeRuntime.

func (*MockUnsignedTxMockRecorder) InputIDs added in v1.1.11

func (mr *MockUnsignedTxMockRecorder) InputIDs() *gomock.Call

InputIDs indicates an expected call of InputIDs.

func (*MockUnsignedTxMockRecorder) InputUTXOs added in v1.1.11

func (mr *MockUnsignedTxMockRecorder) InputUTXOs() *gomock.Call

InputUTXOs indicates an expected call of InputUTXOs.

func (*MockUnsignedTxMockRecorder) NumCredentials added in v1.1.11

func (mr *MockUnsignedTxMockRecorder) NumCredentials() *gomock.Call

NumCredentials indicates an expected call of NumCredentials.

func (*MockUnsignedTxMockRecorder) SetBytes added in v1.1.11

func (mr *MockUnsignedTxMockRecorder) SetBytes(unsignedBytes any) *gomock.Call

SetBytes indicates an expected call of SetBytes.

func (*MockUnsignedTxMockRecorder) Visit added in v1.1.11

func (mr *MockUnsignedTxMockRecorder) Visit(visitor any) *gomock.Call

Visit indicates an expected call of Visit.

type Operation

type Operation struct {
	lux.Asset `serialize:"true"`
	UTXOIDs   []*lux.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() error

type OperationTx

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

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

OperationTx is a transaction with no credentials.

func (*OperationTx) InitRuntime added in v1.24.12

func (t *OperationTx) InitRuntime(rt *runtime.Runtime)

func (*OperationTx) InitializeRuntime added in v1.24.12

func (t *OperationTx) InitializeRuntime(rt *runtime.Runtime) error

InitializeRuntime initializes the context for this transaction

func (*OperationTx) InitializeWithRuntime added in v1.24.12

func (tx *OperationTx) InitializeWithRuntime(rt *runtime.Runtime) error

InitializeWithRuntime initializes the transaction with Runtime

func (*OperationTx) InputIDs

func (t *OperationTx) InputIDs() set.Set[ids.ID]

func (*OperationTx) InputUTXOs

func (t *OperationTx) InputUTXOs() []*lux.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) Visit

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

type Parser

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

	CodecRegistry() codec.Registry
	GenesisCodecRegistry() codec.Registry

	ParseTx(bytes []byte) (*Tx, error)
	ParseGenesisTx(bytes []byte) (*Tx, error)
}

func NewCustomParser

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

func NewParser

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

type Tx

type Tx struct {
	Unsigned UnsignedTx          `serialize:"true" json:"unsignedTx"`
	Creds    []*fxs.FxCredential `serialize:"true" json:"credentials"` // The credentials of this transaction

	TxID ids.ID `json:"id"`
	// contains filtered or unexported fields
}

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) Bytes

func (t *Tx) Bytes() []byte

Bytes returns the binary representation of this tx

func (*Tx) GossipID

func (t *Tx) GossipID() ids.ID

GossipID returns the unique ID that this tx should use for mempool gossip

func (*Tx) ID

func (t *Tx) ID() ids.ID

ID returns the unique ID of this tx

func (*Tx) Initialize

func (t *Tx) Initialize(c codec.Manager) error

func (*Tx) InputIDs

func (t *Tx) InputIDs() set.Set[ids.ID]

func (*Tx) SetBytes

func (t *Tx) SetBytes(unsignedBytes, signedBytes []byte)

func (*Tx) SignNFTFx

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

func (*Tx) SignPropertyFx

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

func (*Tx) SignSECP256K1Fx

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

func (*Tx) Size

func (t *Tx) Size() int

func (*Tx) UTXOs

func (t *Tx) UTXOs() []*lux.UTXO

UTXOs returns the UTXOs transaction is producing.

type UnsignedTx

type UnsignedTx interface {
	SetBytes(unsignedBytes []byte)
	Bytes() []byte

	InputIDs() set.Set[ids.ID]

	NumCredentials() int
	InputUTXOs() []*lux.UTXOID

	// Visit calls [visitor] with this transaction's concrete type
	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.

Directories

Path Synopsis
Package mempool is a generated GoMock package.
Package mempool is a generated GoMock package.
mempoolmock
Package mempoolmock is a generated GoMock package.
Package mempoolmock is a generated GoMock package.
Package txsmock is a generated GoMock package.
Package txsmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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