Documentation
¶
Index ¶
- Constants
- Variables
- func IsSortedAndUniqueOperations(ops []*Operation, c codec.Manager) bool
- func SortOperations(ops []*Operation, c codec.Manager)
- func SortOperationsWithSigners(ops []*Operation, signers [][]*secp256k1.PrivateKey, codec codec.Manager)
- type BaseTx
- type BurnTx
- type CreateAssetTx
- type ExportTx
- type ImportTx
- type InitialState
- type MintTx
- type NFTTransferTx
- func (t *NFTTransferTx) InitCtx(ctx *consensus.Context)
- func (t *NFTTransferTx) SemanticVerify(vm VM, tx UnsignedTx, creds []verify.Verifiable) error
- func (t *NFTTransferTx) SyntacticVerify(ctx *consensus.Context, c codec.Manager, txFeeAssetID ids.ID, txFee uint64, ...) error
- func (t *NFTTransferTx) Visit(v Visitor) error
- type Operation
- type OperationTx
- 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(c codec.Manager) error
- func (t *Tx) InputIDs() set.Set[ids.ID]
- func (t *Tx) SetBytes(unsignedBytes, signedBytes []byte)
- func (t *Tx) SignNFTFx(c codec.Manager, signers [][]*secp256k1.PrivateKey) error
- func (t *Tx) SignPropertyFx(c codec.Manager, signers [][]*secp256k1.PrivateKey) error
- func (t *Tx) SignSECP256K1Fx(c codec.Manager, signers [][]*secp256k1.PrivateKey) error
- func (t *Tx) Size() int
- func (t *Tx) UTXOs() []*lux.UTXO
- type UnsignedTx
- type Visitor
Constants ¶
const CodecVersion = 0
CodecVersion is the current default codec version
Variables ¶
var ( ErrInvalidDestChain = errors.New("invalid destination chain") ErrInvalidDestAddress = errors.New("invalid destination address") ErrInvalidAmount = errors.New("invalid burn amount") )
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") )
var ( ErrInvalidSourceChain = errors.New("invalid source chain") ErrInvalidBurnProof = errors.New("invalid burn proof") ErrInvalidMintAmount = errors.New("invalid mint amount") )
Functions ¶
func SortOperations ¶
func SortOperationsWithSigners ¶
func SortOperationsWithSigners(ops []*Operation, signers [][]*secp256k1.PrivateKey, codec codec.Manager)
Types ¶
type BurnTx ¶
type BurnTx struct {
// Base transaction fields
BaseTx `serialize:"true"`
// Asset being burned
AssetID ids.ID `serialize:"true" json:"assetID"`
// Amount to burn
Amount uint64 `serialize:"true" json:"amount"`
// Destination chain ID
DestChain ids.ID `serialize:"true" json:"destChain"`
// Destination address (chain-specific format)
DestAddress []byte `serialize:"true" json:"destAddress"`
// Optional metadata for the transfer
TeleportData []byte `serialize:"true" json:"teleportData"`
}
BurnTx burns assets on X-Chain for cross-chain transfers via Teleport Protocol
func (*BurnTx) SemanticVerify ¶ added in v1.13.21
func (t *BurnTx) SemanticVerify(vm VM, tx UnsignedTx, creds []verify.Verifiable) error
func (*BurnTx) SyntacticVerify ¶ added in v1.13.21
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 *consensus.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) 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.
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) 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 `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) InitCtx ¶
func (is *InitialState) InitCtx(ctx *consensus.Context)
func (*InitialState) Sort ¶
func (is *InitialState) Sort(c codec.Manager)
type MintTx ¶
type MintTx struct {
// Base transaction fields
BaseTx `serialize:"true"`
// Asset being minted
AssetID ids.ID `serialize:"true" json:"assetID"`
// Amount to mint
Amount uint64 `serialize:"true" json:"amount"`
// Source chain ID
SourceChain ids.ID `serialize:"true" json:"sourceChain"`
// Proof of burn on source chain
BurnProof []byte `serialize:"true" json:"burnProof"`
// MPC signatures authorizing the mint
MPCSignatures [][]byte `serialize:"true" json:"mpcSignatures"`
}
MintTx mints assets on X-Chain from cross-chain transfers via Teleport Protocol
func (*MintTx) SemanticVerify ¶ added in v1.13.21
func (t *MintTx) SemanticVerify(vm VM, tx UnsignedTx, creds []verify.Verifiable) error
func (*MintTx) SyntacticVerify ¶ added in v1.13.21
type NFTTransferTx ¶
type NFTTransferTx struct {
// Base transaction fields
BaseTx `serialize:"true"`
// NFT being transferred
NFTTransferOp nftfx.TransferOperation `serialize:"true" json:"nftTransferOp"`
// Destination chain (usually C-Chain)
DestChain ids.ID `serialize:"true" json:"destChain"`
// Recipient address on destination chain
Recipient []byte `serialize:"true" json:"recipient"`
// Optional metadata for the transfer
Metadata []byte `serialize:"true" json:"metadata"`
}
NFTTransferTx transfers NFTs from X-Chain to C-Chain or other subnets This enables NFTs to move from UTXO model (X-Chain) to account model (C-Chain)
func (*NFTTransferTx) InitCtx ¶
func (t *NFTTransferTx) InitCtx(ctx *consensus.Context)
func (*NFTTransferTx) SemanticVerify ¶ added in v1.13.21
func (t *NFTTransferTx) SemanticVerify(vm VM, tx UnsignedTx, creds []verify.Verifiable) error
func (*NFTTransferTx) SyntacticVerify ¶ added in v1.13.21
func (*NFTTransferTx) Visit ¶
func (t *NFTTransferTx) Visit(v Visitor) error
type Operation ¶
type OperationTx ¶
type OperationTx struct {
BaseTx `serialize:"true"`
Ops []*Operation `serialize:"true" json:"operations"`
}
OperationTx is a transaction with no credentials.
func (*OperationTx) InitCtx ¶
func (t *OperationTx) InitCtx(ctx *consensus.Context)
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 ¶
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) SignPropertyFx ¶
func (*Tx) SignSECP256K1Fx ¶
type UnsignedTx ¶
type UnsignedTx interface {
consensus.ContextInitializable
SetBytes(unsignedBytes []byte)
Bytes() []byte
InputIDs() set.Set[ids.ID]
NumCredentials() int
// TODO: deprecate after x-chain linearization
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
BurnTx(*BurnTx) error
MintTx(*MintTx) error
NFTTransferTx(*NFTTransferTx) error
}
Allow vm to execute custom logic against the underlying transaction types.