Documentation
¶
Index ¶
- type Client
- func (c *Client) BroadcastRawTx(ctx context.Context, rawTx []byte) (string, error)
- func (c *Client) CreateTxUsePSBTv0(ctx context.Context, inputParams *types.TxInputParams) (string, error)
- func (c *Client) FinalizePSBT(ctx context.Context, signedPSBT string) ([]byte, error)
- func (c *Client) GetRawTx(ctx context.Context, txid string) ([]byte, error)
- func (c *Client) GetTx(ctx context.Context, txid string) (*types.Tx, error)
- func (c *Client) MsgTxToPSBTV0(ctx context.Context, tx *wire.MsgTx, inputParams *types.TxInputParams, ...) (*types.TxUnsignedPSBT, error)
- func (c *Client) TransferAllToNewAddress(ctx context.Context, toAddress string, privateKeyWIF string, ...) (string, error)
- func (c *Client) ValidateSignedPsbtBase64(ctx context.Context, psbtBase64 string) (string, error)
- func (c *Client) ValidateUnsignedPsbtBase64(ctx context.Context, psbtBase64 string) error
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 (*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
接收OKX签名后的交易数据并解析
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
校验已签名psbt的base64串
Click to show internal directories.
Click to hide internal directories.