utxo

package
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package xchain provides the X-Chain (UTXO) adapter for the DAG indexer. X-Chain handles asset transfers using the UTXO model and DAG consensus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter implements dag.Adapter for X-Chain

func New

func New(rpcEndpoint string) *Adapter

New creates a new X-Chain adapter

func (*Adapter) GetBalance

func (a *Adapter) GetBalance(ctx context.Context, store storage.Store, address string, assetID string) (uint64, error)

GetBalance calculates balance for an address

func (*Adapter) GetRecentVertices

func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)

GetRecentVertices fetches recent vertices from the X-Chain

func (*Adapter) GetStats

func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)

GetStats returns X-Chain specific statistics

func (*Adapter) GetUTXOs

func (a *Adapter) GetUTXOs(ctx context.Context, store storage.Store, address string, assetID string, spentFilter *bool) ([]UTXO, error)

GetUTXOs fetches UTXOs for an address

func (*Adapter) GetVertexByID

func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)

GetVertexByID fetches a specific vertex by ID

func (*Adapter) InitSchema

func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error

InitSchema creates X-Chain specific database tables

func (*Adapter) ParseVertex

func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)

ParseVertex parses X-Chain vertex data into a dag.Vertex

func (*Adapter) StoreAsset

func (a *Adapter) StoreAsset(ctx context.Context, store storage.Store, asset *Asset) error

StoreAsset stores or updates an asset

func (*Adapter) StoreTransaction

func (a *Adapter) StoreTransaction(ctx context.Context, store storage.Store, vertexID string, tx *Transaction) error

StoreTransaction stores a transaction and updates UTXOs

type Asset

type Asset struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Symbol       string `json:"symbol"`
	Denomination uint8  `json:"denomination"`
	TotalSupply  uint64 `json:"totalSupply"`
}

Asset represents an X-Chain asset

type Input

type Input struct {
	TxID     string `json:"txId"`
	OutIndex uint32 `json:"outIndex"`
	AssetID  string `json:"assetId"`
	Amount   uint64 `json:"amount"`
	Address  string `json:"address"`
}

Input represents a transaction input

type Output

type Output struct {
	AssetID   string   `json:"assetId"`
	Amount    uint64   `json:"amount"`
	Addresses []string `json:"addresses"`
	Threshold uint32   `json:"threshold"`
	Locktime  uint64   `json:"locktime"`
}

Output represents a transaction output

type Transaction

type Transaction struct {
	ID        string   `json:"id"`
	Type      string   `json:"type"`
	Inputs    []Input  `json:"inputs"`
	Outputs   []Output `json:"outputs"`
	Memo      string   `json:"memo,omitempty"`
	Timestamp int64    `json:"timestamp"`
}

Transaction represents an X-Chain transaction

type UTXO

type UTXO struct {
	ID       string `json:"id"`
	TxID     string `json:"txId"`
	OutIndex uint32 `json:"outIndex"`
	AssetID  string `json:"assetId"`
	Amount   uint64 `json:"amount"`
	Address  string `json:"address"`
	Spent    bool   `json:"spent"`
	SpentBy  string `json:"spentBy,omitempty"`
}

UTXO represents an unspent transaction output

type VertexData

type VertexData struct {
	Transactions []Transaction `json:"transactions"`
	ChainID      string        `json:"chainId"`
}

VertexData holds X-Chain specific vertex data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL