觀察與實驗

交易如何確認?

iota.lib.py : get_inclusion_states

函數的註解:

Get the inclusion states of a set of transactions. This is for
determining if a transaction was accepted and confirmed by the
network or not. You can search for multiple tips (and thus,
milestones) to get past inclusion states of transactions.
:param transactions:
List of transactions you want to get the inclusion state for.
:param tips:
List of tips (including milestones) you want to search for the
inclusion state.

iota.lib.js : getLatestInclusion

var latestMilestone = nodeInfo.latestSolidSubtangleMilestone; return self.getInclusionStates(hashes, Array(latestMilestone), callback);

可以看到需要Coo發起的交易hash , 才能正確的判斷某筆交易是確認的

一些

getInclusionStates 的結果

curl http://node.deviceproof.org:14265 -X POST -H 'Content-Type: application/json' -H 'X-IOTA-API-Version: 1' -d '{"command": "getInclusionStates", "transactions": ["FBPFOAJOCXKYCXNMHMTLFFLBHGIUFKPZATJPBYHGLZKNAPXKYMEEUWRHBEHAX9PHCEQLXPVUDSNGA9999"], "tips": ["ZHIVIWXBDENIVTSZWPVYHDPWWSRREMEN9DFBCBHOULNIYOYROKTBZGMLWYJFOJSQFGFRQUUFCBC9A9999"]}'

結果

{"states":[false],"duration":1}

"ZHIVIWXBDENIVTSZWPVYHDPWWSRREMEN9DFBCBHOULNIYOYROKTBZGMLWYJFOJSQFGFRQUUFCBC9A9999" 是 "FBPFOAJOCXKYCXNMHMTLFFLBHGIUFKPZATJPBYHGLZKNAPXKYMEEUWRHBEHAX9PHCEQLXPVUDSNGA9999" 的 Trunk

把"ZHIVIWXBDENIVTSZWPVYHDPWWSRREMEN9DFBCBHOULNIYOYROKTBZGMLWYJFOJSQFGFRQUUFCBC9A9999" 換掉

換掉的command如下

curl http://node.deviceproof.org:14265 -X POST -H 'Content-Type: application/json' -H 'X-IOTA-API-Version: 1' -d '{"command": "getInclusionStates", "transactions": ["FBPFOAJOCXKYCXNMHMTLFFLBHGIUFKPZATJPBYHGLZKNAPXKYMEEUWRHBEHAX9PHCEQLXPVUDSNGA9999"], "tips": ["FBPFOAJOCXKYCXNMHMTLFFLBHGIUFKPZATJPBYHGLZKNAPXKYMEEUWRHBEHAX9PHCEQLXPVUDSNGA9999"]}'

結果

{"states":[true],"duration":1}

transactionToApprove的流程

tags: IOTA