1. 程式人生 > >數字貨幣開發專題(創世區塊裡藏著什麼祕密)

數字貨幣開發專題(創世區塊裡藏著什麼祕密)

區塊鏈愛好者(QQ:53016353)
#數字貨幣創世塊留言
這是廣為流傳的中本聰在數字貨幣創世塊的coinbase寫下“The Times 03/Jan/2009 Chancellor on brink of second bailout for banks” 這句話正是泰晤士報當天的頭版文章標題,如下:




coinbase的值為


"coinbase":"04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73"
解碼方法如下:


python shell下:


"04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73".decode('hex')'\x04\xff\xff\x00\x1d\x01\x04EThe Times 03/Jan/2009 Chancellor on brink of second bailout for banks'
或者在shell下


->strings -n 20 blk00000.datEThe Times 03/Jan/2009 Chancellor on brink of second bailout for banks
參考:




#隱藏的bitcoin logo
bitcoin_log


以上圖片隱藏在如下交易中:


解碼方法如下:


把ceb1a7fb57ef8b75ac59b56dd859d5cb3ab5c31168aa55eb3819cd5ddbd3d806 和9173744691ac25f3cd94f35d4fc0e0a2b9d1ab17b4fe562acc07660552f95518交易中所有vxout的scriptPubKey匯出:


bitcoind getrawtransaction ceb1a7fb57ef8b75ac59b56dd859d5cb3ab5c31168aa55eb3819cd5ddbd3d806 1
匯出出所有vxout的scriptPubKey:


 "OP_DUP OP_HASH160 3d79626567696e206c696e653d3132382073697a OP_EQUALVERIFY OP_CHECKSIG" "OP_DUP OP_HASH160 653d38373736206e616d653d626974636f696e2e OP_EQUALVERIFY OP_CHECKSIG", ......
刪除所有OP CODE,得到如下


'3d79626567696e206c696e653d3132382073697a','653d38373736206e616d653d626974636f696e2e','6a70670d0a2902293d4a2a3a747073702a2b2b2b','2a8a2a8a2a2a290b2a926fa293902a2a77772a54',......
轉換為hex


'3d79626567696e206c696e653d3132382073697a'.decode(hex)
把結果按yenc解碼:


if c == '=' and esc != 1:    esc = 1    continuen = ord(c)if esc:    c2 = chr((n-42-64+256)%256)    esc = 0else:    c2 = chr((n-42+256)%256)
完整的python程式碼 https://gist.github.com/shirriff/7461227133c26645abdf


  python3 parseImageFromBlock.py
討論見


#bitcoin論文
在交易54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713 中隱藏著比特幣的原始論文


解碼方法同上一條:


把交易中所有vxout的scriptPubKey匯出:
刪除所有OP CODE,得到如下
轉換為hex
把結果存為pdf
這裡有完整的python程式碼


python3 parseImageFromBlock.py


論文在這裡就不貼了, 你可以自己轉換看看


#Email from Satoshi Nakamoto
在交易77822fd6663c665104119cb7635352756dfc50da76a92d417ec1a12c518fad69 中隱藏著一封中本聰的電子郵件


解碼方法:


把交易中所有vxout的scriptPubKey匯出,這個scriptPubKey比較特殊: scriptPubKey: OP_IF OP_INVALIDOPCODE 4effffffff 1443 bytes of data OP_ENDIF
刪除OP CODE
轉為hex
結果如下:


From a3a61fef43309b9fb23225df7910b03afc5465b9 Mon Sep 17 00:00:00 2001From: Satoshi Nakamoto Date: Mon, 12 Aug 2013 02:28:02 -0200Subject: [PATCH] Remove (SINGLE|DOUBLE)BYTEI removed this from Bitcoin in f1e1fb4bdef878c8fc1564fa418d44e7541a7e83in Sept 7 2010, almost three years ago. Be warned that I have notactually tested this patch.--- backends/bitcoind/deserialize.py |    8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)diff --git a/backends/bitcoind/deserialize.py b/backends/bitcoind/deserialize.pyindex 6620583..89b9b1b 100644--- a/backends/bitcoind/deserialize.py+++ b/backends/bitcoind/
[email protected]
@ -280,10 +280,8 @@ opcodes = Enumeration("Opcodes", [     "OP_WITHIN", "OP_RIPEMD160", "OP_SHA1", "OP_SHA256", "OP_HASH160",     "OP_HASH256", "OP_CODESEPARATOR", "OP_CHECKSIG", "OP_CHECKSIGVERIFY", "OP_CHECKMULTISIG",     "OP_CHECKMULTISIGVERIFY",-    ("OP_SINGLEBYTE_END", 0xF0),-    ("OP_DOUBLEBYTE_BEGIN", 0xF000),     "OP_PUBKEY", "OP_PUBKEYHASH",-    ("OP_INVALIDOPCODE", 0xFFFF),+    ("OP_INVALIDOPCODE", 0xFF), ])@@ -293,10 +291,6 @@ def script_GetOp(bytes):         vch = None         opcode = ord(bytes[i])         i += 1-        if opcode >= opcodes.OP_SINGLEBYTE_END and i < len(bytes):-            opcode <<= 8-            opcode |= ord(bytes[i])-            i += 1         if opcode <= opcodes.OP_PUSHDATA4:             nSize = opcode-- 1.7.9.4