Transactions

比特幣腳本:mandatory-script-verify-flag-failed 腳本未能通過 OP_EQUALVERIFY 操作

  • February 6, 2019

我嘗試使用 200 個塊的 timelockscript 花費 P2SH 交易(在 regtest 中)。我收到以下錯誤:

強制腳本驗證標誌失敗(腳本失敗 OP_EQUALVERIFY 操作)(程式碼 16)

不幸的是,我找不到錯誤,因為腳本和序列似乎很好。

decodescript 02c800b27576a921023fb59ee7e5722a9c559d366f6ca114c73361108c04e27a18060cef7a727d58a988ac
{
 "asm": "200 OP_CHECKSEQUENCEVERIFY OP_DROP OP_DUP OP_HASH160 023fb59ee7e5722a9c559d366f6ca114c73361108c04e27a18060cef7a727d58a9 OP_EQUALVERIFY OP_CHECKSIG",
 "type": "nonstandard",
 "p2sh": "2NF4BoboM58w8JJgdvbe7i6J3R8Kb3Gugqi",
 "segwit": {
   "asm": "0 da6ffdda71c413d3b26344158aac0f086bf5d979df2b81f9551da5ef62ee71b0",
   "hex": "0020da6ffdda71c413d3b26344158aac0f086bf5d979df2b81f9551da5ef62ee71b0",
   "reqSigs": 1,
   "type": "witness_v0_scripthash",
   "addresses": [
     "bcrt1qmfhlmkn3csfa8vnrgs2c4tq0pp4ltktemu4cr724rkj77chwwxcq84ftzy"
   ],
   "p2sh-segwit": "2MvKhZeGAV5KpkQXYnB4BydLMwMZGw6N8Ap"
 }
}

decoderawtransaction 02000000013db72755b71d95be7f6785448b5387b6273ca26fd5e42204390899154b111a5300000000754830450221009b813cf658ec2c30e68fd23c369c348fd5f915f77b49581a945aa2f2f2d3c8aa022058f6a7eb78b2132d24cc260699fdc158fda6f3a0d10bc3c52bacccc03bb6b8cb012b02c800b27576a921023fb59ee7e5722a9c559d366f6ca114c73361108c04e27a18060cef7a727d58a988acc800007f0100127a00000000001976a914fd337ad3bf81e086d96a68e1f8d6a0a510f8c24a88ac00000000
{
 "txid": "7f0262e1448896a4091bf9d1c55e346766b2aa8c19895bccaf2194b610f02525",
 "hash": "7f0262e1448896a4091bf9d1c55e346766b2aa8c19895bccaf2194b610f02525",
 "version": 2,
 "size": 202,
 "vsize": 202,
 "weight": 808,
 "locktime": 0,
 "vin": [
   {
     "txid": "531a114b159908390422e4d56fa23c27b687538b4485677fbe951db75527b73d",
     "vout": 0,
     "scriptSig": {
       "asm": "30450221009b813cf658ec2c30e68fd23c369c348fd5f915f77b49581a945aa2f2f2d3c8aa022058f6a7eb78b2132d24cc260699fdc158fda6f3a0d10bc3c52bacccc03bb6b8cb[ALL] 02c800b27576a921023fb59ee7e5722a9c559d366f6ca114c73361108c04e27a18060cef7a727d58a988ac",
       "hex": "4830450221009b813cf658ec2c30e68fd23c369c348fd5f915f77b49581a945aa2f2f2d3c8aa022058f6a7eb78b2132d24cc260699fdc158fda6f3a0d10bc3c52bacccc03bb6b8cb012b02c800b27576a921023fb59ee7e5722a9c559d366f6ca114c73361108c04e27a18060cef7a727d58a988ac"
     },
     "sequence": 2130706632
   }
 ],
 "vout": [
   {
     "value": 0.08000000,
     "n": 0,
     "scriptPubKey": {
       "asm": "OP_DUP OP_HASH160 fd337ad3bf81e086d96a68e1f8d6a0a510f8c24a OP_EQUALVERIFY OP_CHECKSIG",
       "hex": "76a914fd337ad3bf81e086d96a68e1f8d6a0a510f8c24a88ac",
       "reqSigs": 1,
       "type": "pubkeyhash",
       "addresses": [
         "n4bkvTyU1dVdzsrhWBqBw8fEMbHjJvtmJR"
       ]
     }
   }
 ]
}

該故障發生,因為hash160(30450221009b813cf658ec2c30e68fd23c369c348fd5f915f77b49581a945aa2f2f2d3c8aa022058f6a7eb78b2132d24cc260699fdc158fda6f3a0d10bc3c52bacccc03bb6b8cb)不023fb59ee7e5722a9c559d366f6ca114c73361108c04e27a18060cef7a727d58a9。

Hash160 的長度為 160 位,最終為 40 個十六進製字元。023fb… 上面是 66 個字元,所以沒有 hash160 可以匹配它。調查它是從哪裡來的?


我發現 btcdeb <https://github.com/kallewoof/btcdeb>對於這類問題非常有用:它是一個命令行工具,允許單步執行比特幣腳本。OP的腳本是: 30450221009b813cf658ec2c30e68fd23c369c348fd5f915f77b49581a945aa... | 02c800b27576a921023fb59ee7e5722a9c559d366f6ca114c73361108c04e27... | &lt;&lt;&lt; scriptPubKey &gt;&gt;&gt; | OP_HASH160 | ef3c5e4ee866b692245de650b178d83ca3d0fdbd | OP_EQUAL | &lt;&lt;&lt; P2SH script &gt;&gt;&gt; | c800 | OP_CHECKSEQUENCEVERIFY | OP_DROP | OP_DUP | OP_HASH160 | 023fb59ee7e5722a9c559d366f6ca114c73361108c04e27a18060cef7a727d58a9 | OP_EQUALVERIFY | OP_CHECKSIG | #0000

他的問題可以通過呼叫來複製:

btcdeb --txin 02000000107c60fb7c4de7528b0693f189483996f62d04527a693b86ffd940fe21c2efe65a00000000484730440220521eae742c5587ea8d0947879de20f6ff07c30a3e6fc37f3472374d94d1c57b102207cdf2e65e9812adebe37f28279ac23c7f316c5cdd00104aa92396d2768724e0201feffffff15aeb7dae6d514d833e3f25ffc1a992cb2dbc633b30c09f314e726d22ab34c2f000000004847304402206669b4a43e22272d18dcdd99527fcbfbf97bb024ea808bd9ae1ee492da5ab361022045625e98f6f8ddfb3427d4d43f66722d799fbce338f1dd8cbf2ba8c4082756d901feffffffdb2b200941d79838f30139ffc8b1b23bae1cb298a5642a4b3242c74e3614308c0000000048473044022043cb6c47831ad4903c4f657031671fe5b3e8c3e8b4c12de3bc62af6cbda60b32022052c41f1a6e767ebe663b10a4e7350ad12555b4524c0d51ceb50a929466bef89101feffffffc676855c7880b9672531cf3b5bdf170e683ecf43881cb69ded2f469e1725de370000000048473044022057f71e9d946525338e4a504f9cf55065154de09a5f85a8c68d586648246bd99f02202322de86499f035a99d90861bda53d72eb5b8bbeb0349e472290e25db8d5843601feffffff34cdc4315cee2f6c754ac9d6aff58ce87d24d2ea9f1a7427274ecec7f33acc650000000048473044022039444c85f778fd8a95cfdf4afef47ba804425d2ca97907e86393af56406f472a022029de7c2617d2e7d8c1958bd84b775e1b8d4d1e22591529dc13ae050b0b96999001feffffffd6a7bf9cd512e454b7b1b33f2484a16cf5237d8a9e6ecf49294dd7931a5e88d600000000484730440220492bbaa48ca4ea7424412d6421e87f95f0f1b5beefc4c1c818bd2a94b9b5a00402207ef391cdc9f84e88d1ff2cc7d68edb5afacd7ad0be3a478df0911b1bb1973cf401feffffff89e1344e9d47932c19b24a88062ee6166cc9704d26820690c903e3a63924b924000000004847304402207fcd1b6818c875abe2148b1dfe1553c73c2eca561ec3ce1e99c6bbab3b6543830220562dfa7391a5823563fbecf3e41361e6b7a4b3f541b39f667ad0137c726c9de801feffffffe7092dda245a178b4e50dcda70cbc9fedef3fadfef94c6dbe5dc349d105cb94e0000000048473044022002fdc279d955d8d0e60c4705b170b700d934fbf5efa1d7c8b2443ab1587d80b9022000c8d135e6f81c664487ca8431c7e6eb89a3eb618f646b2bce28b5517dbff72a01feffffff8bf3c8734ee9682ffbce41e520a2e8a466c5d46654d98cbcd4ebfcf64a73939700000000484730440220629988e915cb34552abeef352b7a1a0ebd6792d0a0c91d8d906dd6065ee68a4902207646cc98da887dd19b3d26185d5bcae423fcba036c8c1082985ac8a260e7f54001feffffff4a3b666ad423ba3a2b7a14edef7d826cf7587a2774b9f3937e75aade5698d09c000000004847304402205644ed173a99869018434ea4a1a580a1a1815431f294f134dda6cb259613962f02201d6fe1aae7fe07a88c686bf31348b07927b5088bb321af9169ddf1b232b421e601feffffff75dd734653ba95042205708b007b448aaef21cf972e8e25d76485b66a8f6c5a0000000004847304402200b4301e24066c184a4014cddec046fb9990c08caf73130e780ff9b3959e510a402206e947ea7a81cdd2ed67ae88bca5ccad5db2b29cd86cb3f57755cae19121e74d801feffffff7c704726f11711d0b75f399272c697ee49bb10aeaf170372dd50480b2fe194d9000000004847304402202bd26868009c2fc5d94525eabb1197cef6aac5b235d1623c3a762fe61295c1ba022024b9c7ecb2c28a01ba8976bd4ab9779915d37b788dc6dcdec335f89e457a99d101feffffff0a6b94c0ded59df2a0ec996581af027e4116d915e5264fb14a6555f266bec285000000004847304402203997a2d145c8cef3879c5d5dccf7758081b95d3be05443c07053d9d352d4fc2802204f66e8ceadf3147118f430404cbfa8f3b4b99d3a410d69d2a831646c1a5c2f3b01feffffff2f04521db3ecbefd9cd14ef6a594572508cbb2d9c9f544700bde46363f573926000000004847304402200fa171a3d8e4c5105504b498d039d3c386e8325b672c558e97c2751aba8ab0ba022026ba230078fac40413b0d3abc43546d3b9a779eb7af0d08544ac39355475dd4301feffffffdad37c38f84fc6fddee6510ee88705719128b1b5b2dadbc4df7e2e61164e6989000000004847304402202e8751498d9bf91cba9935100dda9cb27f404c91b1531b5dc8904278bb25b0730220537b9a18d368466680fff9c2434788f616b6d99ed46ec04c775cd041d64fc14701feffffff519a0366daed0321fcb1cbb78dd6d5d65febd7e7ea2b100c73396a98a09c2ef50000000048473044022048e89845d80f216f291001fee37e8c7178e40b97af051d57679fc46707a426bf02203ae8c2e132b4c5dbbcd97c59584a0ea9cec6a78294fe7fbfdb86d6ebe13ffc7101feffffff01809698000000000017a914ef3c5e4ee866b692245de650b178d83ca3d0fdbd8782170000 --tx 02000000013db72755b71d95be7f6785448b5387b6273ca26fd5e42204390899154b111a5300000000754830450221009b813cf658ec2c30e68fd23c369c348fd5f915f77b49581a945aa2f2f2d3c8aa022058f6a7eb78b2132d24cc260699fdc158fda6f3a0d10bc3c52bacccc03bb6b8cb012b02c800b27576a921023fb59ee7e5722a9c559d366f6ca114c73361108c04e27a18060cef7a727d58a988acc800007f0100127a00000000001976a914fd337ad3bf81e086d96a68e1f8d6a0a510f8c24a88ac00000000

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