Documentation
¶
Index ¶
- Constants
- Variables
- func Consume(utxoDB UTXODeleter, ins []*TransferableInput)
- func GetBalance(db UTXOReader, addrs set.Set[ids.ShortID]) (uint64, error)
- func IsSortedTransferableOutputs(outs []*TransferableOutput, c codec.Manager) bool
- func ParseLocalAddresses(a AddressManager, addrStrs []string) (set.Set[ids.ShortID], error)
- func ParseServiceAddress(a AddressManager, addrStr string) (ids.ShortID, error)
- func ParseServiceAddresses(a AddressManager, addrStrs []string) (set.Set[ids.ShortID], error)
- func Produce(utxoDB UTXOAdder, txID ids.ID, outs []*TransferableOutput)
- func SortTransferableInputsWithSigners(ins []*TransferableInput, signers [][]*secp256k1.PrivateKey)
- func SortTransferableOutputs(outs []*TransferableOutput, c codec.Manager)
- func VerifyMemoFieldLength(memo types.JSONByteSlice, isDurangoActive bool) error
- func VerifyTx(feeAmount uint64, feeAssetID ids.ID, allIns [][]*TransferableInput, ...) error
- type AddressManager
- type Addressable
- type Amounter
- type Asset
- type AtomicUTXOManager
- type BCLookup
- type BaseTx
- type ContextInitializable
- type Coster
- type FlowChecker
- type GetUTXOsArgs
- type GetUTXOsReply
- type Index
- type JSONTxID
- type Metadata
- type TestAddressable
- type TestState
- type TestTransferable
- type TransferableIn
- type TransferableInput
- type TransferableOut
- type TransferableOutput
- type UTXO
- func GetAllUTXOs(db UTXOReader, addrs set.Set[ids.ShortID]) ([]*UTXO, error)
- func GetAtomicUTXOs(sharedMemory atomic.SharedMemory, codec codec.Manager, chainID ids.ID, ...) ([]*UTXO, ids.ShortID, ids.ID, error)
- func GetPaginatedUTXOs(db UTXOReader, addrs set.Set[ids.ShortID], lastAddr ids.ShortID, ...) ([]*UTXO, ids.ShortID, ids.ID, error)
- type UTXOAdder
- type UTXODeleter
- type UTXOGetter
- type UTXOID
- type UTXOReader
- type UTXOState
- type UTXOWriter
Constants ¶
const MaxMemoSize = 256
MaxMemoSize is the maximum number of bytes in the memo field
Variables ¶
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") )
var ( ErrNilTransferableOutput = errors.New("nil transferable output is not valid") ErrNilTransferableFxOutput = errors.New("nil transferable feature extension output is not valid") ErrOutputsNotSorted = errors.New("outputs not sorted") ErrNilTransferableInput = errors.New("nil transferable input is not valid") ErrNilTransferableFxInput = errors.New("nil transferable feature extension input is not valid") ErrInputsNotSortedUnique = errors.New("inputs not sorted and unique") )
var ErrInsufficientFunds = errors.New("insufficient funds")
var (
ErrMismatchedChainIDs = errors.New("mismatched chainIDs")
)
Functions ¶
func Consume ¶
func Consume(utxoDB UTXODeleter, ins []*TransferableInput)
Removes the UTXOs consumed by [ins] from the UTXO set
func GetBalance ¶
GetBalance returns the current balance of [addrs]
func IsSortedTransferableOutputs ¶
func IsSortedTransferableOutputs(outs []*TransferableOutput, c codec.Manager) bool
IsSortedTransferableOutputs returns true if output objects are sorted
func ParseLocalAddresses ¶
func 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
func ParseServiceAddresses ¶
ParseServiceAddress get addresses IDs from addresses strings, being them either localized or not
func 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].
func SortTransferableInputsWithSigners ¶
func SortTransferableInputsWithSigners(ins []*TransferableInput, signers [][]*secp256k1.PrivateKey)
SortTransferableInputsWithSigners sorts the inputs and signers based on the input's utxo ID
func SortTransferableOutputs ¶
func SortTransferableOutputs(outs []*TransferableOutput, c codec.Manager)
SortTransferableOutputs sorts output objects
func VerifyMemoFieldLength ¶
func VerifyMemoFieldLength(memo types.JSONByteSlice, isDurangoActive bool) error
VerifyMemoFieldLength validates memo field length based on Durango activation status
func VerifyTx ¶
func VerifyTx( feeAmount uint64, feeAssetID ids.ID, allIns [][]*TransferableInput, allOuts [][]*TransferableOutput, c codec.Manager, ) error
VerifyTx verifies that the inputs and outputs flowcheck, including a fee. Additionally, this verifies that the inputs and outputs are sorted.
Types ¶
type AddressManager ¶
type AddressManager interface {
// ParseLocalAddress takes in an address for this chain and produces the ID
ParseLocalAddress(addrStr string) (ids.ShortID, error)
// ParseAddress takes in an address and produces the ID of the chain it's
// for and the ID of the address
ParseAddress(addrStr string) (ids.ID, ids.ShortID, error)
// FormatLocalAddress takes in a raw address and produces the formatted
// address for this chain
FormatLocalAddress(addr ids.ShortID) (string, error)
// FormatAddress takes in a chainID and a raw address and produces the
// formatted address for that chain
FormatAddress(chainID ids.ID, addr ids.ShortID) (string, error)
}
func NewAddressManager ¶
func NewAddressManager(rt *runtime.Runtime) AddressManager
type Addressable ¶
type Addressable interface {
Addresses() [][]byte
}
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
type Amounter ¶
type Amounter interface {
// Amount returns how much value this element represents of the asset in its
// transaction.
Amount() uint64
}
Amounter is a data structure that has an amount of something associated with it
type AtomicUTXOManager ¶
type AtomicUTXOManager interface {
// GetAtomicUTXOs returns the UTXOs controlled by [addrs] from the given [chainID]
GetAtomicUTXOs(
chainID ids.ID,
addrs set.Set[ids.ShortID],
startAddr ids.ShortID,
startUTXOID ids.ID,
limit int,
) ([]*UTXO, ids.ShortID, ids.ID, error)
}
AtomicUTXOManager defines the interface for managing atomic UTXOs
func NewAtomicUTXOManager ¶
func NewAtomicUTXOManager(sm atomic.SharedMemory, codec codec.Manager) AtomicUTXOManager
type BaseTx ¶
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
}
BaseTx is the basis of all standard transactions.
func (*BaseTx) InputUTXOs ¶
InputUTXOs track which UTXOs this transaction is consuming.
func (*BaseTx) NumCredentials ¶
NumCredentials returns the number of expected credentials
type ContextInitializable ¶
ContextInitializable can be initialized with a context
type Coster ¶
type Coster interface {
// Cost returns how much this element costs to be included in its
// transaction.
Cost() (uint64, error)
}
Coster is a data structure that has a cost associated with it
type FlowChecker ¶
type FlowChecker struct {
// contains filtered or unexported fields
}
func NewFlowChecker ¶
func NewFlowChecker() *FlowChecker
func (*FlowChecker) Verify ¶
func (fc *FlowChecker) Verify() error
type GetUTXOsArgs ¶
type GetUTXOsArgs struct {
Addresses []string `json:"addresses"`
SourceChain string `json:"sourceChain"`
Limit codec.Uint32 `json:"limit"`
StartIndex Index `json:"startIndex"`
Encoding formatting.Encoding `json:"encoding"`
}
GetUTXOsArgs are arguments for passing into GetUTXOs. Gets the UTXOs that reference at least one address in [Addresses]. Returns at most [limit] addresses. If specified, [SourceChain] is the chain where the atomic UTXOs were exported from. If empty, or the Chain ID of this VM is specified, then GetUTXOs fetches the native UTXOs. If [limit] == 0 or > [maxUTXOsToFetch], fetches up to [maxUTXOsToFetch]. [StartIndex] defines where to start fetching UTXOs (for pagination.) UTXOs fetched are from addresses equal to or greater than [StartIndex.Address] For address [StartIndex.Address], only UTXOs with IDs greater than [StartIndex.UTXO] will be returned. If [StartIndex] is omitted, gets all UTXOs. If GetUTXOs is called multiple times, with our without [StartIndex], it is not guaranteed that returned UTXOs are unique. That is, the same UTXO may appear in the response of multiple calls.
type GetUTXOsReply ¶
type GetUTXOsReply struct {
// Number of UTXOs returned
NumFetched codec.Uint64 `json:"numFetched"`
// The UTXOs
UTXOs []string `json:"utxos"`
// The last UTXO that was returned, and the address it corresponds to.
// Used for pagination. To get the rest of the UTXOs, call GetUTXOs
// again and set [StartIndex] to this value.
EndIndex Index `json:"endIndex"`
// Encoding specifies the encoding format the UTXOs are returned in
Encoding formatting.Encoding `json:"encoding"`
}
GetUTXOsReply defines the GetUTXOs replies returned from the API JSON field names match RPC conventions for compatibility across services.
type Index ¶
type Index struct {
Address string `json:"address"` // The address as a string
UTXO string `json:"utxo"` // The UTXO ID as a string
}
Index is an address and an associated UTXO. Marks a starting or stopping point when fetching UTXOs. Used for pagination.
type JSONTxID ¶
JSONTxID contains the ID of a transaction. This is duplicated here for UTXO tooling convenience.
type Metadata ¶
type Metadata struct {
// contains filtered or unexported fields
}
func (*Metadata) Initialize ¶
Initialize set the bytes and ID
func (*Metadata) SignedBytes ¶
Bytes returns the binary representation of this data
type TestAddressable ¶
type TestAddressable struct {
TestTransferable `serialize:"true"`
Addrs [][]byte `serialize:"true"`
}
func (*TestAddressable) Addresses ¶
func (a *TestAddressable) Addresses() [][]byte
type TestState ¶
type TestState struct {
verify.IsState `serialize:"-" json:"-"`
Err error `serialize:"-" json:"-"`
}
func (*TestState) InitRuntime ¶
type TestTransferable ¶
func (*TestTransferable) Amount ¶
func (t *TestTransferable) Amount() uint64
func (*TestTransferable) Cost ¶
func (*TestTransferable) Cost() (uint64, error)
func (*TestTransferable) InitRuntime ¶
func (*TestTransferable) InitRuntime(*runtime.Runtime)
type TransferableIn ¶
type TransferableIn interface {
verify.Verifiable
Amounter
Coster
}
TransferableIn is the interface a feature extension must provide to transfer value between features extensions.
type TransferableInput ¶
type TransferableInput struct {
UTXOID `serialize:"true"`
Asset `serialize:"true"`
// FxID has serialize false because we don't want this to be encoded in bytes
FxID ids.ID `serialize:"-" json:"fxID"`
In TransferableIn `serialize:"true" json:"input"`
}
func (*TransferableInput) Compare ¶
func (in *TransferableInput) Compare(other *TransferableInput) int
func (*TransferableInput) InitRuntime ¶ added in v0.2.7
func (in *TransferableInput) InitRuntime(rt *runtime.Runtime)
InitRuntime forwards the runtime to the inner Fx input if it implements the runtime-aware interface. No-op otherwise. Used by VMs that need to hand a runtime context down to feature-extension input types.
func (*TransferableInput) Input ¶
func (in *TransferableInput) Input() TransferableIn
Input returns the feature extension input that this Input is using.
func (*TransferableInput) Verify ¶
func (in *TransferableInput) Verify() error
type TransferableOut ¶
TransferableOut is the interface a feature extension must provide to transfer value between features extensions.
type TransferableOutput ¶
type TransferableOutput struct {
Asset `serialize:"true"`
// FxID has serialize false because we don't want this to be encoded in bytes
FxID ids.ID `serialize:"-" json:"fxID"`
Out TransferableOut `serialize:"true" json:"output"`
}
func (*TransferableOutput) InitRuntime ¶
func (out *TransferableOutput) InitRuntime(rt *runtime.Runtime)
func (*TransferableOutput) Output ¶
func (out *TransferableOutput) Output() TransferableOut
Output returns the feature extension output that this Output is using.
func (*TransferableOutput) Verify ¶
func (out *TransferableOutput) Verify() error
type UTXO ¶
type UTXO struct {
UTXOID `serialize:"true"`
Asset `serialize:"true"`
Out verify.State `serialize:"true" json:"output"`
}
func GetAllUTXOs ¶
func GetAtomicUTXOs ¶
func GetAtomicUTXOs( sharedMemory atomic.SharedMemory, codec codec.Manager, chainID ids.ID, addrs set.Set[ids.ShortID], startAddr ids.ShortID, startUTXOID ids.ID, limit int, ) ([]*UTXO, ids.ShortID, ids.ID, error)
GetAtomicUTXOs returns exported UTXOs such that at least one of the addresses in [addrs] is referenced.
Returns at most [limit] UTXOs.
Returns: * The fetched UTXOs * The address associated with the last UTXO fetched * The ID of the last UTXO fetched * Any error that may have occurred upstream.
func GetPaginatedUTXOs ¶
func GetPaginatedUTXOs( db UTXOReader, addrs set.Set[ids.ShortID], lastAddr ids.ShortID, lastUTXOID ids.ID, limit int, ) ([]*UTXO, ids.ShortID, ids.ID, error)
GetPaginatedUTXOs returns UTXOs such that at least one of the addresses in [addrs] is referenced.
Returns at most [limit] UTXOs.
Only returns UTXOs associated with addresses >= [startAddr].
For address [startAddr], only returns UTXOs whose IDs are greater than [startUTXOID].
Returns: * The fetched UTXOs * The address associated with the last UTXO fetched * The ID of the last UTXO fetched
type UTXODeleter ¶
type UTXOGetter ¶
type UTXOGetter interface {
// GetUTXO attempts to load a utxo.
GetUTXO(utxoID ids.ID) (*UTXO, error)
}
UTXOGetter is a thin wrapper around a database to provide fetching of a UTXO.
type UTXOID ¶
type UTXOID struct {
// Serialized:
TxID ids.ID `serialize:"true" json:"txID"`
OutputIndex uint32 `serialize:"true" json:"outputIndex"`
// Symbol is false if the UTXO should be part of the DB
Symbol bool `serialize:"-" json:"-"`
// contains filtered or unexported fields
}
func UTXOIDFromString ¶
UTXOIDFromString attempts to parse a string into a UTXOID
func (*UTXOID) InputSource ¶
InputSource returns the source of the UTXO that this input is spending
type UTXOReader ¶
type UTXOReader interface {
UTXOGetter
// UTXOIDs returns the slice of IDs associated with [addr], starting after
// [previous].
// If [previous] is not in the list, starts at beginning.
// Returns at most [limit] IDs.
UTXOIDs(addr []byte, previous ids.ID, limit int) ([]ids.ID, error)
}
UTXOReader is a thin wrapper around a database to provide fetching of UTXOs.
type UTXOState ¶
type UTXOState interface {
UTXOReader
UTXOWriter
// Checksum returns the current UTXOChecksum.
Checksum() ids.ID
}
UTXOState is a thin wrapper around a database to provide, caching, serialization, and de-serialization for UTXOs.
func NewMeteredUTXOState ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ed25519fx provides Ed25519 credentials for UTXO spending on X-Chain.
|
Package ed25519fx provides Ed25519 credentials for UTXO spending on X-Chain. |
|
Package luxmock is a generated GoMock package.
|
Package luxmock is a generated GoMock package. |
|
Package mldsafx provides ML-DSA (Module-Lattice Digital Signature Algorithm) credentials for post-quantum secure UTXO spending on X-Chain.
|
Package mldsafx provides ML-DSA (Module-Lattice Digital Signature Algorithm) credentials for post-quantum secure UTXO spending on X-Chain. |
|
Package schnorrfx provides BIP-340 Schnorr credentials for UTXO spending on X-Chain.
|
Package schnorrfx provides BIP-340 Schnorr credentials for UTXO spending on X-Chain. |
|
Package secp256r1fx provides P-256 (NIST secp256r1) ECDSA credentials for UTXO spending on X-Chain.
|
Package secp256r1fx provides P-256 (NIST secp256r1) ECDSA credentials for UTXO spending on X-Chain. |
|
Package slhdsafx provides SLH-DSA (FIPS 205) hash-based post-quantum credentials for high-assurance UTXO spending on X-Chain.
|
Package slhdsafx provides SLH-DSA (FIPS 205) hash-based post-quantum credentials for high-assurance UTXO spending on X-Chain. |