Files
zeekay 7cf87b230b node-unified is the node
The module already called itself github.com/luxfi/node while containing no node
in Go: cmd/luxd was twenty-one lines that printed the size of a few types, and
the Go column of the matrix measured a VM plugin. A repo that fetches the thing
it claims to be has not replaced it, so the Go sources move in — 1515 files,
the daemon and everything under it — and the build reaches outside this module
for nothing.

Rust and C++ sit beside it unchanged and are still measured against it by the
differential. That is the point of one repo: the reference implementation and
the two ports are the same checkout, so parity is a thing you can run rather
than a thing you assert.

Verified: builds, and the closure carries no lux-private — checked at build time
rather than believed. The daemon starts twelve chains on a local network
(P X C Q Z A B G K M F, plus D through its plugin) and reports healthy.
2026-09-07 16:15:25 -07:00

84 lines
2.3 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package lux
import (
"errors"
"fmt"
"github.com/luxfi/runtime"
"github.com/luxfi/ids"
"github.com/luxfi/vm/types"
)
// MaxMemoSize is the maximum number of bytes in the memo field
const MaxMemoSize = 256
var (
ErrNilTx = errors.New("nil tx is not valid")
ErrWrongNetworkID = errors.New("tx has wrong network ID")
ErrWrongChainID = errors.New("tx has wrong chain ID")
ErrMemoTooLarge = errors.New("memo exceeds maximum length")
)
// BaseTx is the basis of all standard transactions.
type BaseTx struct {
NetworkID uint32 `serialize:"true" json:"networkID"` // ID of the network this chain lives on
BlockchainID ids.ID `serialize:"true" json:"blockchainID"` // ID of the chain on which this transaction exists (prevents replay attacks)
Outs []*TransferableOutput `serialize:"true" json:"outputs"` // The outputs of this transaction
Ins []*TransferableInput `serialize:"true" json:"inputs"` // The inputs to this transaction
Memo types.JSONByteSlice `serialize:"true" json:"memo"` // Memo field contains arbitrary bytes, up to maxMemoSize
}
// InputUTXOs track which UTXOs this transaction is consuming.
func (t *BaseTx) InputUTXOs() []*UTXOID {
utxos := make([]*UTXOID, len(t.Ins))
for i, in := range t.Ins {
utxos[i] = &in.UTXOID
}
return utxos
}
// NumCredentials returns the number of expected credentials
func (t *BaseTx) NumCredentials() int {
return len(t.Ins)
}
// Verify ensures that transaction metadata is valid
func (t *BaseTx) Verify(rt *runtime.Runtime) error {
switch {
case t == nil:
return ErrNilTx
case t.NetworkID != rt.NetworkID:
return ErrWrongNetworkID
case t.BlockchainID != rt.ChainID:
return ErrWrongChainID
case len(t.Memo) > MaxMemoSize:
return fmt.Errorf(
"%w: %d > %d",
ErrMemoTooLarge,
len(t.Memo),
MaxMemoSize,
)
default:
return nil
}
}
// VerifyMemoFieldLength enforces the Lux memo-field length rule: under
// activate-all-implicitly the memo field must be empty on every tx.
func VerifyMemoFieldLength(memo types.JSONByteSlice, _ bool) error {
if len(memo) != 0 {
return fmt.Errorf(
"%w: %d > %d",
ErrMemoTooLarge,
len(memo),
0,
)
}
return nil
}