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 ¶
- type Adapter
- func (a *Adapter) GetBalance(ctx context.Context, store storage.Store, address string, assetID string) (uint64, error)
- func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)
- func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
- func (a *Adapter) GetUTXOs(ctx context.Context, store storage.Store, address string, assetID string, ...) ([]UTXO, error)
- func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)
- func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error
- func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)
- func (a *Adapter) StoreAsset(ctx context.Context, store storage.Store, asset *Asset) error
- func (a *Adapter) StoreTransaction(ctx context.Context, store storage.Store, vertexID string, tx *Transaction) error
- type Asset
- type Input
- type Output
- type Transaction
- type UTXO
- type VertexData
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 (*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 ¶
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 ¶
GetVertexByID fetches a specific vertex by ID
func (*Adapter) InitSchema ¶
InitSchema creates X-Chain specific database tables
func (*Adapter) ParseVertex ¶
ParseVertex parses X-Chain vertex data into a dag.Vertex
func (*Adapter) StoreAsset ¶
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