了解基本比特幣交易:scriptPubKey.addresses 數組
我曾經認為 scriptPubKey (vout) 中的地址數組是從腳本開始填充的,但是在檢查老式的多重簽名交易時,我發現有些東西使我的假設錯誤:
鑑於這三個投票:
{ "value" : 0.01000000, "n" : 0, "scriptPubKey" : { "asm" : "1 04cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e7e2e6d317b87bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4 0461cbdcc5409fb4b4d42b51d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5b0e4ef8551946d8a540911abe3e7854a26f39f58b25c15342af 2 OP_CHECKMULTISIG", "hex" : "514104cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e7e2e6d317b87bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4410461cbdcc5409fb4b4d42b51d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5b0e4ef8551946d8a540911abe3e7854a26f39f58b25c15342af52ae", "reqSigs" : 1, "type" : "multisig", "addresses" : [ "1AJbsFZ64EpEfS5UAjAfcUG8pH8Jn3rn1F", "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq" ] } } { "value" : 0.00000002, "n" : 0, "scriptPubKey" : { "asm" : "1 0351efb6e91a31221652105d032a2508275f374cea63939ad72f1b1e02f477da78 00f2b7816db49d55d24df7bdffdbc1e203b424e8cd39f5651ab938e5e4a193569e 2 OP_CHECKMULTISIG", "hex" : "51210351efb6e91a31221652105d032a2508275f374cea63939ad72f1b1e02f477da782100f2b7816db49d55d24df7bdffdbc1e203b424e8cd39f5651ab938e5e4a193569e52ae", "reqSigs" : 1, "type" : "multisig", "addresses" : [ "1NdB761LmTmrJixxp93nz7pEiCx5cKPW44" ] } }
分別來自交易:
60a20bd93aa49ab4b28d514ec10b06e1829ce6818ec06cd3aabd013ebcdc4bb1 274f8be3b7b9b1a220285f5f71f61e2691dd04df9d69bb02a8b3b85f91fb1857
我注意到他們共享相同的腳本:
OP1 OPDATA OPDATA OP2 OP_CHECKMULTISIG
但結果不同。
在第一個交易中,您可以在地址數組中看到兩個地址,在第二個交易中您只能看到一個地址。
另外,鑑於此:
{ "value" : 0.00000001, "n" : 22, "scriptPubKey" : { "asm" : "1 6565292c66696c653d7379732e737464657272290a0a69662046616c73653a0a202020207072696e742870726f78792e73656e647261777472616e73616374696f 6e287369676e65645f74785b27686578275d29290a656c73653a0a202020207072696e74287369676e65645f7478290a0000000000000000000000000000000000 2 OP_CHECKMULTISIG", "hex" : "51416565292c66696c653d7379732e737464657272290a0a69662046616c73653a0a202020207072696e742870726f78792e73656e647261777472616e73616374696f416e287369676e65645f74785b27686578275d29290a656c73653a0a202020207072696e74287369676e65645f7478290a000000000000000000000000000000000052ae", "type" : "multisig" } }
來自交易 4b72a223007eab8a951d43edc171befeabc7b5dca4213770c88e09ba5b936e17
解析的事務中沒有 reqsigs 或地址。
所以,我想我對地址數組的填充方式有點困惑。
發送:60a20bd93aa49ab4b28d514ec10b06e1829ce6818ec06cd3aabd013ebcdc4bb1
OP_1 04cc71eb[...cut...]0d348ac4 // this is pubkey of 1AJbsFZ64EpEfS5UAjAfcUG8pH8Jn3rn1F 0461cbdc[...cut...]c15342af // this is pubkey of 1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq OP_2 OP_CHECKMULTISIG
要花費這筆交易,應該使用兩個私鑰之一對其進行簽名
發送:274f8be3b7b9b1a220285f5f71f61e2691dd04df9d69bb02a8b3b85f91fb1857
OP_1 0351efb6[...cut...]77da78 // this is public key of 1NdB761LmTmrJixxp93nz7pEiCx5cKPW44 00f2b781[...cut...]93569e // this is not a public key! OP_2 OP_CHECKMULTISIG
TX:4b72a223007eab8a951d43edc171befeabc7b5dca4213770c88e09ba5b936e17
您可以在此處閱讀有關此交易的資訊: http ://www.righto.com/2014/02/ascii-bernanke-wikileaks-photographs.html [16]
看起來它與 <https://github.com/bitcoin/bitcoin/blob/master/src/pubkey.h#L48>有關。
據我了解(也感謝#bitcoin @freenode 使用者)我試圖解碼的pubkeys 與此檢查不匹配,因此,對於記錄:在提到的範例中,addresses 數組(和 reqSigs int ) 僅當 pubkey 的第一個字節匹配相對長度的檢查(壓縮與否)時才會填充。