btcapis

package module
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: 11 Imported by: 0

README

交易解析、验证、广播、费率估算 完整的 PSBT 构建、签名、最终化流程

Documentation

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(network string, rpc_url, rpc_user, rpc_pass string, timeout int) *Client

func (*Client) CreatePSBT

func (c *Client) CreatePSBT(ctx context.Context, inputParams *types.TxInputParams) (*psbt.BuildResult, error)

创建PSBT预览交易数据(钱包未签名状态)

func (*Client) DecodeRawTx

func (c *Client) DecodeRawTx(ctx context.Context, rawtx []byte) (*types.Tx, error)

解析一笔交易元数据 => 适用于外部直接输入交易元数据解析结构

func (*Client) EstimateFeeRate

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

EstimateFeeRate 估计手续费.

func (*Client) GetAddressBalanceBTC

func (c *Client) GetAddressBalanceBTC(ctx context.Context, addr string) (confirmed float64, mempool float64, err error)

func (*Client) GetAddressBalanceSats

func (c *Client) GetAddressBalanceSats(ctx context.Context, addr string) (confirmed int64, mempool int64, err error)

GetAddressBalance 返回地址的确认余额和未确认余额.

func (*Client) GetAddressInfo

func (c *Client) GetAddressInfo(ctx context.Context, pkScript []byte) (*types.AddressInfo, error)

func (*Client) GetAddressScriptInfo

func (c *Client) GetAddressScriptInfo(ctx context.Context, addr string) (*types.AddressScriptInfo, error)

GetAddressScriptInfo 返回地址的锁定脚本信息.

func (*Client) GetAddressUTXOs

func (c *Client) GetAddressUTXOs(ctx context.Context, addr string) ([]types.TxUTXO, error)

GetAddressUTXOs 返回地址拥有的UTXO.

func (*Client) GetTx

func (c *Client) GetTx(ctx context.Context, txid string) (*types.Tx, error)

查询交易信息 => 适用于通过txid查询详细交易信息

func (*Client) GetTxRaw

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

查询交易元数据

func (*Client) ImportAddressAndPublickey

func (c *Client) ImportAddressAndPublickey(ctx context.Context, address string, publickey string) error

上传钱包+publickey, 用于后续组装PSBT等数据, 后续需要在postgres创建映射;

func (*Client) SendBTCByPSBT

func (c *Client) SendBTCByPSBT(ctx context.Context, psbt string) (string, error)

上传经过钱包签名的PSBT数据, 用于后续广播交易;

type TestClient

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

func NewTestClient

func NewTestClient(client *Client) *TestClient

func (*TestClient) GetNetworkInfo

func (c *TestClient) GetNetworkInfo(ctx context.Context) (bitcoindrpc.NetworkInfoDTO, error)

Directories

Path Synopsis
examples
basic command
Package main 基础使用示例
Package main 基础使用示例
bitcoind_fee command
Package main Bitcoin Core费率估算示例
Package main Bitcoin Core费率估算示例
mempool_mix command
Package main 混合后端使用示例
Package main 混合后端使用示例
txdump command
internal
adapters/bitcoindrpc
Package bitcoindrpc 提供Bitcoin Core JSON-RPC客户端
Package bitcoindrpc 提供Bitcoin Core JSON-RPC客户端
adapters/mempoolapis
Package mempoolspace 提供mempool.space REST API客户端
Package mempoolspace 提供mempool.space REST API客户端
db
操作mysql
操作mysql
decoders
提供一些通用的解析函数
提供一些通用的解析函数
psbt
Package psbt PSBT处理
Package psbt PSBT处理
tx
types
示例代码备用参考: 锁定脚本/解锁脚本/自定义逻辑脚等
示例代码备用参考: 锁定脚本/解锁脚本/自定义逻辑脚等

Jump to

Keyboard shortcuts

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