mempoolapis

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mempoolspace 提供mempool.space REST API客户端

mempool.space 原生数据结构定义

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(baseURL string, timeout int) *Client

func (*Client) AddressGetBalance

func (c *Client) AddressGetBalance(ctx context.Context, addr string) (int64, int64, error)

获取地址余额

func (*Client) AddressGetUTXOs

func (c *Client) AddressGetUTXOs(ctx context.Context, addr string) ([]UTXODTO, error)

获取地址 UTXO

func (*Client) EstimateFeeRate

func (c *Client) EstimateFeeRate(ctx context.Context, targetBlocks int) (*FeeRateDTO, error)

估算交易费率

func (*Client) TxBroadcast

func (c *Client) TxBroadcast(ctx context.Context, rawtx []byte) (string, error)

func (*Client) TxGetRaw

func (c *Client) TxGetRaw(ctx context.Context, txid string) ([]byte, error)

type FeeRateDTO

type FeeRateDTO struct {
	FastestFee  float64 `json:"fastestFee"`
	HalfHourFee float64 `json:"halfHourFee"`
	HourFee     float64 `json:"hourFee"`
}

估算交易费率数据结构

type TxDTO

type TxDTO struct {
	Txid     string `json:"txid"`
	Version  int32  `json:"version"`
	Locktime uint32 `json:"locktime"`
	Weight   int64  `json:"weight"`
	Size     int64  `json:"size"`

	Vin []struct {
		Txid      string   `json:"txid"`
		Vout      uint32   `json:"vout"`
		Sequence  uint32   `json:"sequence"`
		Scriptsig string   `json:"scriptsig"`
		Witness   []string `json:"witness"`
	} `json:"vin"`

	Vout []struct {
		Value        int64  `json:"value"` // sats
		ScriptPubKey string `json:"scriptpubkey"`
		ScriptType   string `json:"scriptpubkey_type"`
		Address      string `json:"scriptpubkey_address"`
	} `json:"vout"`
}

从mempool.space获取到的交易数据结构

type UTXODTO

type UTXODTO struct {
	Txid   string `json:"txid"`
	Vout   uint32 `json:"vout"`
	Value  int64  `json:"value"`
	Status struct {
		Confirmed   bool  `json:"confirmed"`
		BlockHeight int64 `json:"block_height"`
	} `json:"status"`
}

从mempool.space获取到的UTXO数据结构

Jump to

Keyboard shortcuts

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