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.