Bitcoin-Core

PSZ Timestamp 在比特幣核心程式碼中是如何編碼的?

  • July 23, 2018

在Bitcoin Core源碼的Chainparams.cpp中,編碼PSZTimestamp如下

04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73

原始字元串是

The Times 03/Jan/2009 Chancellor on brink of second bailout for banks

如果您將其轉換為HEX線上使用任何字元串到十六進制轉換器,您會得到

5468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73

這是encoded PSZTimestamp第 16 個字元的子字元串。我的問題:

前 16 個字元從何而來? 04ffff001d010445

04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73

上面其實是比特幣腳本,不僅僅是字節數據。

這分解為:

04         # PUSH the next 4 bytes
ffff001d   # This is the same as the nbits for the block, which was the target for the genesis block difficulty
01         # PUSH 1 byte
04         # PUSHed 1 byte - I'm not entirely sure what this 4 represents
45         # PUSH the next 69 bytes (0x45 == 69)
# The text
5468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73

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