查看链信息
bitcoin-cli -rpcconnect=127.0.0.1 -rpcuser=btcrpcusr -rpcpassword=btcrpcpasswd -rpcport=18332 getinfo
"-rpcconnect=127.0.0.1 -rpcuser=btcrpcusr -rpcpassword=btcrpcpasswd -rpcport=18332" 为连接信息,之后都省略掉。
根据块儿数查看其hash值
bitcoin-cli getblockhash 1410503
根据hash值查看区块儿详细信息
bitcoin-cli getblock 0000000000000086b55198d8775c6363d275ad8f5eee615e4a2507bbb439b63e
账户列表
bitcoin-cli listaccounts
查看某个账户下的地址
bitcoin-cli getaddressesbyaccount "recive"
在某个账户下新建地址
bitcoin-cli getnewaddress "recive"
查看某个地址所属的账户
bitcoin-cli getaccount myCDZbtxJwtY2YKPc5E3tVqfMU8yWMwWRF
查看账户余额
bitcoin-cli getbalance "account_name"
如果不指定账户名称,则返回总余额。
查看地址收到币的数量
bitcoin-cli getreceivedbyaddress "n3BMgZMA26TcHnVa5iNJeB3PMqkF3cEWBE"
0.02000000
# 指定最小确认数量(默认为1)
bitcoin-cli getreceivedbyaddress "address" 6
查看本地address的接收记录
bitcoin-cli listreceivedbyaddress 6
[
{
"address": "mgQwXkzXz75zorb4F8L9Bw9PKim6TrbjPY",
"account": "recive",
"amount": 1.10000000,
"confirmations": 153368,
"label": "recive",
"txids": [
"deca83ef57c4a2648f59784756e693bf8db760a86d13101c105d53160079a900"
]
},
{
"address": "mhgvU3hh8RNy4Y319w8EehnszSr4XEsLec",
"account": "recive",
"amount": 2.00000000,
"confirmations": 153343,
"label": "recive",
"txids": [
"8691f1fa76cd69dc494de16046f92d15bb25b94e580f228d13784691901c914b",
"5450567faf25bb43647f4fb70b0d1972c6553482fcfef43254b38f280851c77b"
]
},
......
]
转账
# 从默认账户给目标地址转账
bitcoin-cli sendtoaddress "myCDZbtxJwtY2YKPc5E3tVqfMU8yWMwWRF" 0.01
# 从指定账户转账
bitcoin-cli sendfrom "recive" "n3BMgZMA26TcHnVa5iNJeB3PMqkF3cEWBE" 0.01
查看交易详情
bitcoin-cli gettransaction "a3a8382e3f0bbf2d2334bfa9f25558860311640c9a6c2122ea77e9c8cfb34179"
查看raw交易
bitcoin-cli getrawtransaction "7499046133f298e09decd5775e42d23e0eacdee96425efa8090b706429209468"
得到hash字符串,解码:
bitcoin-cli decoderawtransaction "0100000001baf023ab403e7a4ec4982d695f9a98d2a88babb8cd7c9c2c27c72425735fa917000000006b483045022100c9f23820000b1d9dcae313907e483138a977a4b6e21a3464c1d09cc4ada203770220194aa9eaf0b4be843f0afdbdf62657cbfdc1278f176817447941c6c559f8f0d9012103863830b0464e964c04bce8fe1385f55a48e478617ecd91a6e7c5266d83f834effdffffff02a086010000000000016ab7938700000000001976a9149e6b3422474214b0fa9461eef68a10f22ce1aa9288acc6851500"
也可以直接通过 transaction id 查看交易的 JSON 对象:
bitcoin-cli getrawtransaction d63b10919f548ccd6e8a48954826aacde0e9f4aac250d965a1c3eee5f044f454 true
查看帮助
- 命令列表
bitcoin-cli help
- 某个命令的详细帮助信息
bitcoin-cli help sendtoaddress
API 文档:
http://chainquery.com/bitcoin-api
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list
测试币水龙头:
https://testnet.manu.backend.hamburg/faucet
https://testnet.coinfaucet.eu/en/
测试网络工具网站:
https://testnet.blockchain.info
https://live.blockcypher.com/btc-testnet/
https://test-insight.bitpay.com