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 BlockKeystoneByL2KeystoneAbrevHashRequest
- type BlockKeystoneByL2KeystoneAbrevHashResponse
- 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" CmdBlockKeystoneByL2KeystoneAbrevHashRequest = "tbcapi-l2-keystone-abrev-by-abrev-hash-request" CmdBlockKeystoneByL2KeystoneAbrevHashResponse = "tbcapi-l2-keystone-abrev-by-abrev-hash-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 ยถ added in v0.3.8
type Block struct {
Hash chainhash.Hash `json:"hash"`
Header BlockHeader `json:"header"`
Txs []Tx `json:"txs"`
}
Block represents a Bitcoin block.
type BlockByHashRawRequest ยถ added in v0.3.8
BlockByHashRawRequest requests a raw block by its hash.
type BlockByHashRawResponse ยถ added in v0.3.8
type BlockByHashRawResponse struct {
Block api.ByteSlice `json:"block"`
Error *protocol.Error `json:"error,omitempty"`
}
BlockByHashRawResponse is the response for BlockByHashRawRequest.
type BlockByHashRequest ยถ added in v0.3.8
BlockByHashRequest requests a Block by its hash.
type BlockByHashResponse ยถ added in v0.3.8
type BlockByHashResponse struct {
Block *Block `json:"block"`
Error *protocol.Error `json:"error,omitempty"`
}
BlockByHashResponse is the response for BlockByHashRequest.
type BlockDownloadAsyncRawRequest ยถ added in v0.6.0
type BlockDownloadAsyncRawResponse ยถ added in v0.6.0
type BlockDownloadAsyncRequest ยถ added in v0.6.0
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 ยถ added in v0.6.0
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 ยถ added in v0.2.0
type BlockHeaderBestRawRequest struct{}
type BlockHeaderBestRawResponse ยถ added in v0.2.0
type BlockHeaderBestRequest ยถ added in v0.2.0
type BlockHeaderBestRequest struct{}
type BlockHeaderBestResponse ยถ added in v0.2.0
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 ยถ added in v0.6.0
type BlockInsertRawResponse ยถ added in v0.6.0
type BlockInsertRequest ยถ added in v0.6.0
type BlockInsertResponse ยถ added in v0.6.0
type BlockKeystoneByL2KeystoneAbrevHashRequest ยถ added in v0.11.2
type BlockKeystoneByL2KeystoneAbrevHashResponse ยถ added in v0.11.2
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 ยถ added in v0.5.0
type TxBroadcastRawResponse ยถ added in v0.5.0
type TxBroadcastRequest ยถ added in v0.5.0
type TxBroadcastResponse ยถ added in v0.5.0
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 ยถ added in v0.3.8
type UTXO struct {
TxId chainhash.Hash `json:"tx_id"`
Value uint64 `json:"value"`
OutIndex uint32 `json:"out_index"`
}
UTXO represents a Bitcoin unspent transaction output.