mempool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBaseURL = "https://mempool.space/api"

Variables

View Source
var UserAgent = "ompool"

UserAgent identifies ompool to the API. main sets it to include the version.

Functions

This section is empty.

Types

type Block

type Block struct {
	ID        string `json:"id"`
	Height    int64  `json:"height"`
	Timestamp int64  `json:"timestamp"`
	TxCount   int    `json:"tx_count"`
	Size      int64  `json:"size"`
	Weight    int64  `json:"weight"`
	Extras    struct {
		Reward        int64     `json:"reward"`
		MedianFee     float64   `json:"medianFee"`
		FeeRange      []float64 `json:"feeRange"`
		TotalFees     int64     `json:"totalFees"`
		AvgFee        int64     `json:"avgFee"`
		AvgFeeRate    float64   `json:"avgFeeRate"`
		AvgTxSize     float64   `json:"avgTxSize"`
		SegwitTotalTx int       `json:"segwitTotalTxs"`
		MatchRate     float64   `json:"matchRate"`
		Pool          struct {
			Name string `json:"name"`
			Slug string `json:"slug"`
		} `json:"pool"`
	} `json:"extras"`
}

type Client

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

func NewClient

func NewClient(baseURL string) *Client

func (*Client) FetchBlockHistory

func (c *Client) FetchBlockHistory(ctx context.Context, tip int64, pages int) ([]Block, error)

FetchBlockHistory requests older v1 block pages concurrently. The caller supplies the current tip, allowing deterministic non-overlapping 15-block windows without a serial pagination waterfall.

func (*Client) FetchMining

func (c *Client) FetchMining(ctx context.Context) (MiningStats, error)

FetchMining loads slower-moving mining analytics independently from the core snapshot so screens that do not display them avoid the extra requests.

func (*Client) FetchOverview

func (c *Client) FetchOverview(ctx context.Context) (Overview, error)

func (*Client) FetchTransaction

func (c *Client) FetchTransaction(ctx context.Context, txid string) (TransactionInspection, error)

FetchTransaction loads the decoded transaction, its raw serialization, and output-spend state concurrently so the viewer can describe both sides of the UTXO exchange without serial request latency.

func (*Client) StreamStats

func (c *Client) StreamStats(ctx context.Context) <-chan LiveStats

type DifficultyAdjustment

type DifficultyAdjustment struct {
	ProgressPercent       float64 `json:"progressPercent"`
	DifficultyChange      float64 `json:"difficultyChange"`
	EstimatedRetargetDate int64   `json:"estimatedRetargetDate"`
	RemainingBlocks       int     `json:"remainingBlocks"`
	RemainingTime         int64   `json:"remainingTime"`
	NextRetargetHeight    int64   `json:"nextRetargetHeight"`
}

type DifficultyPoint

type DifficultyPoint struct {
	Time       int64   `json:"time"`
	Height     int64   `json:"height"`
	Difficulty float64 `json:"difficulty"`
	Adjustment float64 `json:"adjustment"`
}

type Fees

type Fees struct {
	Fastest  int     `json:"fastestFee"`
	HalfHour int     `json:"halfHourFee"`
	Hour     int     `json:"hourFee"`
	Economy  int     `json:"economyFee"`
	Minimum  float64 `json:"minimumFee"`
}

type HashratePoint

type HashratePoint struct {
	Timestamp   int64   `json:"timestamp"`
	AvgHashrate float64 `json:"avgHashrate"`
}

type HashrateStats

type HashrateStats struct {
	Hashrates         []HashratePoint   `json:"hashrates"`
	Difficulty        []DifficultyPoint `json:"difficulty"`
	CurrentHashrate   float64           `json:"currentHashrate"`
	CurrentDifficulty float64           `json:"currentDifficulty"`
}

type LiveStats

type LiveStats struct {
	VBytesPerSecond float64 `json:"vBytesPerSecond"`
	HasFlow         bool
	Transactions    []Transaction `json:"transactions"`
}

type Mempool

type Mempool struct {
	Count    int     `json:"count"`
	VSize    int64   `json:"vsize"`
	TotalFee float64 `json:"total_fee"`
}

type MiningPool

type MiningPool struct {
	Name         string  `json:"name"`
	Slug         string  `json:"slug"`
	BlockCount   int     `json:"blockCount"`
	Rank         int     `json:"rank"`
	EmptyBlocks  int     `json:"emptyBlocks"`
	AvgMatchRate float64 `json:"avgMatchRate"`
}

type MiningStats

type MiningStats struct {
	Hashrate HashrateStats
	Pools    PoolStats
	Rewards  RewardStats
}

type Outspend

type Outspend struct {
	Spent  bool              `json:"spent"`
	TxID   string            `json:"txid"`
	Vin    int               `json:"vin"`
	Status TransactionStatus `json:"status"`
}

type Overview

type Overview struct {
	Fees            Fees
	Mempool         Mempool
	Blocks          []Block
	ProjectedBlocks []ProjectedBlock
	Difficulty      DifficultyAdjustment
	Recent          []Transaction
	Prices          Prices
	Mining          MiningStats
	Fetched         time.Time
}

type PoolStats

type PoolStats struct {
	Pools                 []MiningPool `json:"pools"`
	BlockCount            int          `json:"blockCount"`
	LastEstimatedHashrate float64      `json:"lastEstimatedHashrate"`
}

type Prices

type Prices struct {
	USD float64 `json:"USD"`
}

type ProjectedBlock

type ProjectedBlock struct {
	BlockSize  int64     `json:"blockSize"`
	BlockVSize float64   `json:"blockVSize"`
	TxCount    int       `json:"nTx"`
	TotalFees  float64   `json:"totalFees"`
	MedianFee  float64   `json:"medianFee"`
	FeeRange   []float64 `json:"feeRange"`
}

type RewardStats

type RewardStats struct {
	StartBlock  int64  `json:"startBlock"`
	EndBlock    int64  `json:"endBlock"`
	TotalReward string `json:"totalReward"`
	TotalFee    string `json:"totalFee"`
	TotalTx     string `json:"totalTx"`
}

type Transaction

type Transaction struct {
	TxID  string  `json:"txid"`
	Fee   int64   `json:"fee"`
	VSize float64 `json:"vsize"`
	Value int64   `json:"value"`
}

type TransactionDetail

type TransactionDetail struct {
	TxID     string              `json:"txid"`
	Version  int                 `json:"version"`
	Locktime uint32              `json:"locktime"`
	Size     int64               `json:"size"`
	Weight   int64               `json:"weight"`
	Fee      int64               `json:"fee"`
	Vin      []TransactionInput  `json:"vin"`
	Vout     []TransactionOutput `json:"vout"`
	Status   TransactionStatus   `json:"status"`
}

TransactionDetail is the full transaction shape returned by the explorer endpoint. Prevout carries the UTXO consumed by an input; Vout contains the newly-created transaction outputs.

type TransactionInput

type TransactionInput struct {
	TxID         string             `json:"txid"`
	Vout         uint32             `json:"vout"`
	Prevout      *TransactionOutput `json:"prevout"`
	ScriptSig    string             `json:"scriptsig"`
	ScriptSigAsm string             `json:"scriptsig_asm"`
	Witness      []string           `json:"witness"`
	IsCoinbase   bool               `json:"is_coinbase"`
	Sequence     uint32             `json:"sequence"`
}

type TransactionInspection

type TransactionInspection struct {
	Transaction TransactionDetail
	RawHex      string
	Outspends   []Outspend
}

type TransactionOutput

type TransactionOutput struct {
	ScriptPubKey        string `json:"scriptpubkey"`
	ScriptPubKeyAsm     string `json:"scriptpubkey_asm"`
	ScriptPubKeyType    string `json:"scriptpubkey_type"`
	ScriptPubKeyAddress string `json:"scriptpubkey_address"`
	Value               int64  `json:"value"`
}

type TransactionStatus

type TransactionStatus struct {
	Confirmed   bool   `json:"confirmed"`
	BlockHeight int64  `json:"block_height"`
	BlockHash   string `json:"block_hash"`
	BlockTime   int64  `json:"block_time"`
}

Jump to

Keyboard shortcuts

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