奇亚(Chia, XCH) 接口之根据指纹(公钥)获取私钥等相关信息,路径为 /send_transaction
。
要注意端口号,钱包的端口号一般为 9256
如果你要自己搭建节点,请把该接口的对外访问屏蔽掉
如果你要自己搭建节点,请把该接口的对外访问屏蔽掉
如果你要自己搭建节点,请把该接口的对外访问屏蔽掉
如果你要自己搭建节点,请把该接口的对外访问屏蔽掉
如果你要自己搭建节点,请把该接口的对外访问屏蔽掉
该接口非常危险,因为他使用已有的钱包进行转账,服务器一旦被黑客攻破,可能里面的钱都没有了。
该接口需要四参数:钱包编号、转账金额、转出地址(到账地址、收款地址),手续费
wallet_id
钱包账号,是一个数字,默认情况下,为1
即可amount
转账金额,转账金额是以mojo
来计算的,也就是1e-12
次方,所以如果你输入 100,那么实际到账是1e-10 xch
address
地址,到账地址,是xch
开头的那个地址fee
手续费参数,如果不想给设置为0
,如果设置了,金额也是以mojo
来计算的,也就是1e-12
次方,所以如果你输入 100,那么实际手续费是1e-10 xch
因此,实际参数可能为
{"wallet_id":1,"amount":100,"address":"xch19fnnnvwhwefxjypwq3ee8e5mznqrzdhls8376stz3r7lydceqdpq5syxcl","fee":0}
例如
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 '{"wallet_id":1,"amount":100,"address":"xch19fnnnvwhwefxjypwq3ee8e5mznqrzdhls8376stz3r7lydceqdpq5syxcl","fee":0}' -H "Content-Type: application/json" -X POST https://localhost:9256/send_transaction | python3 -m json.tool
返回结果如下
{ "success": true, "transaction": { "additions": [ { "amount": 100, "parent_coin_info": "0x13945f519fb83c363c9ab1cd57a84c247f047d26cdeed55e524e380646e83dfd", "puzzle_hash": "0x2a6739b1d7765269102e047393e69b14c03136ff81e3ed416288fdf237190342" }, { "amount": 9999999900, "parent_coin_info": "0x13945f519fb83c363c9ab1cd57a84c247f047d26cdeed55e524e380646e83dfd", "puzzle_hash": "0xc178192b6a769ad895e6da2e6d8045b0ca0ead2a84df09bf44444054212da769" } ], "amount": 100, "confirmed": false, "confirmed_at_height": 0, "created_at_time": 1621903747, "fee_amount": 0, "name": "0xc8d812e271ed70a6da6bf2e5b357e37c1e21d9aa3809a830024cb62b1f285711", "removals": [ { "amount": 10000000000, "parent_coin_info": "0x448e7073a631bb12eb88d869937027edc23cf2e15d1e3d2da13b21a541778e2f", "puzzle_hash": "0x2a6739b1d7765269102e047393e69b14c03136ff81e3ed416288fdf237190342" } ], "sent": 0, "sent_to": [], "spend_bundle": { "aggregated_signature": "0x8a960a5edaa0ce06bf78696ad7cf990adb051afd461e5d45c239736ce42261839d1129b3e3ddb95b423ac57d23c3d02f0f350206df805f6049665c7557a0300ad87141717a7dbfcb16129cc0c432055842c666b915b174ed94771b2bb8009f38", "coin_solutions": [ { "coin": { "amount": 10000000000, "parent_coin_info": "0x448e7073a631bb12eb88d869937027edc23cf2e15d1e3d2da13b21a541778e2f", "puzzle_hash": "0x2a6739b1d7765269102e047393e69b14c03136ff81e3ed416288fdf237190342" }, "puzzle_reveal": "0xff02ffff01ff02ffff01ff02ffff03ff0bffff01ff02ffff03ffff09ff05ffff1dff0bffff1effff0bff0bffff02ff06ffff04ff02ffff04ff17ff8080808080808080ffff01ff02ff17ff2f80ffff01ff088080ff0180ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff17ff80808080ff80808080ffff02ff17ff2f808080ff0180ffff04ffff01ff32ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080ffff04ffff01b0a0cd89ed8b993596b931451c8c96abf2f4041167b35f762360dc9e135db9e8300e56fecef70ae9eb279626008f394b9bff018080", "solution": "0xff80ffff01ffff33ffa02a6739b1d7765269102e047393e69b14c03136ff81e3ed416288fdf237190342ff6480ffff33ffa0c178192b6a769ad895e6da2e6d8045b0ca0ead2a84df09bf44444054212da769ff8502540be39c80ffff3cffa01137d6024eef23690b9605554f5772122d67ca0f74ac420ca2f95af410c5f6d28080ff8080" } ] }, "to_puzzle_hash": "0x2a6739b1d7765269102e047393e69b14c03136ff81e3ed416288fdf237190342", "trade_id": null, "type": 1, "wallet_id": 1 }, "transaction_id": "0xc8d812e271ed70a6da6bf2e5b357e37c1e21d9aa3809a830024cb62b1f285711" }
如果转账失败,返回的值为
{ "error": "fee", "success": false }
error
指示了哪个字段错误
如果正确返回,那返回结果里的参数太多了,这个的返回结果和 /get_transaction
的返回结果是一样的。
里面有几个参数很重要
success
如果返回true
则说明转账成功,返回false
则转账失败transaction/additions
指示了 UXTO 的资金流向transaction/amount
指示了这次转账金额,mojo
为单位transaction/confirmed
指示了这次转账是否已经记录,也就是打包了transaction/confirmed_at_height
指示了这次转账打包的块高大小transaction/fee_amoun
指示了该次转账的手续费大小,金额以mojo
为单位transaction/removals
指示了使用了哪条 UXTOtransaction_id
这是当前转账事物 hash
目前尚无回复