tx

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2025 License: MIT Imports: 20 Imported by: 0

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(bitcoindrpcClient *bitcoindrpc.Client, mempoolapisClient *mempoolapis.Client, electrumxClient *electrumx.Client, addressClient *address.Client) *Client

NewWithElectrumX 创建包含ElectrumX支持的交易客户端

func (*Client) BroadcastRawTx added in v0.1.0

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

广播交易

func (*Client) CreateTxUsePSBTv0 added in v0.1.0

func (c *Client) CreateTxUsePSBTv0(ctx context.Context, inputParams *types.TxInputParams) (string, error)

转账交易-使用PSBTv0版本

func (*Client) FinalizePSBT added in v0.1.0

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

接收OKX签名后的交易数据并解析

func (*Client) GetRawTx

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

查询交易元数据: 优先使用bitcoindrpc, 如果没有再使用mempoolapis

func (*Client) GetTx

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

按照types.Tx格式返回交易数据

func (*Client) MsgTxToPSBTV0 added in v0.1.0

func (c *Client) MsgTxToPSBTV0(ctx context.Context, tx *wire.MsgTx, inputParams *types.TxInputParams, utxos []*types.TxUTXO) (*types.TxUnsignedPSBT, error)

将交易 MsgTx 转为 PSBTv0 格式; 因为btcd还不支持v2, 暂时使用v0;

func (*Client) TransferAllToNewAddress added in v0.2.2

func (c *Client) TransferAllToNewAddress(
	ctx context.Context,
	toAddress string,
	privateKeyWIF string,
	fromAddress string,
	feeRate float64) (string, error)

TransferAllToNewAddress 将给定私钥+对应fromAddress的所有余额转移到toAddress 这是一个紧急避险功能,用于将泄露私钥的地址的余额快速转移到安全地址

功能说明: - 使用ElectrumX查询UTXO(如果可用),否则使用Bitcoin Core的scantxoutset - 使用Mempool.space获取费率(如果可用),否则使用Bitcoin Core的estimatesmartfee - 使用PSBT签名流程,支持所有地址类型(P2PKH、P2SH、P2WPKH、P2TR) - 自动计算最优手续费,最大化转账金额

func (*Client) ValidateSignedPsbtBase64 added in v0.1.1

func (c *Client) ValidateSignedPsbtBase64(ctx context.Context, psbtBase64 string) (string, error)

校验已签名psbt的base64串

func (*Client) ValidateUnsignedPsbtBase64 added in v0.1.1

func (c *Client) ValidateUnsignedPsbtBase64(ctx context.Context, psbtBase64 string) error

校验psbt base64串是否合法

Jump to

Keyboard shortcuts

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