當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Bitcoin getchaintips用法及代碼示例


比特幣(Bitcoin) RPC Blockchain API中getchaintips的用法及代碼示例。

用法:

getchaintips

返回有關塊樹中所有已知tips的信息,包括主鏈以及孤立的分支。

返回結果

[
  {
    "height": xxxx,         (numeric) height of the chain tip
    "hash": "xxxx",         (string) block hash of the tip
    "branchlen": 0          (numeric) zero for main chain
    "status": "active"      (string) "active" for the main chain
  },
  {
    "height": xxxx,
    "hash": "xxxx",
    "branchlen": 1          (numeric) length of branch connecting the tip to the main chain
    "status": "xxxx"        (string) status of the chain (active, valid-fork, valid-headers, headers-only, invalid)
  }
]

示例

bitcoin-cli getchaintips
curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getchaintips", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

相關用法


注:本文由純淨天空篩選整理自bitcoin.org大神的英文原創作品 Bitcoin getchaintips。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。