1

Trying to build Bitcoin raw transaction for Bitcoin Testnet in Golang, but when trying to send getting an error:

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

Here is raw transaction:

01000000014071216d4d93d0e3a4d88ca4cae97891bc786e50863cd0efb1f15006e2b0b1d6010000008a4730440220658f619cde3c5c5dc58e42f9625ef71e8279f923af6179a90a0474a286a8b9c60220310b4744fa7830e796bf3c3ed9c8fea9acd6aa2ddd3bc54c4cb176f6c20ec1be0141045128ccd27482b3791228c6c438d0635ebb2fd6e78aa2d51ea70e8be32c9e54daf29c5ee7a3752b5896e5ed3693daf19b57e243cf2dcf27dfe5081cfcf534496affffffff012e1300000000000017a914de05d1320add0221111cf163a9764587c5a171ba8700000000

Tried to debug with 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

Can anybody give an advice on where to look at?

it4ddict
  • 29
  • 5

1 Answers1

0

Judging from the examples in the btcdeb documentation, you should expect to see a valid script message when starting btcdeb, if the script validates correctly.


btcdeb will still allow you to step through the script with the step command, but because the script is invalid in the first place, this may not tell you much, except that it decides to halt after reaching <<< P2SH script >>>, thinking that is the end of the script.

The most obvious fix should be to remove OP_UNKNOWN, which represents an opcode that was not understood by btcdeb, but there are probably other errors lurking that prevent the script from validating also. You could try removing the end of the script, and building it back up incrementally, testing with the debugger, until it works.

soccer193
  • 413
  • 2
  • 7