Documentation
¶
Overview ¶
校验数据的基本格式.
Index ¶
- type Client
- func (c *Client) BatchGetBalancesWithElectrumX(ctx context.Context, addresses []string, concurrent int) ([]types.AddressBalanceInfo, error)
- func (c *Client) BroadcastRawTx(ctx context.Context, rawtx []byte) (string, error)
- func (c *Client) CheckFormatAddress(s string) error
- func (c *Client) CheckFormatBase64(s string) error
- func (c *Client) CheckFormatHex(s string) error
- func (c *Client) CheckFormatTxid(s string) error
- func (c *Client) CreateNewWallet(ctx context.Context) (*types.WalletInfo, error)
- func (c *Client) CreatePSBT(ctx context.Context, inputParams *types.TxInputParams) (string, error)
- func (c *Client) DecodeAddressToPkScript(addr string) ([]byte, error)
- func (c *Client) DecodeAddressToScriptInfo(addr string) (*types.AddressScriptInfo, error)
- func (c *Client) DecodeAddressToType(addr string) (types.AddressType, error)
- func (c *Client) DecodePKScriptToType(pkScript []byte) (types.AddressType, error)
- func (c *Client) DecodePkScriptToAddressInfo(pkScript []byte) (*types.AddressInfo, error)
- func (c *Client) DecodePkScriptToAsmString(pkScript []byte) (ops []types.ScriptOp, asm string, err error)
- func (c *Client) DecodeRawTx(rawtx []byte) (*types.Tx, error)
- func (c *Client) DecodeRawTxString(rawHex string) (*types.Tx, error)
- func (c *Client) EstimateFeeRate(ctx context.Context, targetBlocks int) (float64, float64, error)
- func (c *Client) FilterAddressesWithBalanceWithElectrumX(ctx context.Context, addresses []string, concurrent int) ([]types.AddressBalanceInfo, error)
- func (c *Client) FinalizePSBTAndBroadcast(ctx context.Context, psbt string) (string, error)
- func (c *Client) GetAddressBalance(ctx context.Context, addr string) (confirmed float64, mempool float64, err error)
- func (c *Client) GetAddressBalanceWithElectrumX(ctx context.Context, addr string) (confirmed float64, mempool float64, err error)
- func (c *Client) GetAddressBalanceWithElectrumXByPrivateKey(ctx context.Context, privateKeyWIF string) (*types.AddressBalanceInfo, error)
- func (c *Client) GetAddressBalanceWithElectrumXByXPRV(ctx context.Context, xprv string, numAddresses uint32) ([]types.AddressBalanceInfo, error)
- func (c *Client) GetAddressUTXOs(ctx context.Context, addr string) ([]types.TxUTXO, error)
- func (c *Client) GetTx(ctx context.Context, txid string) (*types.Tx, error)
- func (c *Client) GetTxRaw(ctx context.Context, txid string) ([]byte, error)
- func (c *Client) ImportAddressAndPublickey(ctx context.Context, address string, publickey string) 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
- type Config
- type TestClient
- func (c *TestClient) GetBlockChainInfo(ctx context.Context) (*bitcoindrpc.ChainInfoDTO, error)
- func (c *TestClient) GetBlockCount(ctx context.Context) (int64, error)
- func (c *TestClient) GetBlockStats(ctx context.Context, height int64) (*bitcoindrpc.BlockStatsDTO, error)
- func (c *TestClient) GetChainTips(ctx context.Context) ([]bitcoindrpc.ChainTipDTO, error)
- func (c *TestClient) GetNetworkInfo(ctx context.Context) (*bitcoindrpc.NetworkInfoDTO, 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 NewWithElectrumX ¶ added in v0.2.0
func NewWithElectrumX(network string, rpc_url, rpc_user, rpc_pass string, electrumx_url string, timeout int) *Client
NewWithElectrumX 创建包含ElectrumX支持的客户端
func (*Client) BatchGetBalancesWithElectrumX ¶ added in v0.2.1
func (c *Client) BatchGetBalancesWithElectrumX(ctx context.Context, addresses []string, concurrent int) ([]types.AddressBalanceInfo, error)
批量查询所有地址余额
func (*Client) BroadcastRawTx ¶ added in v0.1.0
广播签名
func (*Client) CheckFormatAddress ¶ added in v0.1.2
校验地址是否合法
func (*Client) CheckFormatBase64 ¶ added in v0.1.2
helper 校验base64字符串是否合法
func (*Client) CheckFormatHex ¶ added in v0.1.2
helper 校验hex字符串是否合法
func (*Client) CheckFormatTxid ¶ added in v0.1.2
校验交易id是否合法
func (*Client) CreateNewWallet ¶ added in v0.2.0
创建新钱包
func (*Client) CreatePSBT ¶
创建PSBT预览交易数据(钱包未签名状态)
func (*Client) DecodeAddressToPkScript ¶ added in v0.1.0
通过地址获取锁定脚本
func (*Client) DecodeAddressToScriptInfo ¶ added in v0.1.0
func (c *Client) DecodeAddressToScriptInfo(addr string) (*types.AddressScriptInfo, error)
通过地址获取地址的详细信息
func (*Client) DecodeAddressToType ¶ added in v0.1.0
func (c *Client) DecodeAddressToType(addr string) (types.AddressType, error)
通过地址获取类型
func (*Client) DecodePKScriptToType ¶ added in v0.1.0
func (c *Client) DecodePKScriptToType(pkScript []byte) (types.AddressType, error)
通过脚本获取类型
func (*Client) DecodePkScriptToAddressInfo ¶ added in v0.1.0
func (c *Client) DecodePkScriptToAddressInfo(pkScript []byte) (*types.AddressInfo, error)
通过脚本获取地址信息
func (*Client) DecodePkScriptToAsmString ¶ added in v0.1.0
func (c *Client) DecodePkScriptToAsmString(pkScript []byte) (ops []types.ScriptOp, asm string, err error)
解析脚本为操作码
func (*Client) DecodeRawTx ¶
解析一笔交易元数据 => 适用于外部直接输入交易元数据解析结构
func (*Client) DecodeRawTxString ¶ added in v0.1.1
解析一笔交易元数据 => 适用于外部直接输入交易元数据解析结构(十六进制字符串)
func (*Client) EstimateFeeRate ¶
EstimateFeeRate 估计手续费.
func (*Client) FilterAddressesWithBalanceWithElectrumX ¶ added in v0.2.1
func (c *Client) FilterAddressesWithBalanceWithElectrumX(ctx context.Context, addresses []string, concurrent int) ([]types.AddressBalanceInfo, error)
批量查询并过滤有余额的地址
func (*Client) FinalizePSBTAndBroadcast ¶ added in v0.1.0
上传经过钱包签名的PSBT数据并进行广播;
func (*Client) GetAddressBalance ¶ added in v0.1.0
func (c *Client) GetAddressBalance(ctx context.Context, addr string) (confirmed float64, mempool float64, err error)
GetAddressBalance 返回地址的确认余额和未确认余额.
func (*Client) GetAddressBalanceWithElectrumX ¶ added in v0.2.1
func (c *Client) GetAddressBalanceWithElectrumX(ctx context.Context, addr string) (confirmed float64, mempool float64, err error)
GetAddressBalanceWithElectrumX 返回地址的确认余额和未确认余额.
func (*Client) GetAddressBalanceWithElectrumXByPrivateKey ¶ added in v0.2.1
func (c *Client) GetAddressBalanceWithElectrumXByPrivateKey(ctx context.Context, privateKeyWIF string) (*types.AddressBalanceInfo, error)
通过私钥查询余额
func (*Client) GetAddressBalanceWithElectrumXByXPRV ¶ added in v0.2.1
func (c *Client) GetAddressBalanceWithElectrumXByXPRV(ctx context.Context, xprv string, numAddresses uint32) ([]types.AddressBalanceInfo, error)
通过扩展私钥查询余额
func (*Client) GetAddressUTXOs ¶
GetAddressUTXOs 返回地址拥有的UTXO.
func (*Client) ImportAddressAndPublickey ¶
func (c *Client) ImportAddressAndPublickey(ctx context.Context, address string, publickey string) error
上传钱包+publickey, 用于后续组装PSBT等数据, 后续需要在postgres创建映射;
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)
transfer all to new address
func (*Client) ValidateSignedPsbtBase64 ¶ added in v0.1.1
校验已签名psbt的base64串
type TestClient ¶
type TestClient struct {
// contains filtered or unexported fields
}
func NewTestClient ¶
func NewTestClient(client *Client) *TestClient
func (*TestClient) GetBlockChainInfo ¶ added in v0.1.0
func (c *TestClient) GetBlockChainInfo(ctx context.Context) (*bitcoindrpc.ChainInfoDTO, error)
获取链信息
func (*TestClient) GetBlockCount ¶ added in v0.1.1
func (c *TestClient) GetBlockCount(ctx context.Context) (int64, error)
GetBlockCount
func (*TestClient) GetBlockStats ¶ added in v0.1.0
func (c *TestClient) GetBlockStats(ctx context.Context, height int64) (*bitcoindrpc.BlockStatsDTO, error)
获取区块统计信息
func (*TestClient) GetChainTips ¶ added in v0.1.0
func (c *TestClient) GetChainTips(ctx context.Context) ([]bitcoindrpc.ChainTipDTO, error)
获取链顶信息
func (*TestClient) GetNetworkInfo ¶
func (c *TestClient) GetNetworkInfo(ctx context.Context) (*bitcoindrpc.NetworkInfoDTO, error)
获取节点网络信息
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
adapters/bitcoindrpc
Package bitcoindrpc 提供Bitcoin Core JSON-RPC客户端
|
Package bitcoindrpc 提供Bitcoin Core JSON-RPC客户端 |
|
adapters/electrumx
ElectrumX API接口实现
|
ElectrumX API接口实现 |
|
adapters/mempoolapis
Package mempoolspace 提供mempool.space REST API客户端
|
Package mempoolspace 提供mempool.space REST API客户端 |
|
decoders
提供一些通用的解析函数
|
提供一些通用的解析函数 |
|
pkg
|
|
|
示例代码备用参考: 锁定脚本/解锁脚本/自定义逻辑脚等
|
示例代码备用参考: 锁定脚本/解锁脚本/自定义逻辑脚等 |
Click to show internal directories.
Click to hide internal directories.