tbcapi

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 10 Imported by: 0

README ยถ

๐Ÿ“ก Hemi Tiny Bitcoin Daemon RPC

Last updated: May 16th, 2024

This document provides details on the RPC protocol and available commands for the Hemi Tiny Bitcoin Daemon (tbcd).

Table of Contents

โš™๏ธ Implementations

โš™๏ธ tbcd Daemon

The tbcd daemon runs an RPC server that listens on the address provided by the TBC_ADDRESS environment variable. You can run the tbcd daemon with the RPC server enabled with the following command:

# Make sure to replace localhost:8082 with your desired address and port
TBC_ADDRESS=localhost:8082 /path/to/tbcd
๐Ÿ”ง RPC Client

hemictl serves as a reference implementation of an RPC client tailored for interacting with the tbcd daemon. The client provides a command-line interface for all supported RPC commands.


๐Ÿ“š Resources

For developers looking to integrate or extend functionality:


๐Ÿ“ก Protocol

The RPC protocol is WebSocket-based and follows a standard request/response model. All communications are done via JSON messages. For more detailed information, refer to the protocol documentation.

๐Ÿšซ Errors

If an error occurs during a request, the response payload will include an error value containing the following details:

Field Description Example
timestamp The time at which the error occurred, in Unix seconds. 1679198400
trace A unique string for tracing errors between server and client (internal errors only). 804d952f893e686c
message The error message. For internal server errors, this will read internal error. invalid address format
๐Ÿ—„๏ธ Serialized Types

The following types are used throughout the API. All integer values are encoded in little-endian format unless specified otherwise.

Block Header

A serialized block header contains the following data:

Field Description Format
version The version of the block. uint32
prev_hash The hash of the previous block header in the blockchain, in reverse byte order and encoded as a hexadecimal string. string[64]
merkle_root The hash derived from the hashes of all transactions in the block, in reverse byte order and encoded as a hexadecimal string. string[64]
timestamp The time the miner began hashing the header, represented in Unix seconds. uint32
bits The difficulty target for the block. string[8]
nonce The nonce used to create the hash that is less than or equal to the target threshold. uint32
Address

Represents an encoded Bitcoin address. The following address types are supported:

Type Description Example
P2PKH Pay to Public Key Hash mxVFsFW5N4mu1HPkxPttorvocvzeZ7KZyk
P2SH Pay to Script Hash 2N3zXjbwdTcPsJiy8sUK9FhWJhqQCxA8Jjr
P2WPKH Pay to Witness Public Key Hash tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx
P2WSH Pay to Witness Script Hash tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7
P2TR Pay to Taproot tb1p6h5fuzxvqnlhkucpszs7g5h3qc4dhkj99uet6tzxz6k64ch7mgwsyf8jg4
UTXO

A serialized UTXO (Unspent Transaction Output) contains the following data:

Field Description Format
tx_id The transaction ID, in reverse byte order and encoded as a hexadecimal string. string[64]
value The value of the UTXO in satoshis. uint64
out_index The output index of the UTXO in the transaction. uint32

Example UTXO:

{
  "tx_id": "0012a33f3c301c90427d81f256d8a4848dcbfc289e8325725e7657e9a643d6fd",
  "value": 2026,
  "out_index": 1
}
Transaction

A serialized transaction contains the following data:

Field Description Format
version The transaction version number. uint32
lock_time The block height or timestamp after which the transaction becomes final. uint32
tx_in An array of transaction inputs. array
tx_out An array of transaction outputs. array

Example Transaction:

{
  "version": 2,
  "lock_time": 0,
  "tx_in": [
    {
      "outpoint": {
        "hash": "9554a7eb8bc903ea957c87964ab04a58d177692f15d7271cccb95258202f14b5",
        "index": 189
      },
      "signature_script": "",
      "witness": ["304402..."],
      "sequence": 4294967293
    }
  ],
  "tx_out": [
    {
      "value": 330,
      "pk_script": "51208ec88237b5978e75e93feaeeb1343ff86ae2f2c348a903c9c9c4ad0819267735"
    }
  ]
}
Transaction Input

A serialized transaction input contains the following data:

Field Description Format
outpoint The outpoint for the previous transaction output. object
signature_script The signature script that satisfies the spending conditions. string
witness An array of witness data for Segregated Witness transactions. array[string]
sequence The transaction sequence number for Replace-By-Fee or timelock. uint32
Transaction Output

A serialized transaction output contains the following data:

Field Description Format
value The value of the transaction output in satoshis. uint64
pk_script The pubkey script defining the conditions to spend this output. string
Outpoint

A serialized outpoint contains the following data:

Field Description Format
hash The ID of the transaction holding the output to be spent, in reverse byte order and encoded as a hexadecimal string. string[64]
index The index of the specific output to spend from the transaction. uint32

๐Ÿ‘‰ Block Headers by Height

Retrieve the block headers by height.

๐Ÿ—‚ Raw Data
Type command value
Request tbcapi-block-headers-by-height-raw-request
Response tbcapi-block-headers-by-height-raw-response
๐Ÿ“ค Request
Payload
  • height: The height at which block headers should be retrieved.
Example Request

Retrieve block headers at height 43111:

{
  "header": {
    "command": "tbcapi-block-headers-by-height-raw-request",
    "id": "68656d69"
  },
  "payload": {
    "height": 43111
  }
}
๐Ÿ“ฅ Response
Payload
  • block_headers: An array of raw block headers encoded as hexadecimal strings.
Example Response

Response for a request with id 68656d69 and height 43111:

{
  "header": {
    "command": "tbcapi-block-headers-by-height-raw-response",
    "id": "68656d69"
  },
  "payload": {
    "block_headers": [
      "02000000cf31d5156c8ab752b91874d1072d4673b83ee3ed718d3cb4f461c410000000000ca43abadf59bee614186d30da42f56932dc2a53e6d920169b8577207f7b11fcfec3d750c0ff3f1c4f428f6a"
    ]
  }
}
๐Ÿ—‚ Serialized Data
Type command value
Request tbcapi-block-headers-by-height-request
Response tbcapi-block-headers-by-height-response
๐Ÿ“ค Request
Payload
  • height: The height at which block headers should be retrieved.
Example Request

Retrieve block headers at height 43111:

{
  "header": {
    "command": "tbcapi-block-headers-by-height-request",
    "id": "68656d69"
  },
  "payload": {
    "height": 43111
  }
}
๐Ÿ“ฅ Response
Payload
Example Response

Response for a request with id 68656d69 and height 43111:

{
  "header": {
    "command": "tbcapi-block-headers-by-height-response",
    "id": "68656d69"
  },
  "payload": {
    "block_headers": [
      {
        "version": 2,
        "prev_hash": "0000000010c461f4b43c8d71ede33eb873462d07d17418b952b78a6c15d531cf",
        "merkle_root": "fc117b7f2077859b1620d9e6532adc3269f542da306d1814e6be59dfba3aa40c",
        "timestamp": 1356317694,
        "bits": "1c3fffc0",
        "nonce": 1787773519
      }
    ]
  }
}

๐Ÿ‘‰ Best Block Header

Retrieve the best block headers.

๐Ÿ—‚ Raw Data
Type command value
Request tbcapi-block-header-best-raw-request
Response tbcapi-block-header-best-raw-response
๐Ÿ“ค Request
Example Request

Retrieve the best block headers:

{
  "header": {
    "command": "tbcapi-block-header-best-raw-request",
    "id": "68656d69"
  }
}
๐Ÿ“ฅ Response
Payload
  • height: The best-known height.
  • block_header: The best-known block header encoded as a hexadecimal string.
Example Response

Response for a request with id 68656d69 and best height 2182000:

{
  "header": {
    "command": "tbcapi-block-header-best-raw-response",
    "id": "68656d69"
  },
  "payload": {
    "height": 2182000,
    "block_header": "0420002075089ac1ab1cab70cf6e6b774a86703a8d7127c0ebed1d3dfa2c00000000000086105509ec4a79457a400451290ad2a019fec4c76b47512623f1bb17a0ced76f38d82662bef4001b07d86700"
  }
}
๐Ÿ—‚ Serialized Data
Type command value
Request tbcapi-block-header-best-request
Response tbcapi-block-header-best-response
๐Ÿ“ค Request
Example Request

Retrieve the best block headers:

{
  "header": {
    "command": "tbcapi-block-header-best-request",
    "id": "68656d69"
  }
}
๐Ÿ“ฅ Response
Payload
  • height: The best-known height.
  • block_header: The best-known block header.
Example Response

Response for a request with id 68656d69 and height 2587400:

{
  "header": {
    "command": "tbcapi-block-header-best-response",
    "id": "68656d69"
  },
  "payload": {
    "height": 2587400,
    "block_header": {
      "version": 536887296,
      "prev_hash": "000000000000002bbbbec8f126dc76a82109d898383bca5013a2386c8675ce34",
      "merkle_root": "b9d74efdafb5436330b47478b2df28251057da5a9bc11c5509410950253d4f0e",
      "timestamp": 1713461092,
      "bits": "192e17d5",
      "nonce": 3365605040
    }
  }
}

๐Ÿ‘‰ Balance by Address

Retrieve the balance for an address.

๐Ÿ—‚ Raw Data
Type command value
Request tbcapi-balance-by-address-request
Response tbcapi-balance-by-address-response
๐Ÿ“ค Request
Payload
  • address: The address for which the balance should be retrieved.
Example Request

Retrieve the balance for the address myqzZmRvoXmrhsrM5STiMGtNRxCFArHWRd:

{
  "header": {
    "command": "tbcapi-balance-by-address-request",
    "id": "68656d69"
  },
  "payload": {
    "address": "mhAfMWDjd8YV3RoWcpHSzqjkWi6q5Bfixa"
  }
}
๐Ÿ“ฅ Response
Payload
  • balance: The known balance of the address, in satoshis.
Example Response

Response for a request with id 68656d69, if the address's balance is 0:

{
  "header": {
    "command": "tbcapi-balance-by-address-response",
    "id": "68656d69"
  },
  "payload": {
    "balance": 0
  }
}

๐Ÿ‘‰ UTXOs by Address

Retrieve UTXOs by address.

๐Ÿ—‚ Raw Data
Type command value
Request tbcapi-utxos-by-address-raw-request
Response tbcapi-utxos-by-address-raw-response
๐Ÿ“ค Request
Payload
  • address: The address to retrieve the UTXOs for.
  • start: The start index for the UTXOs that should be included in the response (or the number of UTXOs that should be skipped).
  • count: The maximum number of UTXOs that should be included in the response.
Example Request

Retrieve five UTXOs for the address mxVFsFW5N4mu1HPkxPttorvocvzeZ7KZyk:

{
  "header": {
    "command": "tbcapi-utxos-by-address-raw-request",
    "id": "68656d69"
  },
  "payload": {
    "address": "mxVFsFW5N4mu1HPkxPttorvocvzeZ7KZyk",
    "start": 0,
    "count": 5
  }
}
๐Ÿ“ฅ Response
Payload
  • utxos: An array of known UTXOs for the address, encoded as hexadecimal strings, or null if there are * no UTXOs* for the address.
Example Response

Response for a request with id 68656d69, requesting 5 UTXOs for the address mxVFsFW5N4mu1HPkxPttorvocvzeZ7KZyk:

{
  "header": {
    "command": "tbcapi-utxos-by-address-raw-response",
    "id": "68656d69"
  },
  "payload": {
    "utxos": [
      "0073700282db1dcc4853dc64e5da5c8595d1204ea7d036b04ea6b8ba41093a770000000000000cab00000002",
      "0073700282db1dcc4853dc64e5da5c8595d1204ea7d036b04ea6b8ba41093a770000000000000cab00000002",
      "0073700282db1dcc4853dc64e5da5c8595d1204ea7d036b04ea6b8ba41093a770000000000000cab00000002",
      "0073700282db1dcc4853dc64e5da5c8595d1204ea7d036b04ea6b8ba41093a770000000000000cab00000002",
      "0073700282db1dcc4853dc64e5da5c8595d1204ea7d036b04ea6b8ba41093a770000000000000cab00000002"
    ]
  }
}
๐Ÿ—‚ Serialized Data
Type command value
Request tbcapi-utxos-by-address-request
Response tbcapi-utxos-by-address-response
๐Ÿ“ค Request
Payload
  • address: The address to retrieve the UTXOs for.
  • start: The start index for the UTXOs that should be included in the response (or the number of UTXOs that should be skipped).
  • count: The maximum number of UTXOs that should be included in the response.
Example Request

Retrieve 5 UTXOs for the address mxVFsFW5N4mu1HPkxPttorvocvzeZ7KZyk:

{
  "header": {
    "command": "tbcapi-utxos-by-address-request",
    "id": "68656d69"
  },
  "payload": {
    "address": "mxVFsFW5N4mu1HPkxPttorvocvzeZ7KZyk",
    "start": 0,
    "count": 5
  }
}
๐Ÿ“ฅ Response
Payload
  • utxos: An array of known UTXOs. The maximum number of items in this array can be changed with * count* in the request.
Example Response

Response for a request with id 68656d69, showing 5 UTXOs for the address:

{
  "header": {
    "command": "tbcapi-utxos-by-address-response",
    "id": "68656d69"
  },
  "payload": {
    "utxos": [
      {
        "tx_id": "0012a33f3c301c90427d81f256d8a4848dcbfc289e8325725e7657e9a643d6fd",
        "value": 2026,
        "out_index": 1
      },
      {
        "tx_id": "0066c9f87d012e75e390adb490794a746fefe05eb16d220515788f33d5b6b336",
        "value": 10000,
        "out_index": 1
      },
      {
        "tx_id": "0066c9f87d012e75e390adb490794a746fefe05eb16d220515788f33d5b6b336",
        "value": 10000,
        "out_index": 2
      },
      {
        "tx_id": "0073700282db1dcc4853dc64e5da5c8595d1204ea7d036b04ea6b8ba41093a77",
        "value": 3243,
        "out_index": 1
      },
      {
        "tx_id": "0073700282db1dcc4853dc64e5da5c8595d1204ea7d036b04ea6b8ba41093a77",
        "value": 3243,
        "out_index": 2
      }
    ]
  }
}

๐Ÿ‘‰ Transaction by ID

๐Ÿ—‚ Raw Data
Type command value
Request tbcapi-tx-by-id-raw-request
Response tbcapi-tx-by-id-raw-response
๐Ÿ“ค Request
Payload
  • tx_id: The ID of the transaction to retrieve, encoded as a hexadecimal string.

An example request to retrieve the transaction 0584ad53bf1938702b952026f7c986ab5d07ee7295c0ad3241c932a5483158ac:

{
  "header": {
    "command": "tbcapi-tx-by-id-raw-request",
    "id": "68656d69"
  },
  "payload": {
    "tx_id": "0584ad53bf1938702b952026f7c986ab5d07ee7295c0ad3241c932a5483158ac"
  }
}
๐Ÿ“ฅ Response
Payload
  • tx: The transaction (encoded as a hexadecimal string).
Example Response

An example response for a request with id 68656d69, requesting the transaction 0584ad53bf1938702b952026f7c986ab5d07ee7295c0ad3241c932a5483158ac:

{
  "header": {
    "command": "tbcapi-tx-by-id-raw-response",
    "id": "68656d69"
  },
  "payload": {
    "tx": "02000000019554a7eb8bc903ea957c87964ab04a58d177692f15d7271cccb95258202f14b5bd00000000fdffffff014a010000000000002251208ec88237b5978e75e93feaeeb1343ff86ae2f2c348a903c9c9c4ad081926773500000000"
  }
}
๐Ÿ—‚ Serialized Data
Type command value
Request tbcapi-tx-by-id-request
Response tbcapi-tx-by-id-response
๐Ÿ“ค Request
Payload
  • tx_id: The ID of the transaction to retrieve, in reverse byte order and encoded as a hexadecimal string.
Example Request

An example request to retrieve the transaction 0584ad53bf1938702b952026f7c986ab5d07ee7295c0ad3241c932a5483158ac:

{
  "header": {
    "command": "tbcapi-tx-by-id-request",
    "id": "68656d69"
  },
  "payload": {
    "tx_id": "0584ad53bf1938702b952026f7c986ab5d07ee7295c0ad3241c932a5483158ac"
  }
}
๐Ÿ“ฅ Response
Payload
  • tx: The requested transaction, if found, otherwise null.
Example Response

An example response for a request with id 68656d69, requesting the transaction 0584ad53bf1938702b952026f7c986ab5d07ee7295c0ad3241c932a5483158ac:

{
  "header": {
    "command": "tbcapi-tx-by-id-response",
    "id": "68656d69"
  },
  "payload": {
    "tx": {
      "version": 2,
      "lock_time": 0,
      "tx_in": [
        {
          "outpoint": {
            "hash": "9554a7eb8bc903ea957c87964ab04a58d177692f15d7271cccb95258202f14b5",
            "index": 189
          },
          "signature_script": "",
          "tx_witness": null,
          "sequence": 4294967293
        }
      ],
      "tx_out": [
        {
          "value": 330,
          "pk_script": "51208ec88237b5978e75e93feaeeb1343ff86ae2f2c348a903c9c9c4ad0819267735"
        }
      ]
    }
  }
}

Documentation ยถ

Index ยถ

Constants ยถ

View Source
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 ยถ

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 Block ยถ

type Block struct {
	Hash   chainhash.Hash `json:"hash"`
	Header BlockHeader    `json:"header"`
	Txs    []Tx           `json:"txs"`
}

Block represents a Bitcoin block.

type BlockByHashRawRequest ยถ

type BlockByHashRawRequest struct {
	Hash chainhash.Hash `json:"hash"`
}

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 ยถ

type BlockByHashRequest struct {
	Hash chainhash.Hash `json:"hash"`
}

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 BlockDownloadAsyncRawRequest ยถ

type BlockDownloadAsyncRawRequest struct {
	Hash  chainhash.Hash `json:"hash"`
	Peers uint           `json:"peers"`
}

type BlockDownloadAsyncRawResponse ยถ

type BlockDownloadAsyncRawResponse struct {
	Block api.ByteSlice   `json:"block,omitempty"`
	Error *protocol.Error `json:"error,omitempty"`
}

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 BlockHeaderBestRawResponse ยถ

type BlockHeaderBestRawResponse struct {
	Height      uint64          `json:"height"`
	BlockHeader api.ByteSlice   `json:"block_header"`
	Error       *protocol.Error `json:"error,omitempty"`
}

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 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 BlockInsertRawRequest ยถ

type BlockInsertRawRequest struct {
	Block api.ByteSlice `json:"block"`
}

type BlockInsertRawResponse ยถ

type BlockInsertRawResponse struct {
	BlockHash *chainhash.Hash `json:"block_hash"`
	Error     *protocol.Error `json:"error,omitempty"`
}

type BlockInsertRequest ยถ

type BlockInsertRequest struct {
	Block *wire.MsgBlock `json:"block"`
}

type BlockInsertResponse ยถ

type BlockInsertResponse struct {
	BlockHash *chainhash.Hash `json:"block_hash"`
	Error     *protocol.Error `json:"error,omitempty"`
}

type BlocksByL2AbrevHashesRequest ยถ

type BlocksByL2AbrevHashesRequest struct {
	L2KeystoneAbrevHashes []chainhash.Hash `json:"l2_keystone_abrev_hashes"`
}

type BlocksByL2AbrevHashesResponse ยถ

type BlocksByL2AbrevHashesResponse struct {
	L2KeystoneBlocks  []*L2KeystoneBlockInfo `json:"l2_keystone_blocks"`
	BtcTipBlockHash   *chainhash.Hash        `json:"btc_tip_block_hash"`
	BtcTipBlockHeight uint                   `json:"btc_tip_block_height"`
	Error             *protocol.Error        `json:"error,omitempty"`
}

type FeeEstimate ยถ

type FeeEstimate struct {
	Blocks      uint    `json:"blocks"`
	SatsPerByte float64 `json:"sats_per_byte"`
}

type FeeEstimateRequest ยถ

type FeeEstimateRequest struct{}

type FeeEstimateResponse ยถ

type FeeEstimateResponse struct {
	FeeEstimates []*FeeEstimate  `json:"fee_estimate"`
	Error        *protocol.Error `json:"error,omitempty"`
}

type KeystoneTx ยถ

type KeystoneTx struct {
	BlockHash   chainhash.Hash `json:"block_hash"`
	TxIndex     uint           `json:"tx_index"`
	BlockHeight uint           `json:"block_height"`
	RawTx       api.ByteSlice  `json:"raw_tx"` // Keystone Tx
}

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 KeystonesByHeightRequest ยถ

type KeystonesByHeightRequest struct {
	Height uint32 `json:"height"`
	Depth  int    `json:"depth"`
}

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 L2KeystoneBlockInfo struct {
	L2KeystoneAbrev       *hemi.L2KeystoneAbrev `json:"l2_keystone_abrev"`
	L2KeystoneBlockHash   *chainhash.Hash       `json:"l2_keystone_block_hash"`
	L2KeystoneBlockHeight uint                  `json:"l2_keystone_block_height"`
	Error                 *protocol.Error       `json:"error,omitempty"`
}

type MempoolInfoRequest ยถ

type MempoolInfoRequest struct{}

type MempoolInfoResponse ยถ

type MempoolInfoResponse struct {
	Size  int64           `json:"size"`
	TxNum uint            `json:"tx_num"`
	Error *protocol.Error `json:"error,omitempty"`
}

type OutPoint ยถ

type OutPoint struct {
	Hash  chainhash.Hash `json:"hash"`
	Index uint32         `json:"index"`
}

OutPoint is a transaction out point.

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 TxBroadcastRawRequest struct {
	Tx    api.ByteSlice `json:"tx"`
	Force bool          `json:"force"`
}

type TxBroadcastRawResponse ยถ

type TxBroadcastRawResponse struct {
	TxID  *chainhash.Hash `json:"tx_id"`
	Error *protocol.Error `json:"error,omitempty"`
}

type TxBroadcastRequest ยถ

type TxBroadcastRequest struct {
	Tx    *wire.MsgTx `json:"tx"`
	Force bool        `json:"force"`
}

type TxBroadcastResponse ยถ

type TxBroadcastResponse struct {
	TxID  *chainhash.Hash `json:"tx_id"`
	Error *protocol.Error `json:"error,omitempty"`
}

type TxByIdRawRequest ยถ

type TxByIdRawRequest struct {
	TxID chainhash.Hash `json:"tx_id"`
}

type TxByIdRawResponse ยถ

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

type TxByIdRequest ยถ

type TxByIdRequest struct {
	TxID chainhash.Hash `json:"tx_id"`
}

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

TxIn represents a Bitcoin transaction input.

type TxOut ยถ

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

TxOut represents a Bitcoin transaction output.

type TxWitness ยถ

type TxWitness []api.ByteSlice

TxWitness represents a Bitcoin transaction witness.

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.

type UTXOsByAddressRawRequest ยถ

type UTXOsByAddressRawRequest struct {
	FilterMempool bool   `json:"filter_mempool"`
	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 {
	FilterMempool bool   `json:"filter_mempool"`
	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