Documentation
¶
Overview ¶
Package indexer provides an HTTP REST client for the Mintlayer indexer (api-web-server, default mainnet port 3000). All endpoints are under /api/v2/.
Index ¶
- type AddressInfo
- type Amount
- type Block
- type BlockBody
- type BlockHeader
- type ChainTip
- type Client
- func (c *Client) FindTokensByTicker(ctx context.Context, ticker string, opts PageOpts) ([]string, error)
- func (c *Client) GetAddressInfo(ctx context.Context, address string) (*AddressInfo, error)
- func (c *Client) GetAllUTXOs(ctx context.Context, address string) ([]UTXO, error)
- func (c *Client) GetBlock(ctx context.Context, id string) (*Block, error)
- func (c *Client) GetBlockHeader(ctx context.Context, id string) (*BlockHeader, error)
- func (c *Client) GetBlockIDAtHeight(ctx context.Context, height uint64) (string, error)
- func (c *Client) GetBlockReward(ctx context.Context, id string) ([]TxOutput, error)
- func (c *Client) GetBlockTransactionIDs(ctx context.Context, id string) ([]string, error)
- func (c *Client) GetCoinStatistics(ctx context.Context) (*CoinStats, error)
- func (c *Client) GetDelegation(ctx context.Context, id string) (*Delegation, error)
- func (c *Client) GetDelegations(ctx context.Context, address string) ([]DelegationInfo, error)
- func (c *Client) GetFeeRate(ctx context.Context, inTopXMb uint32) (string, error)
- func (c *Client) GetGenesis(ctx context.Context) (*GenesisInfo, error)
- func (c *Client) GetNFT(ctx context.Context, id string) (*NFTInfo, error)
- func (c *Client) GetOrder(ctx context.Context, id string) (*Order, error)
- func (c *Client) GetPool(ctx context.Context, id string) (*Pool, error)
- func (c *Client) GetPoolBlockStats(ctx context.Context, id string, from, to time.Time) (uint64, error)
- func (c *Client) GetPoolDelegations(ctx context.Context, id string) ([]PoolDelegation, error)
- func (c *Client) GetSpendableUTXOs(ctx context.Context, address string) ([]UTXO, error)
- func (c *Client) GetTip(ctx context.Context) (*ChainTip, error)
- func (c *Client) GetToken(ctx context.Context, id string) (*TokenInfo, error)
- func (c *Client) GetTokenAuthority(ctx context.Context, address string) ([]string, error)
- func (c *Client) GetTokenStatistics(ctx context.Context, tokenID string) (*CoinStats, error)
- func (c *Client) GetTokenTransactions(ctx context.Context, id string, opts PageOpts) ([]TokenTx, error)
- func (c *Client) GetTransaction(ctx context.Context, id string) (*Transaction, error)
- func (c *Client) GetTransactionMerklePath(ctx context.Context, id string) (*MerklePath, error)
- func (c *Client) GetTransactionOutput(ctx context.Context, txID string, idx uint32) (json.RawMessage, error)
- func (c *Client) ListOrders(ctx context.Context, opts PageOpts) ([]Order, error)
- func (c *Client) ListOrdersByPair(ctx context.Context, askCurrency, giveCurrency string, opts PageOpts) ([]Order, error)
- func (c *Client) ListPools(ctx context.Context, opts PoolListOpts) ([]Pool, error)
- func (c *Client) ListTokens(ctx context.Context, opts PageOpts) ([]string, error)
- func (c *Client) ListTransactions(ctx context.Context, opts PageOpts) ([]Transaction, error)
- func (c *Client) SubmitTransaction(ctx context.Context, signedTxHex string) (string, error)
- type CoinStats
- type Delegation
- type DelegationInfo
- type GenesisInfo
- type HTTPError
- type MerklePath
- type NFTInfo
- type NFTMetadata
- type Option
- type Order
- type PageOpts
- type PerThousand
- type Pool
- type PoolDelegation
- type PoolListOpts
- type Timestamp
- type TokenBalance
- type TokenInfo
- type TokenTx
- type Transaction
- type TxOutput
- type UTXO
- type UTXOOutpoint
- type Uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressInfo ¶
type AddressInfo struct {
CoinBalance Amount `json:"coin_balance"`
LockedCoinBalance Amount `json:"locked_coin_balance"`
TransactionHistory []string `json:"transaction_history"`
Tokens []TokenBalance `json:"tokens"`
}
AddressInfo is returned by GetAddressInfo.
type Block ¶
type Block struct {
Height uint64 `json:"height"`
Header BlockHeader `json:"header"`
Body BlockBody `json:"body"`
}
Block is returned by GetBlock.
type BlockBody ¶
type BlockBody struct {
Reward []TxOutput `json:"reward"`
Transactions []Transaction `json:"transactions"`
}
BlockBody holds the reward outputs and transactions of a block.
type BlockHeader ¶
type BlockHeader struct {
PreviousBlockID string `json:"previous_block_id"`
Timestamp Timestamp `json:"timestamp"`
MerkleRoot string `json:"merkle_root"`
WitnessMerkleRoot string `json:"witness_merkle_root"`
ConsensusData json.RawMessage `json:"consensus_data"`
}
BlockHeader holds the header fields of a block.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP REST client for the Mintlayer indexer (api-web-server).
func New ¶
New creates a Client targeting baseURL (e.g. "http://127.0.0.1:3000").
func (*Client) FindTokensByTicker ¶
func (c *Client) FindTokensByTicker(ctx context.Context, ticker string, opts PageOpts) ([]string, error)
FindTokensByTicker returns token ids (bech32) that match the given ticker string.
func (*Client) GetAddressInfo ¶
GetAddressInfo returns the balance and transaction history for a bech32 address. Returns an *HTTPError with StatusCode 404 if the address has no transaction history.
func (*Client) GetAllUTXOs ¶
GetAllUTXOs returns all UTXOs (including locked/unspendable) for an address.
func (*Client) GetBlockHeader ¶
GetBlockHeader returns only the header for the given block id (hex).
func (*Client) GetBlockIDAtHeight ¶
GetBlockIDAtHeight returns the block id (hex) at the given mainchain height. Returns an *HTTPError with StatusCode 404 if no block exists at that height.
func (*Client) GetBlockReward ¶
GetBlockReward returns the reward outputs for the given block id (hex).
func (*Client) GetBlockTransactionIDs ¶
GetBlockTransactionIDs returns all transaction ids in the given block (hex block id).
func (*Client) GetCoinStatistics ¶
GetCoinStatistics returns aggregate ML coin supply statistics.
func (*Client) GetDelegation ¶
GetDelegation returns a single delegation by id (bech32).
func (*Client) GetDelegations ¶
GetDelegations returns all delegations owned by an address.
func (*Client) GetFeeRate ¶
GetFeeRate returns the current fee rate (atoms per kilobyte) required to be in the top inTopXMb megabytes of the mempool. Pass 0 to use the server default (5 MB).
func (*Client) GetGenesis ¶
func (c *Client) GetGenesis(ctx context.Context) (*GenesisInfo, error)
GetGenesis returns the genesis block info.
func (*Client) GetPoolBlockStats ¶
func (c *Client) GetPoolBlockStats(ctx context.Context, id string, from, to time.Time) (uint64, error)
GetPoolBlockStats returns the number of blocks produced by a pool in the half-open interval [from, to).
func (*Client) GetPoolDelegations ¶
GetPoolDelegations returns all delegations in a pool.
func (*Client) GetSpendableUTXOs ¶
GetSpendableUTXOs returns the currently spendable (confirmed, unspent) UTXOs for an address.
func (*Client) GetTokenAuthority ¶
GetTokenAuthority returns the ids (bech32) of fungible tokens for which the address is the authority (can mint, freeze, etc.).
func (*Client) GetTokenStatistics ¶
GetTokenStatistics returns aggregate supply statistics for a specific token (bech32 id).
func (*Client) GetTokenTransactions ¶
func (c *Client) GetTokenTransactions(ctx context.Context, id string, opts PageOpts) ([]TokenTx, error)
GetTokenTransactions returns transactions involving a token, with pagination.
func (*Client) GetTransaction ¶
GetTransaction returns the transaction with the given id (hex). BlockID, Timestamp, and Confirmations are empty strings if the transaction is not yet confirmed.
func (*Client) GetTransactionMerklePath ¶
GetTransactionMerklePath returns the Merkle inclusion proof for a transaction. Returns an *HTTPError with StatusCode 404 if the transaction is not yet in a block.
func (*Client) GetTransactionOutput ¶
func (c *Client) GetTransactionOutput(ctx context.Context, txID string, idx uint32) (json.RawMessage, error)
GetTransactionOutput returns a single output by transaction id and output index. The returned JSON includes a "spent_at_block_height" field (null if unspent).
func (*Client) ListOrders ¶
ListOrders returns active orders with pagination.
func (*Client) ListOrdersByPair ¶
func (c *Client) ListOrdersByPair(ctx context.Context, askCurrency, giveCurrency string, opts PageOpts) ([]Order, error)
ListOrdersByPair returns orders for a trading pair with pagination. askCurrency and giveCurrency are either the coin ticker (e.g. "ML") or a token id (bech32).
func (*Client) ListTokens ¶
ListTokens returns fungible token ids with pagination.
func (*Client) ListTransactions ¶
ListTransactions returns paginated transactions.
func (*Client) SubmitTransaction ¶
SubmitTransaction submits a signed transaction (hex-encoded bytes) to the network. Returns the transaction id on success. Note: POST routes must be enabled on the server (--enable-post-routes).
type CoinStats ¶
type CoinStats struct {
CirculatingSupply Amount `json:"circulating_supply"`
Preminted Amount `json:"preminted"`
Burned Amount `json:"burned"`
Staked Amount `json:"staked"`
}
CoinStats is returned by GetCoinStatistics and GetTokenStatistics.
type Delegation ¶
type Delegation struct {
DelegationID string `json:"delegation_id"`
PoolID string `json:"pool_id"`
NextNonce Uint64 `json:"next_nonce"`
SpendDestination string `json:"spend_destination"`
Balance Amount `json:"balance"`
CreationBlockHeight Uint64 `json:"creation_block_height"`
}
Delegation is returned by GetDelegation.
type DelegationInfo ¶
type DelegationInfo struct {
DelegationID string `json:"delegation_id"`
PoolID string `json:"pool_id"`
NextNonce Uint64 `json:"next_nonce"`
SpendDestination string `json:"spend_destination"`
Balance Amount `json:"balance"`
}
DelegationInfo is one entry returned by GetDelegations (address endpoint).
type GenesisInfo ¶
type GenesisInfo struct {
BlockID string `json:"block_id"`
GenesisMessage string `json:"genesis_message"`
Timestamp Timestamp `json:"timestamp"`
UTXOs json.RawMessage `json:"utxos"`
}
GenesisInfo is returned by GetGenesis.
type MerklePath ¶
type MerklePath struct {
BlockID string `json:"block_id"`
TransactionIndex uint32 `json:"transaction_index"`
MerkleRoot string `json:"merkle_root"`
Path []string `json:"merkle_path"`
}
MerklePath is returned by GetTransactionMerklePath.
type NFTInfo ¶
type NFTInfo struct {
Owner string `json:"owner"`
TokenID string `json:"token_id"`
Metadata NFTMetadata `json:"metadata"`
}
NFTInfo is returned by GetNFT.
type NFTMetadata ¶
type NFTMetadata struct {
Creator *string `json:"creator"`
Name string `json:"name"`
Description string `json:"description"`
Ticker string `json:"ticker"`
IconURI string `json:"icon_uri"`
AdditionalMetadataURI *string `json:"additional_metadata_uri"`
MediaURI *string `json:"media_uri"`
MediaHash string `json:"media_hash"`
}
NFTMetadata holds the on-chain metadata of an NFT.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient replaces the default HTTP client.
func WithTimeout ¶
WithTimeout sets a per-request timeout on the default HTTP client. Cannot be combined with WithHTTPClient — the last option applied wins.
type Order ¶
type Order struct {
OrderID string `json:"order_id"`
ConcludeDestination string `json:"conclude_destination"`
GiveCurrency json.RawMessage `json:"give_currency"`
InitiallyGiven Amount `json:"initially_given"`
GiveBalance Amount `json:"give_balance"`
AskCurrency json.RawMessage `json:"ask_currency"`
InitiallyAsked Amount `json:"initially_asked"`
AskBalance Amount `json:"ask_balance"`
Nonce Uint64 `json:"nonce"`
}
Order is one entry returned by ListOrders, GetOrder, and ListOrdersByPair. GiveCurrency and AskCurrency are raw JSON with a "type" field of "Coin" or "Token".
type PageOpts ¶
PageOpts controls pagination for list endpoints. Zero values use server defaults (offset=0, items=10).
type PerThousand ¶
type PerThousand float64
PerThousand holds a margin_ratio_per_thousand value as a float64. The API may return the value as a bare number (35), a quoted integer ("35"), or a quoted decimal with a spurious percent sign ("3.5%"). In all cases the numeric part is stored as-is in per-thousand units.
func (PerThousand) MarshalJSON ¶
func (n PerThousand) MarshalJSON() ([]byte, error)
func (*PerThousand) UnmarshalJSON ¶
func (n *PerThousand) UnmarshalJSON(b []byte) error
type Pool ¶
type Pool struct {
PoolID string `json:"pool_id"`
DecommissionDestination string `json:"decommission_destination"`
StakerBalance Amount `json:"staker_balance"`
MarginRatioPerThousand PerThousand `json:"margin_ratio_per_thousand"`
CostPerBlock Amount `json:"cost_per_block"`
VRFPublicKey string `json:"vrf_public_key"`
DelegationsBalance Amount `json:"delegations_balance"`
}
Pool is one entry returned by ListPools and GetPool.
type PoolDelegation ¶
type PoolDelegation struct {
DelegationID string `json:"delegation_id"`
NextNonce Uint64 `json:"next_nonce"`
SpendDestination string `json:"spend_destination"`
Balance Amount `json:"balance"`
CreationBlockHeight Uint64 `json:"creation_block_height"`
}
PoolDelegation is one entry returned by GetPoolDelegations.
type PoolListOpts ¶
type PoolListOpts struct {
PageOpts
// Sort is "by_height" (default, newest first) or "by_pledge" (largest staker balance first).
Sort string
}
PoolListOpts extends PageOpts with a pool-specific sort order.
type Timestamp ¶
type Timestamp struct {
Timestamp int64 `json:"timestamp"`
}
Timestamp wraps a Unix seconds timestamp returned by the indexer.
type TokenBalance ¶
TokenBalance is one entry in AddressInfo.Tokens.
type TokenInfo ¶
type TokenInfo struct {
Authority string `json:"authority"`
IsLocked bool `json:"is_locked"`
CirculatingSupply Amount `json:"circulating_supply"`
TokenTicker string `json:"token_ticker"`
MetadataURI string `json:"metadata_uri"`
NumberOfDecimals uint8 `json:"number_of_decimals"`
TotalSupply json.RawMessage `json:"total_supply"`
Frozen bool `json:"frozen"`
// IsTokenUnfreezable is non-nil only when Frozen is true.
IsTokenUnfreezable *bool `json:"is_token_unfreezable"`
// IsTokenFreezable is non-nil only when Frozen is false.
IsTokenFreezable *bool `json:"is_token_freezable"`
NextNonce Uint64 `json:"next_nonce"`
}
TokenInfo is returned by GetToken.
type Transaction ¶
type Transaction struct {
ID string `json:"id"`
Inputs json.RawMessage `json:"inputs"`
Outputs json.RawMessage `json:"outputs"`
BlockID string `json:"block_id"`
Timestamp string `json:"timestamp"`
Confirmations string `json:"confirmations"`
}
Transaction is returned by GetTransaction and ListTransactions. BlockID, Timestamp, and Confirmations are empty strings for unconfirmed transactions.
type TxOutput ¶
type TxOutput = json.RawMessage
TxOutput is the raw JSON of one transaction output. Its shape is determined by the "type" field. Common types: "Transfer", "LockThenTransfer", "Burn", "CreateStakePool", "ProduceBlockFromStake", "CreateDelegationId", "DelegateStaking", "IssueFungibleToken", "IssueNft", "DataDeposit", "Htlc", "CreateOrder".
type UTXO ¶
type UTXO struct {
Outpoint UTXOOutpoint `json:"outpoint"`
Output TxOutput `json:"utxo"`
}
UTXO is one entry returned by GetSpendableUTXOs and GetAllUTXOs.
type UTXOOutpoint ¶
UTXOOutpoint identifies a UTXO by its source transaction id and output index.
type Uint64 ¶
type Uint64 uint64
Uint64 is a uint64 that accepts both a bare JSON number and a quoted-string number (e.g. both 42 and "42"). Several Mintlayer API fields are documented as integers but are serialised as strings by the server.