奇亚(Chia, XCH) 接口之获取根据块哈希获取块出入金信息,这个数据非常重要,做出入金相关的都需要该接口,调用的路径为 //get_additions_and_removals
参数则是 POST 提交想要获取的块哈希即可
{"header_hash":"0xac7fcf6ffe96414e0ff8bcb19e4776e3b744bbc4c6accfa228f2bd38f3886950"}
例如
curl --insecure --cert ~/.chia/mainnet/config/ssl/full_node/private_full_node.crt --key ~/.chia/mainnet/config/ssl/full_node/private_full_node.key -d '{"header_hash":"0xac7fcf6ffe96414e0ff8bcb19e4776e3b744bbc4c6accfa228f2bd38f3886950"}' -H "Content-Type: application/json" -X POST https://localhost:8555/get_additions_and_removals | python3 -m json.tool
备注,后面的 |python3 -m json.tool 主要是用于美化返回值
返回的结果为
{ "additions": [ { "coin": { "amount": 182859, "parent_coin_info": "0x1089da31d4b22f1303c13dfcdd4f51ffdef99bfb7f838b1d53174e492dd29a5b", "puzzle_hash": "0x84211ac4c001e691bb8fc131c6a2f655c32e0fc9ce784a6879cd8b016a5445a6" }, "coinbase": false, "confirmed_block_index": 327171, "spent": false, "spent_block_index": 0, "timestamp": 1621818907 }, { "coin": { "amount": 100, "parent_coin_info": "0x23bbddbd42f7a0820d7a54b94c7eb4dd3eb5e10c563f1db6d521a6573cebd8e2", "puzzle_hash": "0x2a6739b1d7765269102e047393e69b14c03136ff81e3ed416288fdf237190342" }, "coinbase": false, "confirmed_block_index": 327171, "spent": false, "spent_block_index": 0, "timestamp": 1621818907 }, { "coin": { "amount": 100, "parent_coin_info": "0xaa26ad579a61b190978fca113d2ab53c0aa9dd473d413ae62101302cb310be78", "puzzle_hash": "0x6137334710112bd984c69538a64a08f56e46855c9e231cb0424c979bd7387605" }, "coinbase": false, "confirmed_block_index": 327171, "spent": false, "spent_block_index": 0, "timestamp": 1621818907 }, { "coin": { "amount": 1766, "parent_coin_info": "0xaa26ad579a61b190978fca113d2ab53c0aa9dd473d413ae62101302cb310be78", "puzzle_hash": "0xfd4789f4106657c4ad8145ab4a028932bbd9f5412b3aa7bb4f682ad203e1d2f6" }, "coinbase": false, "confirmed_block_index": 327171, "spent": false, "spent_block_index": 0, "timestamp": 1621818907 }, { "coin": { "amount": 255000100010, "parent_coin_info": "0x3ff07eb358e8255a65c30a2dce0e5fbb0000000000000000000000000004fe00", "puzzle_hash": "0xe068285e53773b3cbc14b0e5ae47b602bc1b54bfa193951a096838d0de3b07b1" }, "coinbase": true, "confirmed_block_index": 327171, "spent": false, "spent_block_index": 0, "timestamp": 1621818907 }, { "coin": { "amount": 1750000000000, "parent_coin_info": "0xccd5bb71183532bff220ba46c268991a0000000000000000000000000004fe00", "puzzle_hash": "0xe068285e53773b3cbc14b0e5ae47b602bc1b54bfa193951a096838d0de3b07b1" }, "coinbase": true, "confirmed_block_index": 327171, "spent": false, "spent_block_index": 0, "timestamp": 1621818907 }, { "coin": { "amount": 250000000000, "parent_coin_info": "0x3ff07eb358e8255a65c30a2dce0e5fbb0000000000000000000000000004fdff", "puzzle_hash": "0x53b282e8cfe10dbaa405e063115e4e34a64727dfafdd040f74fe2afc60db5ff9" }, "coinbase": true, "confirmed_block_index": 327171, "spent": false, "spent_block_index": 0, "timestamp": 1621818907 }, { "coin": { "amount": 1750000000000, "parent_coin_info": "0xccd5bb71183532bff220ba46c268991a0000000000000000000000000004fdff", "puzzle_hash": "0x53b282e8cfe10dbaa405e063115e4e34a64727dfafdd040f74fe2afc60db5ff9" }, "coinbase": true, "confirmed_block_index": 327171, "spent": false, "spent_block_index": 0, "timestamp": 1621818907 }, { "coin": { "amount": 8458677806, "parent_coin_info": "0x1089da31d4b22f1303c13dfcdd4f51ffdef99bfb7f838b1d53174e492dd29a5b", "puzzle_hash": "0x59b023cb8095dc26b8d277860ebb9a6af256657c1902e0ef9697dd61832ec6b1" }, "coinbase": false, "confirmed_block_index": 327171, "spent": true, "spent_block_index": 327174, "timestamp": 1621818907 }, { "coin": { "amount": 1319, "parent_coin_info": "0x23bbddbd42f7a0820d7a54b94c7eb4dd3eb5e10c563f1db6d521a6573cebd8e2", "puzzle_hash": "0x785446bf395045839f33a40c4793b7f763ee921c479993ce2aba40d5090fb74b" }, "coinbase": false, "confirmed_block_index": 327171, "spent": true, "spent_block_index": 328384, "timestamp": 1621818907 } ], "removals": [ { "coin": { "amount": 8458860665, "parent_coin_info": "0x34499004e2ede5ada989e9a21f007b4b98e6960cea77a667bb9ed7a0c96661f1", "puzzle_hash": "0x0ed1096e2bdf38ad7b6ed23234a54cb4b63da6d990887c5935ba796f202a5a90" }, "coinbase": false, "confirmed_block_index": 327166, "spent": true, "spent_block_index": 327171, "timestamp": 1621818827 }, { "coin": { "amount": 1419, "parent_coin_info": "0x083cf0788962f9cae780bd7e64e442a94fcd3e76e7cc4d21bc15616f4d7d1b13", "puzzle_hash": "0xe69badacac4c948ff22ac61e2f2fb17175000351cdfd22403502524e87eb62b8" }, "coinbase": false, "confirmed_block_index": 325396, "spent": true, "spent_block_index": 327171, "timestamp": 1621789301 }, { "coin": { "amount": 1866, "parent_coin_info": "0xc04d8715ff17c3c84beb9cea6340fc2a03cd79b6e7614e7cda1a5a72ed2cc220", "puzzle_hash": "0xb1577fc967cfbaa32de9d5671e4a4a299813190c5505a536932f0ba0a239407c" }, "coinbase": false, "confirmed_block_index": 324460, "spent": true, "spent_block_index": 327171, "timestamp": 1621773852 } ], "success": true }
返回的参数,每个参数都很重要
removals
表示里面的记录是出金,也就是付款方。additions
表示里面的记录是入金,也就是收款方。
每个出入金记录都有以下记录
{ "coin": { "amount": 1000000, "parent_coin_info": "0x964912d5140e1d8608b53795f1163e483a4e06c4da1a707272edac8164cb6eac", "puzzle_hash": "0xe1e45b735b87f904c85d10104191af5988449a6ddb12a913e8f3478eb028fa9c" }, "coinbase": false, "confirmed_block_index": 327204, "spent": false, "spent_block_index": 0, "timestamp": 1621819744 },
timestamp
表示当前块打包时间confirmed_block_index
表示该记录入金块高spent_block_index
表示该记录出金块高spent
用于表示该记录是否作废,相关知识,你可以百度UXTO
coinbase
用于表示当前记录是否挖矿记录,如果是挖矿则为true
coin
则表示当前出入金相关元数据
每个出入金元素的每个字段都很重要
"coin": { "amount": 1000000, "parent_coin_info": "0x964912d5140e1d8608b53795f1163e483a4e06c4da1a707272edac8164cb6eac", "puzzle_hash": "0xe1e45b735b87f904c85d10104191af5988449a6ddb12a913e8f3478eb028fa9c" }
amount
表示出入金金额,注意,XCH 的小数位数是10^12
次方,因此实际多少 XCH 要处以1000000000000
puzzle_hash
表示 XCH 地址的puzzle,也就是地址编号parent_coin_info
表示当前出入金的上级出入金相关参数,详情请了解 UXTO
目前尚无回复