Scriptsig

測試網交易 - OPCODE MISSING OR NOT UNDERSTOOD 錯誤

  • March 26, 2018

我正在嘗試廣播手動生成的原始測試網交易。我從 SmartBit 收到以下錯誤:PUSH TRANSACTION ERROR: 16: MANDATORY-SCRIPT-VERIFY-FLAG-FAILED (OPCODE MISSING OR NOT UNDERSTOOD).

我的原始交易如下所示:

01000000
01
e6dc926ae5ffd4f6b83376c7df00136cd27284977714f3ab2295f0bb91e13547
00000000
8d
493046022100dc6c14b905647fc0efde3d37079853bb1cedbcdf2cfdecac6665a3b8b8b2395d022100b13412fae64c9b6341096acf3578d93ab450c23dd6361701ceb21cef6d80100201410404f89c713f44615ad5fdc16f1ef8628351a1cce79ee96130a0e4a6eb09d05278cef28cb002a6ad2ad53181b01d03f931538488a7a689d83684e54822305205d5ba
ffffffff
02
75a58c0600000000
1976a91413aa97d12703b051d9b670097bbf07e2cd78de6088ac
23ce010000000000
1976a914a9974100aeee974a20cda9a2f545704a0ab54fdc88ac
00000000

假設錯誤表明scriptsig有問題,分解scriptSig,它看起來像這樣:

49
30
46022100dc6c14b905647fc0efde3d37079853bb1cedbcdf2cfdecac6665a3b8b8b2395d022100b13412fae64c9b6341096acf3578d93ab450c23dd6361701ceb21cef6d80100201
41
04
04f89c713f44615ad5fdc16f1ef8628351a1cce79ee96130a0e4a6eb09d05278cef28cb002a6ad2ad53181b01d03f931538488a7a689d83684e54822305205d5ba

我究竟做錯了什麼?消費者的地址是:mhJwViAyjAdKoEFNPcX96zN2HxZpv69avm

編輯: 我放棄了額外的0x04並調整了 1 字節的公鑰長度。我仍然遇到同樣的錯誤。ScriptSig 現在看起來像這樣:

49
304502202c5a951bbfc185ffbe6c8b74f587a4c4b1afbf99ad2c95050c938dbecdf6bc4b022100a3594fa9168bc8030a73f8fa9d277fad1765ec06d71e378e8637df1e367d260f01
41
04f89c713f44615ad5fdc16f1ef8628351a1cce79ee96130a0e4a6eb09d05278cef28cb002a6ad2ad53181b01d03f931538488a7a689d83684e54822305205d5ba

快速驗證:

410404f89c713f44615ad5fdc16f1ef8628351a1cce79ee96130a0e4a6eb09d05278cef28cb002a6ad2ad53181b01d03f931538488a7a689d83684e54822305205​​d5ba

41 hex 等於 65。所以下面的字元串應該是 65 字節,但它是 66 字節。正如 arubi 所說,雙“04”有一個錯誤——它只需要一個。

快速證明:當我驗證公鑰時,我得到了正確的地址:04f89c713f44615ad5fdc16f1ef8628351a1cce79ee96130a0e4a6eb09d05278cef28cb002a6ad2ad53181b01d03f931538488a7a6239d83684d5048

SHA-256 hash of PUBKEY
EF14CA0F83CCDA08F81806AEFADF80BA58CCCD12B149E028EF86F7B00C04C293

RIPEMD-160 Hash
13AA97D12703B051D9B670097BBF07E2CD78DE60

Adding network bytes
6F13AA97D12703B051D9B670097BBF07E2CD78DE60

SHA-256
AD3575F9D5422C0BD5AE472DA035E54601085FA5F018F4F72EF2ED5E96602B0C

another SHA-256
02D633422E210032443A4F5595C443C311CD64A5C762A7E354CCB6E510F1196B

First four bytes
02D63342

Adding 4 Bytes at the end of the network bytes line
6F13AA97D12703B051D9B670097BBF07E2CD78DE6002D63342

Base58 encoding
mhJwViAyjAdKoEFNPcX96zN2HxZpv69avm

所以 pub 密鑰被錯誤地組裝到 sigscipt 中。在 S 值上:我可以看到,它用雙“0”擴展,但該值仍然保持“高”:

checking S-value is less than N/2, no...
   --> S is not smaller than N/2, need new S-Value (new_s = N - s)
   new S=4ECBED0519B3649CBEF69530CA8726C4065E1AA8D9128939F120419D62B6313F

更改 S 值時,可能需要調整長度欄位…只是出於好奇:您使用什麼工具來組裝 tx?

現在讓我們忽略簽名中的高 s 值:46022100dc6c14b905647fc0efde3d37079853bb1cedbcdf2cfdecac6665a3b8b8b2395d0221 00b13412fae64c9b6341096acf3578d93ab4050c23dd63071

公鑰推送似乎格式不正確。為什麼字節推送0x04後的額外內容?0x41

04f89c713f44615ad5fdc16f1ef8628351a1cce79ee96130a0e4a6eb09d05278cef28cb002a6ad2ad53181b01d03f931538488a7a689d83684e54822305205d5ba是一個有效的公鑰,所以我假設它是不合適的0x04

pubkey0x04在開始時自己的字節表示未壓縮的 pubkey。

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