Documentation
¶
Overview ¶
Package esplora provides a minimal typed client for the Esplora HTTP API (Elements/Liquid variant). Only the endpoints needed by Anchor are implemented.
Index ¶
- type AssetInfo
- type AssetIssuance
- type Block
- type Client
- func (c *Client) GetAddressMempoolTxs(addr string) ([]Tx, error)
- func (c *Client) GetAddressTxs(addr string, afterTxID string) ([]Tx, error)
- func (c *Client) GetAddressUTXOs(addr string) ([]UTXO, error)
- func (c *Client) GetAsset(assetID string) (*AssetInfo, error)
- func (c *Client) GetBlockTxs(blockHash string, startIndex int) ([]Tx, error)
- func (c *Client) GetBlocks(startHeight int) ([]Block, error)
- func (c *Client) GetTx(txid string) (*Tx, error)
- func (c *Client) Ping() (int, error)
- type Issuance
- type PoolCreationRecord
- type Tx
- type TxStatus
- type TxVin
- type TxVout
- type UTXO
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetInfo ¶
type AssetInfo struct {
AssetID string `json:"asset_id"`
IssuanceTxIn *AssetIssuance `json:"issuance_txin"`
Status TxStatus `json:"status"`
}
AssetInfo holds Elements asset metadata from the Esplora API.
type AssetIssuance ¶
AssetIssuance identifies the issuance input for an asset.
type Block ¶
type Block struct {
ID string `json:"id"`
Height int `json:"height"`
Version int `json:"version"`
Timestamp int64 `json:"timestamp"`
MedianTime int64 `json:"mediantime"`
TxCount int `json:"tx_count"`
Size int `json:"size"`
Weight int `json:"weight"`
PreviousBlockHash string `json:"previousblockhash"`
}
Block is a block summary from the blocks endpoint.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an Esplora HTTP API client.
func New ¶
New creates an Esplora client for the given base URL (e.g. "http://10.1.10.5:5500").
func (*Client) GetAddressMempoolTxs ¶
GetAddressMempoolTxs returns unconfirmed transactions for an address (max 50).
func (*Client) GetAddressTxs ¶
GetAddressTxs returns up to 25 confirmed transactions for an address, plus up to 50 unconfirmed. For paging confirmed txs, pass the last txid seen as afterTxID; pass "" for the first page.
func (*Client) GetAddressUTXOs ¶
GetAddressUTXOs returns unspent outputs for an address.
func (*Client) GetAsset ¶
GetAsset fetches asset metadata by asset ID, including the issuance transaction.
func (*Client) GetBlockTxs ¶
GetBlockTxs returns up to 25 transactions from a block, starting at startIndex. startIndex must be a multiple of 25.
func (*Client) GetBlocks ¶
GetBlocks returns 10 block summaries starting at the given height (descending). Pass -1 to start from the tip.
type Issuance ¶
type Issuance struct {
AssetID string `json:"asset_id"`
IsReissuance bool `json:"is_reissuance"`
ContractHash string `json:"contract_hash"`
AssetEntropy string `json:"asset_entropy"`
AssetAmount uint64 `json:"assetamount"`
TokenAmount uint64 `json:"tokenamount"`
}
Issuance holds Elements asset issuance data attached to a transaction input.
type PoolCreationRecord ¶
type PoolCreationRecord struct {
TxID string // creation transaction ID
Asset0 string // display hex (reversed from internal)
Asset1 string // display hex
FeeNum uint16
FeeDen uint16
Height int // block height (-1 if unconfirmed)
}
PoolCreationRecord holds parameters decoded from an ANCHR OP_RETURN output.
func ParseAnchorOutput ¶
func ParseAnchorOutput(scriptHex, txid string, height int) (PoolCreationRecord, bool)
ParseAnchorOutput attempts to decode an ANCHR OP_RETURN from a scriptPubKey hex.
func ScanPoolCreations ¶
func ScanPoolCreations(c *Client, asset0, asset1 string, startHeight int) ([]PoolCreationRecord, error)
ScanPoolCreations scans blocks from startHeight to the chain tip for ANCHR OP_RETURN outputs. Uses the Esplora block and block-tx endpoints which are indexed and much faster than RPC block-by-block scanning.
If asset0 or asset1 is non-empty, only records matching both assets are returned (case-insensitive). Pass "" to return all pools.
type Tx ¶
type Tx struct {
TxID string `json:"txid"`
Version int `json:"version"`
Locktime int `json:"locktime"`
Size int `json:"size"`
Weight int `json:"weight"`
Fee uint64 `json:"fee"`
Vin []TxVin `json:"vin"`
Vout []TxVout `json:"vout"`
Status TxStatus `json:"status"`
}
Tx is a transaction from the Esplora API.
type TxStatus ¶
type TxStatus struct {
Confirmed bool `json:"confirmed"`
BlockHeight int `json:"block_height"`
BlockHash string `json:"block_hash"`
BlockTime int64 `json:"block_time"`
}
TxStatus holds confirmation info for a transaction or UTXO.
type TxVin ¶
type TxVin struct {
TxID string `json:"txid"`
Vout uint32 `json:"vout"`
Prevout *TxVout `json:"prevout"`
Issuance *Issuance `json:"issuance"`
IsCoinbase bool `json:"is_coinbase"`
Sequence uint32 `json:"sequence"`
}
TxVin is a transaction input.
type TxVout ¶
type TxVout struct {
ScriptPubKey string `json:"scriptpubkey"`
ScriptPubKeyAsm string `json:"scriptpubkey_asm"`
ScriptPubKeyType string `json:"scriptpubkey_type"`
ScriptPubKeyAddr string `json:"scriptpubkey_address"`
Value uint64 `json:"value"`
Asset string `json:"asset"`
}
TxVout is a transaction output.