Documentation
¶
Index ¶
- type Block
- type BlockHeader
- type BroadcastResponse
- type Client
- func (c *Client) BroadcastTransaction(ctx context.Context, rawTx string) (*BroadcastResponse, error)
- func (c *Client) GetBlockByHash(ctx context.Context, hash string) (*Block, error)
- func (c *Client) GetBlockByHeight(ctx context.Context, height int64) (*Block, error)
- func (c *Client) GetBlockHeader(ctx context.Context, hash string) (*BlockHeader, error)
- func (c *Client) GetBlockTransactions(ctx context.Context, blockHash string) ([]string, error)
- func (c *Client) GetTransaction(ctx context.Context, txid string) (*Transaction, error)
- func (c *Client) GetTransactionConfirmation(ctx context.Context, txid string) (*TransactionConfirmation, error)
- type ClientOption
- type Transaction
- type TransactionConfirmation
- type TxStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
ID string `json:"id"`
Height int64 `json:"height"`
Version int32 `json:"version"`
Timestamp int64 `json:"timestamp"`
TxCount int `json:"tx_count"`
Size int `json:"size"`
Weight int `json:"weight"`
MerkleRoot string `json:"merkle_root"`
PrevBlockID string `json:"previousblockhash"`
Nonce uint64 `json:"nonce"`
Bits int32 `json:"bits"`
Txids []string `json:"tx"` // Changed from "txids" to "tx"
}
Bitcoin block
type BlockHeader ¶
type BlockHeader struct {
Raw string `json:"raw"` // Raw header in hex format
Version int32 `json:"version"`
PreviousHash string `json:"previousblockhash"`
MerkleRoot string `json:"merkle_root"`
Timestamp int64 `json:"time"`
Bits string `json:"bits"`
Nonce uint64 `json:"nonce"`
}
Block Header
type BroadcastResponse ¶
type BroadcastResponse struct {
Txid string `json:"txid"`
}
BroadcastResponse represents the response from broadcasting a transaction
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a Bitcoin REST API client
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
NewClient creates a new Bitcoin REST API client
func (*Client) BroadcastTransaction ¶
func (c *Client) BroadcastTransaction(ctx context.Context, rawTx string) (*BroadcastResponse, error)
BroadcastTransaction broadcasts a raw transaction to the network
func (*Client) GetBlockByHash ¶
GetBlockByHash retrieves a block by its hash
func (*Client) GetBlockByHeight ¶
GetBlockByHeight retrieves a block by its height
func (*Client) GetBlockHeader ¶
GetBlockHeader retrieves block headers
func (*Client) GetBlockTransactions ¶
GetBlockTransactions retrieves transaction IDs for a given block hash
func (*Client) GetTransaction ¶
GetTransaction retrieves transaction details by txid
func (*Client) GetTransactionConfirmation ¶
func (c *Client) GetTransactionConfirmation(ctx context.Context, txid string) (*TransactionConfirmation, error)
GetTransactionConfirmation retrieves the confirmation status of a transaction
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a function that configures the Client
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL sets a custom base URL for the client
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets a custom timeout for the HTTP client
type Transaction ¶
type Transaction struct {
Txid string `json:"txid"`
Version int32 `json:"version"`
Size int `json:"size"`
Weight int `json:"weight"`
Fee int64 `json:"fee"`
Status TxStatus `json:"status"`
}
Transaction represents a Bitcoin transaction
type TransactionConfirmation ¶
type TransactionConfirmation struct {
Txid string `json:"txid"`
Confirmed bool `json:"confirmed"`
BlockHeight int64 `json:"block_height,omitempty"`
Confirmations int64 `json:"confirmations"`
BlockHash string `json:"block_hash,omitempty"`
BlockTime int64 `json:"block_time,omitempty"`
}
TransactionConfirmation contains confirmation details for a transaction