coinbase rawtx 解析

上一篇文章分享了普通 rawtx 的解析過程,接下來,我們一起看看coinbase 的 rawtx 該如何解析:

coinBase rawtx 解析

coinbase是沒有輸入的,但是這個字段還是沒有,只是礦工在挖出來這個塊的時候,添加了20-100個字節(jié)的塊數(shù)據(jù),如果不是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字節(jié))

//25 byte P2PKH 輸出腳本
>>>>>>>>>>>>>>>>>>
76
a9
14
8349212dc27ce3ab4c5b29b85c4dec643d764b17
88
ac         
>>>>>>>>>>>>>>>>>>>

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

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

01                  //只有一個iterm。   coinbase(是一種共識)
20                 //iterm的長度32 字節(jié)
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
  

繼續(xù)解析 coinbase 80 字節(jié)的 pubKey 輸入腳本

03                      //1 byte 表示有3個字節(jié)代表塊高度
d3aa07                  //當(dāng)前塊的高度 (little endian)

//76 bytes             //剩下的沒有實際含義,只有礦工自己知道,只要在100字節(jié)內(nèi)就屬于合法的范圍。
174d696e656420627920416e74506f6f6c6851205a4dba3efabe6d6d4d3b08032c85f61efdd1681cbe49e72e3faae7fcd20d679e8cd1b392b47829e704000000000000004c42000091780300

本文由Copernicus 團(tuán)隊 冉小龍 總結(jié),轉(zhuǎn)載無需授權(quán)。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,884評論 0 23
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 134,923評論 18 139
  • 每當(dāng)太陽下山,我問了下自己今天有沒有收獲,可惜,天已經(jīng)黑了!有一個人,我愛了她七年,而這七年以來,我無時無刻提醒自...
    因為愛我會回來閱讀 274評論 0 0
  • 告訴大家一個好消息! 我很幸運(yùn)被挑選為萬科基金會 “Green Fellows” 第一屆成員,到美國波士頓旗下一家...
    0d905ea337f1閱讀 178評論 0 0
  • 結(jié)構(gòu) 1:監(jiān)聽來電事件 2:查詢,打開,數(shù)據(jù)庫。匹配正則表達(dá)式 3:監(jiān)聽用戶手勢
    JokerLiang閱讀 267評論 0 0