tbcapi

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 9 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"

	CmdBlockKeystoneByL2KeystoneAbrevHashRequest  = "tbcapi-l2-keystone-abrev-by-abrev-hash-request"
	CmdBlockKeystoneByL2KeystoneAbrevHashResponse = "tbcapi-l2-keystone-abrev-by-abrev-hash-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 ΒΆ 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

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

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

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

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 BlockDownloadAsyncRawRequest struct {
	Hash  *chainhash.Hash `json:"hash"`
	Peers uint            `json:"peers"`
}

type BlockDownloadAsyncRawResponse ΒΆ added in v0.6.0

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

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 BlockHeaderBestRawResponse struct {
	Height      uint64          `json:"height"`
	BlockHeader api.ByteSlice   `json:"block_header"`
	Error       *protocol.Error `json:"error,omitempty"`
}

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 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 ΒΆ added in v0.6.0

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

type BlockInsertRawResponse ΒΆ added in v0.6.0

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

type BlockInsertRequest ΒΆ added in v0.6.0

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

type BlockInsertResponse ΒΆ added in v0.6.0

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

type BlockKeystoneByL2KeystoneAbrevHashRequest ΒΆ added in v0.11.2

type BlockKeystoneByL2KeystoneAbrevHashRequest struct {
	L2KeystoneAbrevHash *chainhash.Hash `json:"l2_keystones_abrev_hash"`
}

type BlockKeystoneByL2KeystoneAbrevHashResponse ΒΆ added in v0.11.2

type BlockKeystoneByL2KeystoneAbrevHashResponse struct {
	L2KeystoneAbrev *hemi.L2KeystoneAbrev `json:"l2_keystone_abrev"`
	BtcBlockHash    *chainhash.Hash       `json:"btc_block_hash"`
	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 ΒΆ added in v0.5.0

type TxBroadcastRawRequest struct {
	Tx    api.ByteSlice `json:"tx"`
	Force bool          `json:"force"`
}

type TxBroadcastRawResponse ΒΆ added in v0.5.0

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

type TxBroadcastRequest ΒΆ added in v0.5.0

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

type TxBroadcastResponse ΒΆ added in v0.5.0

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 ΒΆ 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.

type UTXOsByAddressRawRequest ΒΆ added in v0.3.8

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

type UTXOsByAddressRawResponse ΒΆ added in v0.3.8

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

type UTXOsByAddressRequest ΒΆ added in v0.3.8

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

type UTXOsByAddressResponse ΒΆ added in v0.3.8

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