Documentation
ยถ
Index ยถ
- Constants
- Variables
- func APICommands() map[protocol.Command]reflect.Type
- func Call(ctx context.Context, c *protocol.Conn, payload any) (protocol.Command, string, any, error)
- func Read(ctx context.Context, c protocol.APIConn) (protocol.Command, string, any, error)
- func ReadConn(ctx context.Context, c *protocol.Conn) (protocol.Command, string, any, error)
- func Write(ctx context.Context, c protocol.APIConn, id string, payload any) error
- func WriteConn(ctx context.Context, c *protocol.Conn, id string, payload any) error
- type BalanceByAddressRequest
- type BalanceByAddressResponse
- type Block
- type BlockByHashRawRequest
- type BlockByHashRawResponse
- type BlockByHashRequest
- type BlockByHashResponse
- type BlockDownloadAsyncRawRequest
- type BlockDownloadAsyncRawResponse
- type BlockDownloadAsyncRequest
- type BlockDownloadAsyncResponse
- type BlockHeader
- type BlockHeaderBestRawRequest
- type BlockHeaderBestRawResponse
- type BlockHeaderBestRequest
- type BlockHeaderBestResponse
- type BlockHeadersByHeightRawRequest
- type BlockHeadersByHeightRawResponse
- type BlockHeadersByHeightRequest
- type BlockHeadersByHeightResponse
- type BlockInsertRawRequest
- type BlockInsertRawResponse
- type BlockInsertRequest
- type BlockInsertResponse
- type BlocksByL2AbrevHashesRequest
- type BlocksByL2AbrevHashesResponse
- type FeeEstimate
- type FeeEstimateRequest
- type FeeEstimateResponse
- type KeystoneTx
- type KeystoneTxsByL2KeystoneAbrevHashRequest
- type KeystoneTxsByL2KeystoneAbrevHashResponse
- type KeystonesByHeightRequest
- type KeystonesByHeightResponse
- type L2KeystoneBlockInfo
- type MempoolInfoRequest
- type MempoolInfoResponse
- type OutPoint
- type PingRequest
- type PingResponse
- type Tx
- type TxBroadcastRawRequest
- type TxBroadcastRawResponse
- type TxBroadcastRequest
- type TxBroadcastResponse
- type TxByIdRawRequest
- type TxByIdRawResponse
- type TxByIdRequest
- type TxByIdResponse
- type TxIn
- type TxOut
- type TxWitness
- type UTXO
- type UTXOsByAddressRawRequest
- type UTXOsByAddressRawResponse
- type UTXOsByAddressRequest
- type UTXOsByAddressResponse
Constants ยถ
const ( APIVersion = 1 CmdPingRequest = "tbcapi-ping-request" CmdPingResponse = "tbcapi-ping-response" CmdBlockByHashRawRequest = "tbcapi-block-by-hash-raw-request" CmdBlockByHashRawResponse = "tbcapi-block-by-hash-raw-response" CmdBlockByHashRequest = "tbcapi-block-by-hash-request" CmdBlockByHashResponse = "tbcapi-block-by-hash-response" CmdBlockHeadersByHeightRawRequest = "tbcapi-block-headers-by-height-raw-request" CmdBlockHeadersByHeightRawResponse = "tbcapi-block-headers-by-height-raw-response" CmdBlockHeadersByHeightRequest = "tbcapi-block-headers-by-height-request" CmdBlockHeadersByHeightResponse = "tbcapi-block-headers-by-height-response" CmdBlockHeaderBestRawRequest = "tbcapi-block-header-best-raw-request" CmdBlockHeaderBestRawResponse = "tbcapi-block-header-best-raw-response" CmdBlockHeaderBestRequest = "tbcapi-block-header-best-request" CmdBlockHeaderBestResponse = "tbcapi-block-header-best-response" CmdBalanceByAddressRequest = "tbcapi-balance-by-address-request" CmdBalanceByAddressResponse = "tbcapi-balance-by-address-response" CmdUTXOsByAddressRawRequest = "tbcapi-utxos-by-address-raw-request" CmdUTXOsByAddressRawResponse = "tbcapi-utxos-by-address-raw-response" CmdUTXOsByAddressRequest = "tbcapi-utxos-by-address-request" CmdUTXOsByAddressResponse = "tbcapi-utxos-by-address-response" CmdTxByIdRawRequest = "tbcapi-tx-by-id-raw-request" CmdTxByIdRawResponse = "tbcapi-tx-by-id-raw-response" CmdTxByIdRequest = "tbcapi-tx-by-id-request" CmdTxByIdResponse = "tbcapi-tx-by-id-response" CmdTxBroadcastRequest = "tbcapi-tx-broadcast-request" CmdTxBroadcastResponse = "tbcapi-tx-broadcast-response" CmdTxBroadcastRawRequest = "tbcapi-tx-broadcast-raw-request" CmdTxBroadcastRawResponse = "tbcapi-tx-broadcast-raw-response" CmdBlockInsertRequest = "tbcapi-block-insert-request" CmdBlockInsertResponse = "tbcapi-block-insert-response" CmdBlockInsertRawRequest = "tbcapi-block-insert-raw-request" CmdBlockInsertRawResponse = "tbcapi-block-insert-raw-response" CmdBlockDownloadAsyncRequest = "tbcapi-block-download-async-request" CmdBlockDownloadAsyncResponse = "tbcapi-block-download-async-response" CmdBlockDownloadAsyncRawRequest = "tbcapi-block-download-async-raw-request" CmdBlockDownloadAsyncRawResponse = "tbcapi-block-download-async-raw-response" CmdBlocksByL2AbrevHashesRequest = "tbcapi-block-by-l2-abrev-hash-request" CmdBlocksByL2AbrevHashesResponse = "tbcapi-block-by-l2-abrev-hash-response" CmdKeystoneTxsByL2KeystoneAbrevHashRequest = "tbcapi-l2-keystone-txs-by-abrev-hash-request" CmdKeystoneTxsByL2KeystoneAbrevHashResponse = "tbcapi-l2-keystone-txs-by-abrev-hash-response" CmdFeeEstimateRequest = "tbcapi-fee-estimate-request" CmdFeeEstimateResponse = "tbcapi-fee-estimate-response" CmdMempoolInfoRequest = "tbcapi-mempool-info-request" CmdMempoolInfoResponse = "tbcapi-mempool-info-response" CmdKeystonesByHeightRequest = "tbcapi-keystones-by-height-request" CmdKeystonesByHeightResponse = "tbcapi-keystones-by-height-response" )
Variables ยถ
var ( APIVersionRoute = fmt.Sprintf("v%d", APIVersion) RouteWebsocket = fmt.Sprintf("/%s/ws", APIVersionRoute) DefaultListen = "localhost:8082" DefaultURL = fmt.Sprintf("ws://%s/%s", DefaultListen, RouteWebsocket) )
Functions ยถ
func Call ยถ
func Call(ctx context.Context, c *protocol.Conn, payload any) (protocol.Command, string, any, error)
Call is a blocking call. One should use ReadConn when using Call or else the completion will end up in the Read instead of being completed as expected.
func Read ยถ
Read is the low level primitive of a protocol Read. One should generally not use this function and use ReadConn instead.
func ReadConn ยถ
ReadConn reads from Conn and performs callbacks. One should use ReadConn over Read when mixing Write, WriteConn and Call.
Types ยถ
type BalanceByAddressRequest ยถ
type BalanceByAddressRequest struct {
Address string `json:"address"`
}
type Block ยถ
type Block struct {
Hash chainhash.Hash `json:"hash"`
Header BlockHeader `json:"header"`
Txs []Tx `json:"txs"`
}
Block represents a Bitcoin block.
type BlockByHashRawRequest ยถ
BlockByHashRawRequest requests a raw block by its hash.
type BlockByHashRawResponse ยถ
type BlockByHashRawResponse struct {
Block api.ByteSlice `json:"block"`
Error *protocol.Error `json:"error,omitempty"`
}
BlockByHashRawResponse is the response for BlockByHashRawRequest.
type BlockByHashRequest ยถ
BlockByHashRequest requests a Block by its hash.
type BlockByHashResponse ยถ
type BlockByHashResponse struct {
Block *Block `json:"block"`
Error *protocol.Error `json:"error,omitempty"`
}
BlockByHashResponse is the response for BlockByHashRequest.
type BlockDownloadAsyncRequest ยถ
type BlockDownloadAsyncRequest struct {
Hash chainhash.Hash `json:"hash"`
Peers uint `json:"peers"`
}
BlockDownloadAsyncResponse returns a block if it exists or attempts to download the block from p2p asynchronously.
type BlockDownloadAsyncResponse ยถ
type BlockDownloadAsyncResponse struct {
Block *wire.MsgBlock `json:"block,omitempty"`
Error *protocol.Error `json:"error,omitempty"`
}
BlockDownloadAsyncResponse replies with a block, an error or nothing. When bot Error and Block are nil it measn the block download request was issued to p2p.
type BlockHeader ยถ
type BlockHeader struct {
Version int32 `json:"version"`
PrevHash chainhash.Hash `json:"prev_hash"`
MerkleRoot chainhash.Hash `json:"merkle_root"`
Timestamp int64 `json:"timestamp"`
Bits string `json:"bits"`
Nonce uint32 `json:"nonce"`
}
BlockHeader represents a Bitcoin block header.
type BlockHeaderBestRawRequest ยถ
type BlockHeaderBestRawRequest struct{}
type BlockHeaderBestRequest ยถ
type BlockHeaderBestRequest struct{}
type BlockHeaderBestResponse ยถ
type BlockHeaderBestResponse struct {
Height uint64 `json:"height"`
BlockHeader *BlockHeader `json:"block_header"`
Error *protocol.Error `json:"error,omitempty"`
}
type BlockHeadersByHeightRawRequest ยถ
type BlockHeadersByHeightRawRequest struct {
Height uint32 `json:"height"`
}
type BlockHeadersByHeightRequest ยถ
type BlockHeadersByHeightRequest struct {
Height uint32 `json:"height"`
}
type BlockHeadersByHeightResponse ยถ
type BlockHeadersByHeightResponse struct {
BlockHeaders []*BlockHeader `json:"block_headers"`
Error *protocol.Error `json:"error,omitempty"`
}
type BlockInsertRawRequest ยถ
type BlockInsertRawResponse ยถ
type BlockInsertRequest ยถ
type BlockInsertResponse ยถ
type FeeEstimate ยถ
type FeeEstimateRequest ยถ
type FeeEstimateRequest struct{}
type FeeEstimateResponse ยถ
type FeeEstimateResponse struct {
FeeEstimates []*FeeEstimate `json:"fee_estimate"`
Error *protocol.Error `json:"error,omitempty"`
}
type KeystoneTx ยถ
type KeystoneTxsByL2KeystoneAbrevHashRequest ยถ
type KeystoneTxsByL2KeystoneAbrevHashRequest struct {
L2KeystoneAbrevHash chainhash.Hash `json:"l2_keystone_abrev_hash"`
Depth uint `json:"depth"`
}
KeystoneTxsByL2KeystoneAbrevHashRequest retrieve raw keystone tx's starting from L2KeystoneAbrevHash for up to Depth blocks. Depth cannot be negative since the hash is guaranteed to be the first occurrence.
type KeystoneTxsByL2KeystoneAbrevHashResponse ยถ
type KeystoneTxsByL2KeystoneAbrevHashResponse struct {
KeystoneTxs []KeystoneTx `json:"keystone_txs"`
Error *protocol.Error `json:"error,omitempty"`
}
type KeystonesByHeightResponse ยถ
type KeystonesByHeightResponse struct {
L2KeystoneAbrevs []*hemi.L2KeystoneAbrev `json:"l2_keystone_abrevs"`
BTCTipHeight uint64 `json:"btc_tip_height"`
Error *protocol.Error `json:"error,omitempty"`
}
type L2KeystoneBlockInfo ยถ
type MempoolInfoRequest ยถ
type MempoolInfoRequest struct{}
type MempoolInfoResponse ยถ
type PingRequest ยถ
type PingRequest protocol.PingRequest
type PingResponse ยถ
type PingResponse protocol.PingResponse
type Tx ยถ
type Tx struct {
Version int32 `json:"version"`
LockTime uint32 `json:"lock_time"`
TxIn []*TxIn `json:"tx_in"`
TxOut []*TxOut `json:"tx_out"`
}
Tx represents a Bitcoin transaction.
type TxBroadcastRawRequest ยถ
type TxBroadcastRawResponse ยถ
type TxBroadcastRequest ยถ
type TxBroadcastResponse ยถ
type TxByIdRawRequest ยถ
type TxByIdRawResponse ยถ
type TxByIdRequest ยถ
type TxByIdResponse ยถ
type TxIn ยถ
type TxIn struct {
PreviousOutPoint OutPoint `json:"outpoint"`
SignatureScript api.ByteSlice `json:"signature_script"`
Witness TxWitness `json:"tx_witness"`
Sequence uint32 `json:"sequence"`
}
TxIn represents a Bitcoin transaction input.
type UTXO ยถ
type UTXO struct {
TxId chainhash.Hash `json:"tx_id"`
Value btcutil.Amount `json:"value"`
OutIndex uint32 `json:"out_index"`
}
UTXO represents a Bitcoin unspent transaction output.