区块相关 API
getinfo
获取节点相关信息
Parameters * none
Returns
version
节点版本号
protocol_version
协议版本号
net_type
节点运行的网络环境类型
proxy
节点代理地址:端口
public_ip
节点所在的外网IP地址
conf_dir
配置文件的目录路径
data_dir
区块数据的目录路径
block_interval
出块时间间隔
genblock
是否生产区块
time_offset
当前节点时间偏移量,单位s
WICC_balance
WICC余额
WUSD_balance
WUSD余额
WGRT_balance
WGRT余额
relay_fee_perkb
中继交易的费用/KB的阈值
tipblock_tx_count
节点中最新区块的交易数
tipblock_fuel_rate
节点中最新区块的燃料费率
tipblock_fuel
节点中最新区块的燃料费
tipblock_time
节点中最新区块的出块时间戳
tipblock_hash
节点中最新区块的哈希值
tipblock_height
节点中最新区块的高度
synblock_height
全网最新区块高度
finblock_height
已确认块的高度
finblock_hash
已确认块的哈希
connections
节点与外部节点的连接数
errors
警告信息提示
state
当前链的同步状态:
`Loading` 正在加载
`ReIndexing` 正在重新索引
`IBD` 块初始下载
`InSync` 已同步到最新块
Example
// Request
> coind getinfo
// Response
{
"version" : "v3.0.0.1-79fe51df-release-linux (2020-07-09 11:10:35 +0800)",
"protocol_version" : 10001,
"net_type" : "REGTEST_NET",
"proxy" : "",
"public_ip" : "",
"conf_dir" : "/root/.WaykiChain/WaykiChain.conf",
"data_dir" : "/root/.WaykiChain/regtest",
"block_interval" : 10,
"genblock" : 1,
"time_offset" : 0,
"WICC_balance" : 0,
"WUSD_balance" : 0,
"WGRT_balance" : 0,
"relay_fee_perkb" : 1000,
"tipblock_tx_count" : 3,
"tipblock_fuel_rate" : 100,
"tipblock_fuel" : 0,
"tipblock_time" : 1504305600,
"tipblock_hash" : "ab8d8b1d11784098108df399b247a0b80049de26af1b9c775d550228351c768d",
"tipblock_height" : 0,
"synblock_height" : 0,
"finblock_height" : 0,
"finblock_hash" : "0000000000000000000000000000000000000000000000000000000000000000",
"connections" : 0,
"errors" : "",
"state" : "InSync"
}
如何判断交易是否上链成功
1. coind gettxdetail $txid找到对应的confirmed_height (H1)
2. coind getinfo里面找到finblock_height (H2)
3. 如果 H1 <= H2,那么交易已经准确无误的上链成功
getblockcount
获取当前节点区块高度
Parameters
none
Returns
result
当前区块高度
Example
// Request
curl -u Waykichain:admin -d '{"jsonrpc":"2.0","id":"curltext","method":"getblockcount","params":[]}' -H 'content-type:application/json;' http://127.0.0.1:6967
// Response
{
"result": 38378,
"error": null,
"id": "curltext"
}
getblock
根据区块高度/区块哈希获取区块信息
Parameters
height
/hash
区块高度/区块哈希
Returns
curr_block_hash
当前块的哈希值
prev_block_hash
父区块的哈希值
next_block_hash
下一个块的哈希值
bp_uid
生产者的用户ID
version
区块版本
merkle_root
梅克尔树的根哈希值
total_fuel_fee
总的燃料费
confirmations
区块确认数 = 当前链上区块高度 - 本区块高度
size
区块大小,单位是byte
height
本区块的高度
tx_count
区块在包含的交易数量
tx
交易哈希列表
time
区块生成的时间戳
nonce
随机数
median_price
币价中位数列表,用于稳定币系统喂价
`coin_symbol` 币种符号
`price_symbol` 对标法币
`price` 币价
receipts
块的收据列表
Example
// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": [1000] }' -H 'content-type:application/json;' http://127.0.0.1:6967
// Response
{
"curr_block_hash" : "5131e0510471018ef47b964f8775e7003a1067460ecf5e8920aaf6368d756130",
"prev_block_hash" : "76e2c2a13c29af6cee3f678575924d6db672f0ea97f658911ba0ac7a7c8a1f17",
"next_block_hash" : "5e9b615ab64bd5fa6963aedb1191f7999cdfd5886a50605bbb865fb5a27d2f61",
"bp_uid" : "0-10",
"version" : 1,
"merkle_root" : "0b007a8efceef83b4e4de68b1e7bc50dceb5652ecbf894f520e9121a440ee8aa",
"total_fuel_fee" : 0,
"confirmations" : 13,
"size" : 203,
"height" : 98,
"tx_count" : 2,
"tx" : [
"4fbdeb061b8d9b8edc2c07cb15b3f2b280f6138c6cdffd7d63f7d463a80be627",
"7c283b57d57801bf8ba0d27bcb2f4fa23a8419dc4c8f159e67864dc4f45f4bbc"
],
"time" : 1593864322,
"nonce" : 101,
"median_price" : [
],
"receipts" : [
]
}