tbcapi

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion = 1

	CmdPingRequest  = "tbcapi-ping-request"
	CmdPingResponse = "tbcapi-ping-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"

	CmdBlockHeadersBestRawRequest  = "tbcapi-block-headers-best-raw-request"
	CmdBlockHeadersBestRawResponse = "tbcapi-block-headers-best-raw-response"

	CmdBlockHeadersBestRequest  = "tbcapi-block-headers-best-request"
	CmdBlockHeadersBestResponse = "tbcapi-block-headers-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"
)

Variables

View Source
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 APICommands

func APICommands() map[protocol.Command]reflect.Type

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

func ReadConn(ctx context.Context, c *protocol.Conn) (protocol.Command, string, any, error)

ReadConn reads from Conn and performs callbacks. One should use ReadConn over Read when mixing Write, WriteConn and Call.

func Write

func Write(ctx context.Context, c protocol.APIConn, id string, payload any) error

Write is the low level primitive of a protocol Write. One should generally not use this function and use WriteConn and Call instead.

func WriteConn

func WriteConn(ctx context.Context, c *protocol.Conn, id string, payload any) error

WriteConn writes to Conn. It is equivalent to Write but exists for symmetry reasons.

Types

type BalanceByAddressRequest

type BalanceByAddressRequest struct {
	Address string `json:"address"`
}

type BalanceByAddressResponse

type BalanceByAddressResponse struct {
	Balance uint64          `json:"balance"`
	Error   *protocol.Error `json:"error,omitempty"`
}

type BlockHeader

type BlockHeader struct {
	Version    int32         `json:"version"`
	PrevHash   api.ByteSlice `json:"prev_hash"`   // reverse order
	MerkleRoot api.ByteSlice `json:"merkle_root"` // reverse order
	Timestamp  int64         `json:"timestamp"`
	Bits       string        `json:"bits"`
	Nonce      uint32        `json:"nonce"`
}

type BlockHeadersBestRawRequest

type BlockHeadersBestRawRequest struct{}

type BlockHeadersBestRawResponse

type BlockHeadersBestRawResponse struct {
	Height       uint64          `json:"height"`
	BlockHeaders []api.ByteSlice `json:"block_headers"`
	Error        *protocol.Error `json:"error,omitempty"`
}

type BlockHeadersBestRequest

type BlockHeadersBestRequest struct{}

type BlockHeadersBestResponse

type BlockHeadersBestResponse struct {
	Height       uint64          `json:"height"`
	BlockHeaders []*BlockHeader  `json:"block_headers"`
	Error        *protocol.Error `json:"error,omitempty"`
}

type BlockHeadersByHeightRawRequest

type BlockHeadersByHeightRawRequest struct {
	Height uint32 `json:"height"`
}

type BlockHeadersByHeightRawResponse

type BlockHeadersByHeightRawResponse struct {
	BlockHeaders []api.ByteSlice `json:"block_headers"`
	Error        *protocol.Error `json:"error,omitempty"`
}

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 OutPoint

type OutPoint struct {
	Hash  api.ByteSlice `json:"hash"` // reverse order
	Index uint32        `json:"index"`
}

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"`
}

type TxByIdRawRequest

type TxByIdRawRequest struct {
	TxId api.ByteSlice `json:"tx_id"` // natural order
}

type TxByIdRawResponse

type TxByIdRawResponse struct {
	Tx    api.ByteSlice   `json:"tx"`
	Error *protocol.Error `json:"error,omitempty"`
}

type TxByIdRequest

type TxByIdRequest struct {
	TxId api.ByteSlice `json:"tx_id"` // reverse order
}

type TxByIdResponse

type TxByIdResponse struct {
	Tx    *Tx             `json:"tx"`
	Error *protocol.Error `json:"error,omitempty"`
}

type TxIn

type TxIn struct {
	PreviousOutPoint OutPoint      `json:"outpoint"`
	SignatureScript  api.ByteSlice `json:"signature_script"`
	Witness          TxWitness     `json:"tx_witness"`
	Sequence         uint32        `json:"sequence"`
}

type TxOut

type TxOut struct {
	Value    int64         `json:"value"`
	PkScript api.ByteSlice `json:"pk_script"`
}

type TxWitness

type TxWitness []api.ByteSlice

type Utxo

type Utxo struct {
	TxId     api.ByteSlice `json:"tx_id"` // reverse order
	Value    uint64        `json:"value"`
	OutIndex uint32        `json:"out_index"`
}

type UtxosByAddressRawRequest

type UtxosByAddressRawRequest struct {
	Address string `json:"address"`
	Start   uint   `json:"start"`
	Count   uint   `json:"count"`
}

type UtxosByAddressRawResponse

type UtxosByAddressRawResponse struct {
	Utxos []api.ByteSlice `json:"utxos"`
	Error *protocol.Error `json:"error,omitempty"`
}

type UtxosByAddressRequest

type UtxosByAddressRequest struct {
	Address string `json:"address"`
	Start   uint   `json:"start"`
	Count   uint   `json:"count"`
}

type UtxosByAddressResponse

type UtxosByAddressResponse struct {
	Utxos []*Utxo         `json:"utxos"`
	Error *protocol.Error `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL