1

尝试在 Golang 中为比特币测试网构建比特币原始交易,但在尝试发送时出现错误:

mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack element)

这是原始交易:

01000000014071216d4d93d0e3a4d88ca4cae97891bc786e50863cd0efb1f15006e2b0b1d6010000008a4730440220658f619cde3c5c5dc58e42f9625ef71e8279f923af6179a90a0474a286a8b9c60220310b4744fa7830e796bf3c3ed9c8fea9acd6aa2ddd3bc54c4cb176f6c20ec1be0141045128ccd27482b3791228c6c438d0635ebb2fd6e78aa2d51ea70e8be32c9e54daf29c5ee7a3752b5896e5ed3693daf19b57e243cf2dcf27dfe5081cfcf534496affffffff012e1300000000000017a914de05d1320add0221111cf163a9764587c5a171ba8700000000

尝试使用 btcdeb 进行调试:

./btcdeb --tx=01000000014071216d4d93d0e3a4d88ca4cae97891bc786e50863cd0efb1f15006e2b0b1d6010000008a4730440220658f619cde3c5c5dc58e42f9625ef71e8279f923af6179a90a0474a286a8b9c60220310b4744fa7830e796bf3c3ed9c8fea9acd6aa2ddd3bc54c4cb176f6c20ec1be0141045128ccd27482b3791228c6c438d0635ebb2fd6e78aa2d51ea70e8be32c9e54daf29c5ee7a3752b5896e5ed3693daf19b57e243cf2dcf27dfe5081cfcf534496affffffff012e1300000000000017a914de05d1320add0221111cf163a9764587c5a171ba8700000000 --txin=02000000000101394187cababd1c18dfc9d30d6325167aa654b1d35505ab77cd1b96562fda5d500000000017160014c0a4f9f451ea319f67c6d2535c1e41bd5d333214feffffff02f009aab80000000017a91455f5b5f3afa4751a54205941a45a14b27ad99be787ec8016000000000017a91435ac960b988964007c167c38ea724e034123e6b1870247304402205d6b22bcaf1a58bc41224eecc7437eef0db9b7e7fb709826314a8bd73adb330702204fbbbd49747d75331a89e2f7b486e0b7a786ecef3229b8e3fec0c4be491921c301210233eab1d60449c393c8f22d4b5d98ee103060d9644dc2af665e607a62e2151bbc30091e00
btcdeb 0.4.21 -- type `./btcdeb -h` for start up options
    LOG: sign segwit taproot
    notice: btcdeb has gotten quieter; use --verbose if necessary (this message is temporary)
    input tx index = 0; tx input vout = 1; value = 1474796
    got witness stack of size 0
    14 op script loaded. type `help` for usage information
    script                                                             |  stack
    -------------------------------------------------------------------+--------
    30440220658f619cde3c5c5dc58e42f9625ef71e8279f923af6179a90a0474a... |
    045128ccd27482b3791228c6c438d0635ebb2fd6e78aa2d51ea70e8be32c9e5... |
    <<< scriptPubKey >>>                                               |
    OP_HASH160                                                         |
    35ac960b988964007c167c38ea724e034123e6b1                           |
    OP_EQUAL                                                           |
    <<< P2SH script >>>                                                |
    5128ccd2                                                           |
    OP_DEPTH                                                           |
    OP_SIZE                                                            |
    OP_NOP4                                                            |
    OP_PICK                                                            |
    28c6c438d0635ebb2fd6e78aa2d51ea70e8b                               |
    OP_UNKNOWN                                                         |
    #0000 30440220658f619cde3c5c5dc58e42f9625ef71e8279f923af6179a90a0474a286a8b9c60220310b4744fa7830e796bf3c3ed9c8fea9acd6aa2ddd3bc54c4cb176f6c20ec1be01

任何人都可以提供关于在哪里看的建议吗?

4

1 回答 1

0

btcdeb 文档中的示例来看,如果脚本验证正确,您应该会在启动时看到一条valid script消息。btcdeb


btcdeb仍然允许您使用step命令单步执行脚本,但由于脚本首先是无效的,这可能不会告诉您太多,除了它决定在到达 后停止<<< P2SH script >>>,认为这是脚本的结尾。

最明显的修复应该是删除OP_UNKNOWN,它表示一个不被 理解的操作码btcdeb,但可能还有其他潜在的错误会阻止脚本验证。您可以尝试删除脚本的结尾,并逐步构建它,使用调试器进行测试,直到它工作为止。

于 2021-04-08T03:16:16.853 回答