Coinbase-Transaction

創世區塊的 ScriptSig (coinbase) 結構

  • November 15, 2021

來自原始比特幣 c++ 原始碼:

// Genesis Block:
       // CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
       //   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
       //     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
       //     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
       //   vMerkleTree: 4a5e1e

txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));

我們可以看到Scriptsig是:04FFF001D01045462627262626327262626262726262627262626327262626272626262726262626262626262626266c627262626327262626262726262626272626962632626262626262662696262626266266f75742066226622206622262662222062616222062616222062616e6b73

讓我們仔細看看:

04 - ?

ffff001d - 486604799 又名 0x1d00ffff

010445 - ?

5468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73 - 泰晤士報03 /月/ 2009年總理對銀行第二輪救助瀕臨的

我不明白 04 和 010445 是什麼。我怎樣才能得到它們?在 ScriptSig 行的 Genesis Block ( <https://en.bitcoin.it/wiki/Genesis_block> ) 的 wiki 頁面上,沒有關於 010445 的資訊。

以下是整個創世區塊的細分:

01000000 - version
0000000000000000000000000000000000000000000000000000000000000000 - prev block
3BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA4B1E5E4A - merkle root
29AB5F49 - timestamp
FFFF001D - bits
1DAC2B7C - nonce
01 - number of transactions
01000000 - version
01 - input
0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF - prev output
4D - script length
04FFFF001D0104455468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73 - scriptsig
FFFFFFFF - sequence
01 - outputs
00F2052A01000000 - 50 BTC
43 - pk_script length
4104678AFDB0FE5548271967F1A67130B7105CD6A828E03909A67962E0EA1F61DEB649F6BC3F4CEF38C4F35504E51EC112DE5C384DF7BA0B8D578A4C702B6BF11D5FAC - pk_script
00000000 - lock time

解碼ScriptSig

04 - push the next 4 bytes to stack
FFFF001D - 4 bytes pushed, they appear to be the same as bits
01 - push the next 1 byte to stack
04 - 1 byte pushed
45 - push the next 69 bytes to stack
5468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73 - pushed bytes, "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"

所以 010445 實際上是 2 個操作的一部分 - 01 將 04 推送到堆棧,45 將消息推送到堆棧。至於為什麼 push 04,打敗了我,也許它只是測試以確保某些東西有效?Satoshi 在創世區塊創建期間使用的一些內部計數器?由於硬幣生成交易的腳本真的毫無意義,我們可能永遠不會知道。

引用自:https://bitcoin.stackexchange.com/questions/13122