API

JSON-RPC 与 REST 接口

Orin Core 提供 JSON-RPC 和 REST API,用于区块链、钱包与内存池操作。

JSON-RPC

  • orind 默认启用 JSON-RPC;orin-qt 需要 -server
  • 端点://wallet/<walletname>/
  • 端口与 REST 一致:主网 9998、测试网 19998(可用 rpcport 覆盖)。
curl --user alice --data-binary '{"jsonrpc":"1.0","id":"0","method":"getblockcount","params":[]}' \
  -H 'content-type: text/plain;' http://127.0.0.1:9998/

支持位置参数、命名参数与 args 参数。

使用 orin-cli helporin-cli help <command> 查看完整 RPC 列表。

REST API

使用 -rest 启用 REST。输出支持 binhexjson

方法 端点 说明
GET /rest/tx/<TX-HASH>.<bin|hex|json> 从内存池获取交易(已确认需 txindex=1)。
GET /rest/block/<BLOCK-HASH>.<bin|hex|json> 完整区块数据。
GET /rest/block/notxdetails/<BLOCK-HASH>.<bin|hex|json> 不含交易详情的区块。
GET /rest/headers/<BLOCK-HASH>.<bin|hex|json>?count=<N> 从指定 hash 开始的区块头。
GET /rest/blockfilterheaders/<FILTERTYPE>/<BLOCK-HASH>.<bin|hex|json>?count=<N> 区块过滤器头。
GET /rest/blockfilter/<FILTERTYPE>/<BLOCK-HASH>.<bin|hex|json> 指定类型的区块过滤器。
GET /rest/blockhashbyheight/<HEIGHT>.<bin|hex|json> 通过高度获取区块哈希。
GET /rest/chaininfo.json 链状态信息(getblockchaininfo)。
GET /rest/getutxos/<TXID>-<N>/.../<TXID>-<N>.<bin|hex|json> 按输出点查询 UTXO 集。
GET /rest/getutxos/checkmempool/...<bin|hex|json> 包含内存池校验的 UTXO 查询。
GET /rest/mempool/info.json 内存池统计。
GET /rest/mempool/contents.json 完整内存池内容。

安全提示

  • 不要在公网直接暴露 RPC/REST,必要时使用隧道或反向代理。
  • 高并发请求时提高操作系统文件描述符限制。
  • 同一主机上访问不可信页面可能导致隐私数据泄露。