Documentation
¶
Overview ¶
Package mempool is the library behind the mempool command line: the HTTP client, request shaping, and the typed data models for mempool.space.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public site throws under load.
Index ¶
- Constants
- type Address
- type Block
- type Client
- func (c *Client) GetAddress(ctx context.Context, address string) (*Address, error)
- func (c *Client) GetBlock(ctx context.Context, hash string) (*Block, error)
- func (c *Client) GetBlocks(ctx context.Context, limit int) ([]*Block, error)
- func (c *Client) GetFees(ctx context.Context) (*Fees, error)
- func (c *Client) GetPrice(ctx context.Context) (*Price, error)
- func (c *Client) GetTransaction(ctx context.Context, txid string) (*Transaction, error)
- type Config
- type Domain
- type Fees
- type Price
- type Transaction
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "mempool-cli/dev (+https://github.com/tamnd/mempool-cli)"
DefaultUserAgent identifies the client to mempool.space.
const Host = "mempool.space"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
Address string `kit:"id" json:"address"`
TxCount int `json:"tx_count"`
FundedSum int64 `json:"funded_sum"`
FundedCount int `json:"funded_count"`
SpentSum int64 `json:"spent_sum"`
Balance int64 `json:"balance"`
}
Address holds the chain stats for a Bitcoin address.
type Block ¶
type Block struct {
ID string `kit:"id" json:"id"`
Height int `json:"height"`
Timestamp int64 `json:"timestamp"`
Size int `json:"size"`
Weight int `json:"weight"`
TxCount int `json:"tx_count"`
TotalFees int64 `json:"total_fees"`
MedianFee float64 `json:"median_fee"`
AvgFee float64 `json:"avg_fee"`
}
Block holds summary data for a single Bitcoin block.
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to mempool.space over HTTP.
func (*Client) GetAddress ¶
GetAddress fetches the chain stats for a Bitcoin address.
func (*Client) GetBlocks ¶
GetBlocks fetches the most recent blocks. The API returns the last 10 blocks; limit <= 10 slices the result; limit 0 or > 10 returns all 10.
func (*Client) GetTransaction ¶
GetTransaction fetches a single transaction by its TXID.
type Domain ¶
type Domain struct{}
Domain is the mempool driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns any accepted input into the canonical (type, id). Bitcoin address (starts with 1, 3, bc1) -> "address" 64-char hex -> "tx" numeric -> "height" (not directly addressable, but classified) otherwise -> "block"
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Fees ¶
type Fees struct {
FastestFee int `kit:"id" json:"fastest_fee"`
HalfHourFee int `json:"half_hour_fee"`
HourFee int `json:"hour_fee"`
EconomyFee int `json:"economy_fee"`
MinimumFee int `json:"minimum_fee"`
}
Fees holds the current recommended fee rates in sat/vByte.
type Transaction ¶
type Transaction struct {
TXID string `kit:"id" json:"txid"`
Size int `json:"size"`
Weight int `json:"weight"`
Fee int64 `json:"fee"`
VinCount int `json:"vin_count"`
VoutCount int `json:"vout_count"`
Confirmed bool `json:"confirmed"`
BlockHeight int `json:"block_height"`
}
Transaction holds the data for a single Bitcoin transaction.