coinbase rawtx 解析

上一篇文章分享了普通 rawtx 的解析过程,接下来,我们一起看看coinbase 的 rawtx 该如何解析:

coinBase rawtx 解析

coinbase是没有输入的,但是这个字段还是没有,只是矿工在挖出来这个块的时候,添加了20-100个字节的块数据,如果不是coinbase,那么这个字段就是对上一个脚本输出的一个验证。

01000000               //4 byte version

00                     //1 byte marker
01                     //1 byte flag

01                     //1 byte tx_in count
0000000000000000000000000000000000000000000000000000000000000000      //32 byte hash
ffffffff               //4 byte index
50                     //1 byte script length(80 byte)

03
d3aa07      
174d696e656420627920416e74506f6f6c6851205a4dba3efabe6d6d4d3b08032c85f61efdd1681cbe49e72e3faae7fcd20d679e8cd1b392b47829e704000000000000004c42000091780300         //80 byte script

ffffffff              //4 byte sequence


02                    // 2 tx out

//first tx out
353d6a5e00000000      //15.84020789 btc
19                    //pk_script length(25字节)

//25 byte P2PKH 输出脚本
>>>>>>>>>>>>>>>>>>
76
a9
14
8349212dc27ce3ab4c5b29b85c4dec643d764b17
88
ac         
>>>>>>>>>>>>>>>>>>>

//second tx out
0000000000000000     //0 btc (SegWit commitment output)

26                   //pk_script length(38字节) 至少 38 byte
6a24aa21a9ed         //6 byte 固定
a02fb7425dc44e19e02bfa5a87cb02b4b092adc35f9f3d248894d957a4958742     //32 commit hash

01                  //只有一个iterm。   coinbase(是一种共识)
20                 //iterm的长度32 字节
0000000000000000000000000000000000000000000000000000000000000000     //32 byte witness

00000000  //4 byte lock_time

Commitment structure

  • The commitment is recorded in a scriptPubKey of the coinbase transaction. It must be at least 38 bytes, with the first 6-byte of 0x6a24aa21a9ed, that is:
   1-byte - OP_RETURN (0x6a)
   1-byte - Push the following 36 bytes (0x24)
   4-byte - Commitment header (0xaa21a9ed)
   32-byte - Commitment hash: Double-SHA256(witness root hash|witness reserved value)
  
   39th byte onwards: Optional data with no consensus meaning
  

继续解析 coinbase 80 字节的 pubKey 输入脚本

03                      //1 byte 表示有3个字节代表块高度
d3aa07                  //当前块的高度 (little endian)

//76 bytes             //剩下的没有实际含义,只有矿工自己知道,只要在100字节内就属于合法的范围。
174d696e656420627920416e74506f6f6c6851205a4dba3efabe6d6d4d3b08032c85f61efdd1681cbe49e72e3faae7fcd20d679e8cd1b392b47829e704000000000000004c42000091780300

本文由Copernicus 团队 冉小龙 总结,转载无需授权。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,811评论 0 23
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,860评论 18 139
  • 每当太阳下山,我问了下自己今天有没有收获,可惜,天已经黑了!有一个人,我爱了她七年,而这七年以来,我无时无刻提醒自...
    因为爱我会回来阅读 273评论 0 0
  • 告诉大家一个好消息! 我很幸运被挑选为万科基金会 “Green Fellows” 第一届成员,到美国波士顿旗下一家...
    0d905ea337f1阅读 178评论 0 0
  • 结构 1:监听来电事件 2:查询,打开,数据库。匹配正则表达式 3:监听用户手势
    JokerLiang阅读 267评论 0 0