06月04, 2018

Something About IOTA[03_Transaction]

本文通过交易报文解析IOTA的转账流程及相关名词概念。

Transaction In Bundle

  • 上文中提到当一笔新交易加入Tangle时需要挑选并验证两笔Tips,实际上就是通过保存挑选的Tips的Hash引用来建立关系。
  • 每一个交易包含一束(bundle)交易信息。

alt

一个bundle由一组交易信息组成,包括:

  • 当前交易在bundle中的角标索引
  • 当前交易hash索引
  • trunTransaction的引用 - (tip 1)
  • branchTransaction的引用- (tip 2)

bundle数组中第一个交易元素叫做:tail transaction bundle数组中最后一个交易元素叫做:head transaction

从图解中可知:

  • 在bundle中除了head transaction之外,所有transaction的trunkTrasaction都指向bundle中的下一个transaction,branchTransaction指向1个tip。
  • 而head transaction作为数组的最后一个元素,无需持有后继元素的引用所以trankTransaction指向tip0,branchTransaction指向tip1.

Bundle

这里是一个3IOTA转账交易的Bundle示例。

  • 数组中每个交易有同样的bundle值,代表它们属于同一个bundle中:
    "bundle": "UMGXJ9JCUDQIYFYQLWDSLCVJBKRQIF9AEFBJBCRRCQAZGQNGTLHH9YZKJABACRJCFGZAFHQPGYULOLQVB",
    
  • 三笔交易信息有着不同的nonce说明在bundle中的每笔交易都要做各自的PoW工作。
"nonce": "AZ999IOB9999999999999999999",

Types

bundle中存在3种不同的Transaction:

  1. 转出交易(OutputTransaction):该种交易金额(value)大于0且交易地址(address)不属于发送者。
{
"hash": "ZXKIMUQE9IFXL9FFZVJQRJGBL9G9FSAQN9KINWVKJPOMNOCZWQHOMIRQFTHUERFQDTXACCSYRMNVA9999",
"signatureMessageFragment": "999999999999999999...[etc.]",
"address": "JHYLDJCBBTSFGVTBONTIVOWURCWMWBGGVRTOAMTKKFHWJAJHKKPWEYTAVDXMUSJBIUYEVZMO9LXBWHTUZ",
"value": 3,
"obsoleteTag": "OA9999999999999999999999999",
"timestamp": 1515494426,
"currentIndex": 0,
"lastIndex": 2,
"bundle": "UMGXJ9JCUDQIYFYQLWDSLCVJBKRQIF9AEFBJBCRRCQAZGQNGTLHH9YZKJABACRJCFGZAFHQPGYULOLQVB",
"trunkTransaction": "YDDQVGFO9OTJQSRGESYLPWLIDYBTFHUFQJ9HINVQVJMIKCHXBRNNOO9EZXGDOYJZPCPCZUARJ9IXA9999",
"branchTransaction": "DOXVWOMRDHJRPZBBECUVONZAOGIZGPKGADYKTKFVRFVFWDMWRFBXYFE9DUCVOXPCGARPKSAMUFSOPX999",
"tag": "999999999999999999999999999",
"attachmentTimestamp": 1515496588388,
"attachmentTimestampLowerBound": 0,
"attachmentTimestampUpperBound": 3812798742493,
"nonce": "EA999RL99999999999999999999",
"persistence": true
}
  1. 转入交易(InputTransaction): 分为两种转入交易
    • 负值交易,代表从账户中转出的交易记录。
{
"hash": "YDDQVGFO9OTJQSRGESYLPWLIDYBTFHUFQJ9HINVQVJMIKCHXBRNNOO9EZXGDOYJZPCPCZUARJ9IXA9999",
"signatureMessageFragment": "QL9RL9BRVGUKNOS9BJPEZNW9NWXSJC...[etc.]",
"address": "HRKDPLUQEEVPBOWRFBLULSAZBEQRRZMDTKHJYISUFXFJIRFGYISBEYSJ9LKOINHAC9UCELAEQZJJZXKHX",
"value": -3,
"obsoleteTag": "999999999999999999999999999",
"timestamp": 1515494426,
"currentIndex": 1,
"lastIndex": 2,
"bundle": "UMGXJ9JCUDQIYFYQLWDSLCVJBKRQIF9AEFBJBCRRCQAZGQNGTLHH9YZKJABACRJCFGZAFHQPGYULOLQVB",
"trunkTransaction": "WVCLPNUPZDULEGYMMNQSSP9BCTQTJVCAMU9OQVIOANHWWUVRTZNHJKSVNHWR9RGW9S9VIPJPAWPD99999",
"branchTransaction": "DOXVWOMRDHJRPZBBECUVONZAOGIZGPKGADYKTKFVRFVFWDMWRFBXYFE9DUCVOXPCGARPKSAMUFSOPX999",
"tag": "999999999999999999999999999",
"attachmentTimestamp": 1515496571334,
"attachmentTimestampLowerBound": 0,
"attachmentTimestampUpperBound": 3812798742493,
"nonce": "AZ999IOB9999999999999999999",
"persistence": true
}
  • 正值交易,代表在转出交易中多出的余额退回。
  1. 元交易(MetaTransaction): 元交易为0值交易,是对上一笔交易signatureMessageFragment的补充,两笔交易的signatureMessageFragment 组合成为一笔交易的完整签名。
{
"hash": "WVCLPNUPZDULEGYMMNQSSP9BCTQTJVCAMU9OQVIOANHWWUVRTZNHJKSVNHWR9RGW9S9VIPJPAWPD99999",
"signatureMessageFragment": "AJJCIMHMZRUESZLNC9K9LAOP9XULAUZV...[etc.]",
"address": "HRKDPLUQEEVPBOWRFBLULSAZBEQRRZMDTKHJYISUFXFJIRFGYISBEYSJ9LKOINHAC9UCELAEQZJJZXKHX",
"value": 0,
"obsoleteTag": "999999999999999999999999999",
"timestamp": 1515494426,
"currentIndex": 2,
"lastIndex": 2,
"bundle": "UMGXJ9JCUDQIYFYQLWDSLCVJBKRQIF9AEFBJBCRRCQAZGQNGTLHH9YZKJABACRJCFGZAFHQPGYULOLQVB",
"trunkTransaction": "DOXVWOMRDHJRPZBBECUVONZAOGIZGPKGADYKTKFVRFVFWDMWRFBXYFE9DUCVOXPCGARPKSAMUFSOPX999",
"branchTransaction": "XGACLXADPTUSPCYYVDMIKHJCTOUJEDUNYLZ9BJAIQHFLETICYARXGIFBLUOZUQWBTXNNTKVNCAXLMQ999",
"tag": "999999999999999999999999999",
"attachmentTimestamp": 1515496561769,
"attachmentTimestampLowerBound": 0,
"attachmentTimestampUpperBound": 3812798742493,
"nonce": "JA999ISA9999999999999999999",
"persistence": true
}

Transaction Example

Alice向Bob转账2 IOTAs:

alt

  • 在Alice的钱包中有3个交易地址,从0开始连续向下寻找,直到得到满足转账金额的数目。 在address 1发现5 IOTAs ,所以先生成一笔2IOTAs的InputTransaction:
{
"hash": "N9LSIIRPQYZ9NWZHDDZCAWFP9BZTIUSDVUGEKEUSPMILKEICDIMPUZOPHMCRNLOHPZBUDARMDEHU99999",
"signatureMessageFragment": "999...[etc.]",
"address": "JHYLDJCBBTSFGVTBONTIVOWURCWMWBGGVRTOAMTKKFHWJAJHKKPWEYTAVDXMUSJBIUYEVZMO9LXBWHTUZ",
"value": 2,
"obsoleteTag": "RC9999999999999999999999999",
"timestamp": 1515497312,
"currentIndex": 0,
"lastIndex": 3,
"bundle": "NBBKCKPFECRKCDIBKSTHZYZKSXFEUPTIJRK9FECFKPTTSWTLUWGIFS9AHSDT9LASABRD9KDVFJ9GT9CKA",
"trunkTransaction": "OL9ZVZRYGCRRVSFLIIDBLYSVVFCJWDRT9FHJPHM9UXPJWLHRURNDYCIAGZCFPEBVDMBXLFBCHJGLZ9999",
"branchTransaction": "HJAQCZPDBTEZXRRQFCIWSWGUQLLBUXXNIOCMWFWLKFEXLSFKNURZQGXPTBMKISMZWCDSZLRZDRWNBG999",
"tag": "999999999999999999999999999",
"attachmentTimestamp": 1515497987977,
"attachmentTimestampLowerBound": 0,
"attachmentTimestampUpperBound": 3812798742493,
"nonce": "YA999RJA9999999999999999999",
"persistence": true
}
  • 再生成一笔-5 IOTAOutputTransaction以及一笔对该转出交易的签名补充的元交易。
{
"hash": "OL9ZVZRYGCRRVSFLIIDBLYSVVFCJWDRT9FHJPHM9UXPJWLHRURNDYCIAGZCFPEBVDMBXLFBCHJGLZ9999",
"signatureMessageFragment": "NSGEMRPQSZWBXH...[etc.]",
"address": "IMXKFBJHJTBWUUZQDYYV9RJ9PSWXHWLU9Q9J9UVPP9TPRMNKFIOGGWWZCESTPMVAXDEW9KQSMVVFCKMUY",
"value": -5,
"obsoleteTag": "999999999999999999999999999",
"timestamp": 1515497312,
"currentIndex": 1,
"lastIndex": 3,
"bundle": "NBBKCKPFECRKCDIBKSTHZYZKSXFEUPTIJRK9FECFKPTTSWTLUWGIFS9AHSDT9LASABRD9KDVFJ9GT9CKA",
"trunkTransaction": "A9XKAKZYGEIHWOOW9RWAUVDAFWQOFIORQSUPDFEIGMNWUEWRFXQMLSJTOJCCGXVJYESFPDTSXMQJ99999",
"branchTransaction": "HJAQCZPDBTEZXRRQFCIWSWGUQLLBUXXNIOCMWFWLKFEXLSFKNURZQGXPTBMKISMZWCDSZLRZDRWNBG999",
"tag": "999999999999999999999999999",
"attachmentTimestamp": 1515497982257,
"attachmentTimestampLowerBound": 0,
"attachmentTimestampUpperBound": 3812798742493,
"nonce": "9Z9999CA9999999999999999999",
"persistence": true
}
  • 元交易
{
"hash": "A9XKAKZYGEIHWOOW9RWAUVDAFWQOFIORQSUPDFEIGMNWUEWRFXQMLSJTOJCCGXVJYESFPDTSXMQJ99999",
"signatureMessageFragment": "AJ9HUXWVQUX9UHGCQ...[etc.对转出交易的签名补充]",
"address": "IMXKFBJHJTBWUUZQDYYV9RJ9PSWXHWLU9Q9J9UVPP9TPRMNKFIOGGWWZCESTPMVAXDEW9KQSMVVFCKMUY",
"value": 0,
"obsoleteTag": "999999999999999999999999999",
"timestamp": 1515497312,
"currentIndex": 2,
"lastIndex": 3,
"bundle": "NBBKCKPFECRKCDIBKSTHZYZKSXFEUPTIJRK9FECFKPTTSWTLUWGIFS9AHSDT9LASABRD9KDVFJ9GT9CKA",
"trunkTransaction": "PHXUXKPQAGTOEOWPAEBAVCHRTLQL9V9VVSNB9IOEENWDTWGMYOQNZGZPGEO9BNEUMEQVTVOMPYVOA9999",
"branchTransaction": "HJAQCZPDBTEZXRRQFCIWSWGUQLLBUXXNIOCMWFWLKFEXLSFKNURZQGXPTBMKISMZWCDSZLRZDRWNBG999",
"tag": "999999999999999999999999999",
"attachmentTimestamp": 1515497971060,
"attachmentTimestampLowerBound": 0,
"attachmentTimestampUpperBound": 3812798742493,
"nonce": "YZ9999JA9999999999999999999",
"persistence": true
}
  • 最后还有一笔为3 IOTA转入交易作为该笔交易的零钱余额。
{
"hash": "PHXUXKPQAGTOEOWPAEBAVCHRTLQL9V9VVSNB9IOEENWDTWGMYOQNZGZPGEO9BNEUMEQVTVOMPYVOA9999",
"signatureMessageFragment": "9999999999...[etc.]",
"address": "QSECANQCBXGVSKMWWJDYDZCJXLYPURFANGZNBWHKYBTZRRFTZWTJUSBXGYRHUPXRFDCQXEDIILKMVJFUW",
"value": 3,
"obsoleteTag": "999999999999999999999999999",
"timestamp": 1515497314,
"currentIndex": 3,
"lastIndex": 3,
"bundle": "NBBKCKPFECRKCDIBKSTHZYZKSXFEUPTIJRK9FECFKPTTSWTLUWGIFS9AHSDT9LASABRD9KDVFJ9GT9CKA",
"trunkTransaction": "HJAQCZPDBTEZXRRQFCIWSWGUQLLBUXXNIOCMWFWLKFEXLSFKNURZQGXPTBMKISMZWCDSZLRZDRWNBG999",
"branchTransaction": "YPHZOIWSEI9WFWZJTMJAHHZMVRRWALWCMDSNIKQGOEMUOAVVRKJAWCNXMKEGLNQGLCCLUFXMVBKNKT999",
"tag": "999999999999999999999999999",
"attachmentTimestamp": 1515497963329,
"attachmentTimestampLowerBound": 0,
"attachmentTimestampUpperBound": 3812798742493,
"nonce": "GA999RRC9999999999999999999",
"persistence": true
}

Transaction Object

Transaction对象字段解析:

类型 简介
hash String 交易唯一键
signatureMessage Fragment String 签名段(如没有则99999)
address String 交易地址
value Int 交易金额
timestamp Int 交易时间戳
currentIndex Int 当前交易索引(在bundle中)
lastIndex Int 当前bundle最后一个索引
bundle String bundle编号
trunkTransaction String Tip HASH
branchTransaction String Tip HASH
tag String 用户可以为一笔交易取标签使其更容易搜索
attachment Timestamp Int 交易PoW完成时间
nonce String PoW计算结果
persistence String 交易状态 true:已确认(confirmed) false:未确认(pending)

参考:

1. IOTA tutorial 10: Transaction and bundle

本文链接:https://check321.net/post/IOTA_03.html

-- EOF --