lux
Package lux owns the luxd-side ZAP wire dispatcher for the cross-fx UTXO factory.
import "github.com/luxfi/node/vms/components/lux"Package lux owns the luxd-side ZAP wire dispatcher for the cross-fx UTXO factory. The root utxo package cannot import the per-fx wire adapters (cycle), so each consumer registers an fx-aware utxo.ParseUTXOFunc at boot via utxo.RegisterParseUTXO.
This file is the luxd consumer's registration site: an init() that wires in the full secp256k1fx / mldsafx / slhdsafx / ed25519fx / secp256r1fx / schnorrfx / bls12381fx output set. The dispatcher runs in O(1) on (TypeKind, ShapeKind) and stays in its lane — each fx package's WrapXxxOutput is the only thing that knows the fx-specific shape.
Functions
Consume
func Consume(utxoDB UTXODeleter, ins []*TransferableInput)Removes the UTXOs consumed by [ins] from the UTXO set
GetBalance
func GetBalance(db UTXOReader, addrs set.Set[ids.ShortID]) (uint64, error)GetBalance returns the current balance of [addrs]
IsSortedTransferableOutputs
func IsSortedTransferableOutputs(outs []*TransferableOutput) boolIsSortedTransferableOutputs returns true if output objects are sorted
MarshalOwner
func MarshalOwner(o any) ([]byte, error)MarshalOwner is the ONE canonical byte encoding of an owner: the fx's
own native ZAP OutputOwners envelope (TypeKindReserved,
ShapeKindOutputOwners). Takes any to match the fx.Owned.Owners()
surface. Same wire the fx TransferOutput embeds — no second encoding.
ParseLocalAddresses
func ParseLocalAddresses(a AddressManager, addrStrs []string) (set.Set[ids.ShortID], error)ParseServiceAddress
func ParseServiceAddress(a AddressManager, addrStr string) (ids.ShortID, error)ParseServiceAddress get address ID from address string, being it either localized (using address manager, doing also components validations), or not localized. If both attempts fail, reports error from localized address parsing
ParseServiceAddresses
func ParseServiceAddresses(a AddressManager, addrStrs []string) (set.Set[ids.ShortID], error)ParseServiceAddress get addresses IDs from addresses strings, being them either localized or not
Produce
func Produce(
utxoDB UTXOAdder,
txID ids.ID,
outs []*TransferableOutput,
)Adds the UTXOs created by [outs] to the UTXO set. [txID] is the ID of the tx that created [outs].
RegisterLockedOutputHandler
func RegisterLockedOutputHandler(h LockedOutputHandler)RegisterLockedOutputHandler installs the locked-output wire handler. Called from platformvm/stakeable.init(). Panics on double-install so a duplicate registration during test fixture setup is loud, not silent.
SortTransferableInputsWithSigners
func SortTransferableInputsWithSigners(ins []*TransferableInput, signers [][]*secp256k1.PrivateKey)SortTransferableInputsWithSigners sorts the inputs and signers based on the input's utxo ID
SortTransferableOutputs
func SortTransferableOutputs(outs []*TransferableOutput)SortTransferableOutputs sorts output objects by (AssetID, inner-output ZAP wire bytes). ZAP-native — no codec.Manager needed.
UnmarshalOwner
func UnmarshalOwner(b []byte) (*secp256k1fx.OutputOwners, error)UnmarshalOwner is the exact inverse of MarshalOwner: parses the canonical OutputOwners envelope back into *secp256k1fx.OutputOwners.
VerifyMemoFieldLength
func VerifyMemoFieldLength(memo types.JSONByteSlice, _ bool) errorVerifyMemoFieldLength enforces the Lux memo-field length rule: under activate-all-implicitly the memo field must be empty on every tx.
VerifyTx
func VerifyTx(
feeAmount uint64,
feeAssetID ids.ID,
allIns [][]*TransferableInput,
allOuts [][]*TransferableOutput,
) errorVerifyTx verifies that the inputs and outputs flowcheck, including a fee. Additionally, this verifies that the inputs and outputs are sorted.
WrapOutputBytes
func WrapOutputBytes(b []byte) (verify.State, error)WrapOutputBytes is the public entry to the fx-aware output dispatcher for composite shapes that recurse on a child envelope. Reads the envelope's (TypeKind, ShapeKind) prefix and routes through wrapOutput.
The LockedOutput handler uses this on its inner TransferOutBytes — since the lock is fx-agnostic (TypeKind=Reserved) the inner envelope carries the actual fx discriminator.
Types
AddressManager
func NewAddressManager(rt *runtime.Runtime) AddressManagerAddressable
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
Amounter
Amounter is a data structure that has an amount of something associated with it
Asset
func (asset *Asset) AssetID() ids.IDfunc (a *Asset) Marshal() ([]byte, error)func (a *Asset) Unmarshal(bytes []byte) errorfunc (asset *Asset) Verify() errorAtomicUTXOManager
AtomicUTXOManager defines the interface for managing atomic UTXOs
func NewAtomicUTXOManager(sm atomic.SharedMemory) AtomicUTXOManagerBCLookup
BCLookup provides blockchain alias lookup
BaseTx
BaseTx is the basis of all standard transactions.
func (t *BaseTx) InputUTXOs() []*UTXOIDfunc (t *BaseTx) Marshal() ([]byte, error)func (t *BaseTx) NumCredentials() intfunc (t *BaseTx) Unmarshal(bytes []byte) errorfunc (t *BaseTx) Verify(rt *runtime.Runtime) errorCoster
Coster is a data structure that has a cost associated with it
FlowChecker
func NewFlowChecker() *FlowCheckerfunc (fc *FlowChecker) Consume(assetID ids.ID, amount uint64)func (fc *FlowChecker) Produce(assetID ids.ID, amount uint64)func (fc *FlowChecker) Verify() errorLockedOutputHandler
LockedOutputHandler reconstructs the cross-fx LockedOutput composite (stakeable.LockOut on the platformvm side) from its wire envelope. stakeable.LockOut embeds lux.TransferableOut so this package cannot import it without a cycle — instead the platformvm/stakeable package registers a handler in its init() that knows how to:
- wire.WrapLockedOutput(b) to surface (Locktime, TransferOutBytes)
- WrapOutputBytes(TransferOutBytes) to recursively dispatch the inner output through the same fx-aware dispatcher
- construct a *stakeable.LockOut{Locktime, TransferableOut: inner}
Without a registration, locked-output UTXOs (the canonical shape for
vesting allocations in mainnet/testnet genesis) decode as
"unknown (TypeKind=0x00, ShapeKind=0x0F)" and silently disappear
from address balances — observed live as platform.getBalance = 0
for every genesis-funded P-chain address.
Metadata
func (md *Metadata) Bytes() []bytefunc (md *Metadata) ID() ids.IDfunc (md *Metadata) Initialize(unsignedBytes, bytes []byte)func (md *Metadata) Marshal() ([]byte, error)func (md *Metadata) SignedBytes() []bytefunc (md *Metadata) Unmarshal(bytes []byte) errorfunc (md *Metadata) Verify() errorRuntimeInitializable
RuntimeInitializable can be initialized with a context
TestAddressable
func (a *TestAddressable) Addresses() [][]byteTestState
func (*TestState) InitRuntime(*runtime.Runtime)func (v *TestState) Verify() errorTestTransferable
func (t *TestTransferable) Amount() uint64func (*TestTransferable) Cost() (uint64, error)func (*TestTransferable) InitRuntime(*runtime.Runtime)TransferableIn
TransferableIn is the interface a feature extension must provide to transfer value between features extensions.
func WrapInputBytes(b []byte) (TransferableIn, error)TransferableInput
func (in *TransferableInput) Compare(other *TransferableInput) intfunc (in *TransferableInput) InitRuntime(rt *runtime.Runtime)func (in *TransferableInput) Input() TransferableInfunc (in *TransferableInput) Marshal() ([]byte, error)func (in *TransferableInput) Unmarshal(bytes []byte) errorfunc (in *TransferableInput) Verify() errorTransferableOut
TransferableOut is the interface a feature extension must provide to transfer value between features extensions.
TransferableOutput
func (out *TransferableOutput) InitRuntime(rt *runtime.Runtime)func (out *TransferableOutput) Marshal() ([]byte, error)func (out *TransferableOutput) Output() TransferableOutfunc (out *TransferableOutput) Unmarshal(bytes []byte) errorfunc (out *TransferableOutput) Verify() errorUTXO
func GetAllUTXOs(db UTXOReader, addrs set.Set[ids.ShortID]) ([]*UTXO, error)func GetAtomicUTXOs(
sharedMemory atomic.SharedMemory,
chainID ids.ID,
addrs set.Set[ids.ShortID],
startAddr ids.ShortID,
startUTXOID ids.ID,
limit int,
) ([]*UTXO, ids.ShortID, ids.ID, error)func GetPaginatedUTXOs(
db UTXOReader,
addrs set.Set[ids.ShortID],
lastAddr ids.ShortID,
lastUTXOID ids.ID,
limit int,
) ([]*UTXO, ids.ShortID, ids.ID, error)func (utxo *UTXO) Marshal() ([]byte, error)func (utxo *UTXO) Unmarshal(bytes []byte) errorfunc (utxo *UTXO) Verify() errorUTXOAdder
UTXODeleter
UTXOGetter
UTXOGetter is a thin wrapper around a database to provide fetching of a UTXO.
UTXOID
func UTXOIDFromString(s string) (*UTXOID, error)func (utxo *UTXOID) Compare(other *UTXOID) intfunc (utxo *UTXOID) InputID() ids.IDfunc (utxo *UTXOID) InputSource() (ids.ID, uint32)func (u *UTXOID) Marshal() ([]byte, error)func (utxo *UTXOID) String() stringfunc (utxo *UTXOID) Symbolic() boolfunc (u *UTXOID) Unmarshal(bytes []byte) errorfunc (utxo *UTXOID) Verify() errorUTXOReader
UTXOReader is a thin wrapper around a database to provide fetching of UTXOs.
UTXOState
UTXOState is a thin wrapper around a database to provide, caching, serialization, and de-serialization for UTXOs.
func NewMeteredUTXOState(
db database.Database,
metrics metric.Registerer,
trackChecksum bool,
) (UTXOState, error)func NewUTXOState(
db database.Database,
trackChecksum bool,
) (UTXOState, error)UTXOWriter
UTXOWriter is a thin wrapper around a database to provide storage and deletion of UTXOs.