Documentation
¶
Overview ¶
Package txs is the X-chain (xvm) transaction package for the luxfi/node binary. It owns the native-ZAP struct-is-wire tx codec: the signed-tx envelope (wire.SignedTx), the per-type unsigned bodies keyed by a 1-byte xkind discriminator, and the per-fx Initial-State / Operation accessors the X-VM uses to build, sign, and parse on-chain transactions.
There is no pcodecs.Manager, no linearcodec, and no reflection-driven slot map. Each tx type serializes itself directly onto a github.com/luxfi/zap buffer; polymorphic fx primitives (outputs, inputs, operations, credentials) name themselves on the wire via their (TypeKind, ShapeKind) envelope and are reconstructed by envelope dispatch (fxwire.go).
Package txs is a generated GoMock package.
Index ¶
- Variables
- func IsSortedAndUniqueOperations(ops []*Operation) bool
- func SortOperations(ops []*Operation)
- func SortOperationsWithSigners(ops []*Operation, signers [][]*secp256k1.PrivateKey)
- func UnsignedBytes(u UnsignedTx) ([]byte, error)
- type BaseTx
- func (t *BaseTx) Bytes() []byte
- func (t *BaseTx) InitRuntime(rt *runtime.Runtime)
- func (t *BaseTx) InitializeRuntime(rt *runtime.Runtime) error
- func (t *BaseTx) InitializeWithRuntime(rt *runtime.Runtime) error
- func (t *BaseTx) InputIDs() set.Set[ids.ID]
- func (t *BaseTx) InputUTXOs() []*lux.UTXOID
- func (t *BaseTx) NumCredentials() int
- func (t *BaseTx) SetBytes(bytes []byte)
- func (t *BaseTx) Visit(v Visitor) error
- type CreateAssetTx
- func (t *CreateAssetTx) InitRuntime(rt *runtime.Runtime)
- func (t *CreateAssetTx) InitialStates() []*InitialState
- func (t *CreateAssetTx) InitializeRuntime(rt *runtime.Runtime) error
- func (t *CreateAssetTx) InitializeWithRuntime(rt *runtime.Runtime) error
- func (t *CreateAssetTx) Visit(v Visitor) error
- type ExportTx
- type ImportTx
- func (t *ImportTx) InitRuntime(rt *runtime.Runtime)
- func (t *ImportTx) InitializeRuntime(rt *runtime.Runtime) error
- func (t *ImportTx) InitializeWithRuntime(rt *runtime.Runtime) error
- func (t *ImportTx) InputIDs() set.Set[ids.ID]
- func (t *ImportTx) InputUTXOs() []*lux.UTXOID
- func (t *ImportTx) NumCredentials() int
- func (t *ImportTx) Visit(v Visitor) error
- type InitialState
- type MockUnsignedTx
- func (m *MockUnsignedTx) Bytes() []byte
- func (m *MockUnsignedTx) EXPECT() *MockUnsignedTxMockRecorder
- func (m *MockUnsignedTx) InitRuntime(arg0 context.Context)
- func (m *MockUnsignedTx) InitializeRuntime(arg0 context.Context) error
- func (m *MockUnsignedTx) InputIDs() set.Set[ids.ID]
- func (m *MockUnsignedTx) InputUTXOs() []*lux.UTXOID
- func (m *MockUnsignedTx) NumCredentials() int
- func (m *MockUnsignedTx) SetBytes(unsignedBytes []byte)
- func (m *MockUnsignedTx) Visit(visitor Visitor) error
- type MockUnsignedTxMockRecorder
- func (mr *MockUnsignedTxMockRecorder) Bytes() *gomock.Call
- func (mr *MockUnsignedTxMockRecorder) InitRuntime(arg0 any) *gomock.Call
- func (mr *MockUnsignedTxMockRecorder) InitializeRuntime(arg0 any) *gomock.Call
- func (mr *MockUnsignedTxMockRecorder) InputIDs() *gomock.Call
- func (mr *MockUnsignedTxMockRecorder) InputUTXOs() *gomock.Call
- func (mr *MockUnsignedTxMockRecorder) NumCredentials() *gomock.Call
- func (mr *MockUnsignedTxMockRecorder) SetBytes(unsignedBytes any) *gomock.Call
- func (mr *MockUnsignedTxMockRecorder) Visit(visitor any) *gomock.Call
- type Operation
- type OperationTx
- func (t *OperationTx) InitRuntime(rt *runtime.Runtime)
- func (t *OperationTx) InitializeRuntime(rt *runtime.Runtime) error
- func (t *OperationTx) InitializeWithRuntime(rt *runtime.Runtime) error
- func (t *OperationTx) InputIDs() set.Set[ids.ID]
- func (t *OperationTx) InputUTXOs() []*lux.UTXOID
- func (t *OperationTx) NumCredentials() int
- func (t *OperationTx) Operations() []*Operation
- func (t *OperationTx) Visit(v Visitor) error
- type Parser
- type Tx
- func (t *Tx) Bytes() []byte
- func (t *Tx) GossipID() ids.ID
- func (t *Tx) ID() ids.ID
- func (t *Tx) Initialize() error
- func (t *Tx) InputIDs() set.Set[ids.ID]
- func (t *Tx) SetBytes(unsignedBytes, signedBytes []byte)
- func (t *Tx) SignNFTFx(signers [][]*secp256k1.PrivateKey) error
- func (t *Tx) SignPropertyFx(signers [][]*secp256k1.PrivateKey) error
- func (t *Tx) SignSECP256K1Fx(signers [][]*secp256k1.PrivateKey) error
- func (t *Tx) Size() int
- func (t *Tx) UTXOs() []*lux.UTXO
- type UnsignedTx
- type Visitor
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func SortOperations ¶
func SortOperations(ops []*Operation)
func SortOperationsWithSigners ¶
func SortOperationsWithSigners(ops []*Operation, signers [][]*secp256k1.PrivateKey)
func UnsignedBytes ¶ added in v1.36.4
func UnsignedBytes(u UnsignedTx) ([]byte, error)
UnsignedBytes returns the canonical native-ZAP wire bytes of an unsigned tx, serializing (and caching) them on first use. This is the signing target — every fx signature is computed over hash(unsignedBytes).
Types ¶
type BaseTx ¶
BaseTx is the basis of all transactions. It carries the multi-asset spending envelope (NetworkID/BlockchainID/Outs/Ins/Memo) as an embedded lux.BaseTx — X-Chain is a universal multi-fx settlement layer, so Outs/Ins hold arbitrary fx primitives, not the fixed secp256k1 stride the P-Chain uses. The struct is the source of truth; Bytes() is the cached native-ZAP wire encoding.
Wire (unsigned): zap object { xkind@0, baseTxEnvelope@8 } where the envelope is a wire.XVMBaseTx (each Out/In an fx-typed TransferableOut/In envelope).
func (*BaseTx) InitRuntime ¶ added in v1.24.12
func (*BaseTx) InitializeRuntime ¶ added in v1.24.12
InitializeRuntime initializes the context for this transaction
func (*BaseTx) InitializeWithRuntime ¶ added in v1.24.12
InitializeWithRuntime initializes the transaction with Runtime
func (*BaseTx) InputUTXOs ¶ added in v1.11.14
InputUTXOs returns the UTXOIDs this transaction is consuming
func (*BaseTx) NumCredentials ¶ added in v1.11.14
NumCredentials returns the number of expected credentials
type CreateAssetTx ¶
type CreateAssetTx struct {
BaseTx
Name string `json:"name"`
Symbol string `json:"symbol"`
Denomination byte `json:"denomination"`
States []*InitialState `json:"initialStates"`
}
CreateAssetTx is a transaction that creates a new asset.
Wire (unsigned): the shared { xkind@0, baseTxEnvelope@8 } prefix, then Name@16 / Symbol@24 (text) + Denomination@32 (u8) + the InitialStates as a packed (length list @36, blob @44) of self-delimiting InitialState objects.
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 (t *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
// Which chain to send the funds to
DestinationChain ids.ID `json:"destinationChain"`
// The outputs this transaction is sending to the other chain
ExportedOuts []*lux.TransferableOutput `json:"exportedOutputs"`
}
ExportTx is a transaction that exports an asset to another blockchain.
Wire (unsigned): the shared { xkind@0, baseTxEnvelope@8 } prefix, then DestinationChain@16 (32B) + the exported outputs as a packed (length list @48, blob @56) of self-delimiting wire TransferableOut envelopes.
func (*ExportTx) InitRuntime ¶ added in v1.24.12
func (*ExportTx) InitializeRuntime ¶ added in v1.24.12
InitializeRuntime initializes the context for this transaction
func (*ExportTx) InitializeWithRuntime ¶ added in v1.24.12
InitializeWithRuntime initializes the transaction with Runtime
type ImportTx ¶
type ImportTx struct {
BaseTx
// Which chain to consume the funds from
SourceChain ids.ID `json:"sourceChain"`
// The inputs to this transaction
ImportedIns []*lux.TransferableInput `json:"importedInputs"`
}
ImportTx is a transaction that imports an asset from another blockchain.
Wire (unsigned): the shared { xkind@0, baseTxEnvelope@8 } prefix, then SourceChain@16 (32B) + the imported inputs as a packed (length list @48, blob @56) of self-delimiting wire TransferableIn envelopes.
func (*ImportTx) InitRuntime ¶ added in v1.24.12
func (*ImportTx) InitializeRuntime ¶ added in v1.24.12
InitializeRuntime initializes the context for this transaction
func (*ImportTx) InitializeWithRuntime ¶ added in v1.24.12
InitializeWithRuntime initializes the transaction with Runtime
func (*ImportTx) InputUTXOs ¶
InputUTXOs track which UTXOs this transaction is consuming.
func (*ImportTx) NumCredentials ¶
NumCredentials returns the number of expected credentials
type InitialState ¶
type InitialState struct {
FxIndex uint32 `json:"fxIndex"`
FxID ids.ID `json:"fxID"`
Outs []verify.State `json:"outputs"`
}
InitialState is the per-fx genesis state a CreateAssetTx installs: an fx index plus that fx's initial output set. Outs is a heterogeneous slice of fx state outputs, each serialized as its own (TypeKind, ShapeKind, ZAP) wire envelope — the FxID is recovered from the envelope's TypeKind, so it is not stored on the wire.
Wire: zap object { FxIndex@0 (u32), Outs (length list @4, blob @12) }.
func (*InitialState) Bytes ¶ added in v1.36.4
func (is *InitialState) Bytes() ([]byte, error)
Bytes serializes the InitialState to its self-delimiting native-ZAP wire object. Each output is its fx primitive's own wire envelope.
func (*InitialState) Compare ¶
func (is *InitialState) Compare(other *InitialState) int
func (*InitialState) InitRuntime ¶ added in v1.24.12
func (is *InitialState) InitRuntime(*runtime.Runtime)
func (*InitialState) Sort ¶
func (is *InitialState) Sort()
func (*InitialState) Verify ¶
func (is *InitialState) Verify(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
func (m *MockUnsignedTx) EXPECT() *MockUnsignedTxMockRecorder
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.
type Operation ¶
type Operation struct {
lux.Asset
UTXOIDs []*lux.UTXOID `json:"inputIDs"`
FxID ids.ID `json:"fxID"`
Op fxs.FxOperation `json:"operation"`
}
Operation runs a single fx operation (mint / NFT transfer / property burn) over a set of consumed UTXOs of a given asset.
Wire: zap object { Asset@0 (32B), UTXOIDs@32 (36B-stride list), Op@40 (the fx operation's own (TypeKind, ShapeKind, ZAP) envelope) }. FxID is recovered from the Op envelope's TypeKind, so it is not stored on the wire.
type OperationTx ¶
OperationTx is a transaction that runs a set of fx operations over existing UTXOs (mint / NFT transfer / property burn ...).
Wire (unsigned): the shared { xkind@0, baseTxEnvelope@8 } prefix, then the Operations as a packed (length list @16, blob @24) of self-delimiting Operation objects.
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 (t *OperationTx) InitializeWithRuntime(rt *runtime.Runtime) error
InitializeWithRuntime initializes the transaction with Runtime
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 {
ParseTx(bytes []byte) (*Tx, error)
ParseGenesisTx(bytes []byte) (*Tx, error)
}
func NewCustomParser ¶
type Tx ¶
type Tx struct {
Unsigned UnsignedTx `json:"unsignedTx"`
Creds []*fxs.FxCredential `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.
A signed tx is a wire.SignedTx envelope: the unsigned tx bytes (which carry the xkind discriminator at offset 0) followed by a packed list of fx credential envelopes. There is no codec.
func Parse ¶ added in v1.36.4
Parse decodes a signed X-chain tx from its wire bytes. It is the codec-free, parser-instance-free entry point used by the block layer and any consumer holding raw tx bytes; fx credential dispatch is envelope-based (stateless).
func (*Tx) Initialize ¶
Initialize binds the tx's cached bytes and TxID from its Unsigned tx and Creds. Used for txs built fresh in-process (wallet, block builder).
func (*Tx) SignPropertyFx ¶
func (t *Tx) SignPropertyFx(signers [][]*secp256k1.PrivateKey) error
func (*Tx) SignSECP256K1Fx ¶
func (t *Tx) SignSECP256K1Fx(signers [][]*secp256k1.PrivateKey) error
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
}
func ParseUnsignedTx ¶ added in v1.36.4
func ParseUnsignedTx(unsignedBytes []byte) (UnsignedTx, error)
ParseUnsignedTx decodes native-ZAP unsigned-tx bytes (as produced by UnsignedBytes) back into the concrete UnsignedTx, dispatching on the xkind discriminator. Used by the X-Chain genesis wire to re-hydrate each GenesisAsset's embedded CreateAssetTx.
Source Files
¶
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. |