bitcoin节点搭建与bitcoin-cli
我用的是 docker 部署 bitcoin-testnet-box
bitcoin-cli
进入容器后,用ps命令看到有两个btc节点进程在运行,例如bitcoind -datadir=1 -daemon
可以用 bitcoin-cli getblockcount 获取区块高度
跟 geth console 类似的 eth.nodeInfo 获取节点信息的命令在 bitcoin-cli 中有三个: getblockcount getblockchaininfo getpeerinfo
getnetworkinfo
tester@1871562bdd9c ~/bitcoin-testnet-box$ bitcoin-cli -datadir=1 getnetworkinfo
{
"version": 210000,
"subversion": "/Satoshi:0.21.0/",
...
}
可以用 make 批量查询所有节点的信息
tester@1871562bdd9c ~/bitcoin-testnet-box$ make getinfo
bitcoin-cli -datadir=1 -getinfo
{
"version": 210000,
"blocks": 0,
"headers": 0,
"verificationprogress": 1,
"timeoffset": 0,
"connections": {
"in": 1,
"out": 0,
"total": 1
},
"proxy": "",
"difficulty": 4.656542373906925e-10,
"chain": "regtest",
"relayfee": 0.00001000,
"warnings": ""
}
bitcoin-cli -datadir=2 -getinfo
{
"version": 210000,
"blocks": 0,
"headers": 0,
"verificationprogress": 1,
"timeoffset": 0,
"connections": {
"in": 0,
"out": 1,
"total": 1
},
"proxy": "",
"difficulty": 4.656542373906925e-10,
"chain": "regtest",
"relayfee": 0.00001000,
"warnings": ""
}