transactionsbitcoinbitcoin-testnet

Bitcoin P2PKH signing process throws mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation)


I'm trying to sign and broadcast a regtest P2PKH transaction.

previous transaction hex:

020000000001035a2fd7d9b2dfb25b03c3e602f652bd724db07acab3fd3eb1de68f7ad2f4694140000000000feffffff521441c610969652ba7cb017ce7db0731138013122b47aac1ce8caaa5e1fce190000000000feffffffa77a07589d12ceedaa27929b13654c2ca41e43ef1042d57f1f01e9efb65195d9000000006a47304402207212c1279c7e63439ec5ddc86ae6ac0faa13379af904791e1084a90d7b81638502204efae464a34cdf6125ea472540097de23930ce168b968b2850da5e3f761a9c5d012102e1ab11484eaa09e1955fe640a2e884b2900497428a895688ef586799b1f1ff1ffeffffff0200ca9a3b000000001976a91448bd61c0dcb03018ee6604f5b32edab07975e61688ac88f59505000000001976a914a8bb4f75fac6c10972b4c060a65efacead543be788ac0247304402202da78e9e1d4fec03a0b326f5b80db6446209d64d2138df1f0dc303b9454020250220216513e81182d2508aa1e0d036ddb4973170926a9f7e2237e4bb2eed621689a3012102b0dc39ccb8aea237695913d390a72d322b47eb6dda61c216a4ff1a3d06bac49402473044022039cfa24798c991e6b373772c5cadae6b898a680e78b9fd55b27225a3ed8ce7fe02205dddda9430c7d86a27a877ca77c99f563bca574565613d242f434673e662fe93012103188f0e4cc8aa6e88966b3fcb20494deaa771aeae6828241e00af852fb228f8080000000000

new transaction hex:

0100000001beabc86499ccbefa281da4ea818be45b05dcc4df55ecbb15199b5ce4e3013409000000006a47304402201b494b019df0b380331fdb728d67e61f95657d2f411fdf105c2a47411f72cb780220753560b7f00f60ab3ad53640efa325b34b3ef991392261a13d9886492228a8960121039355776cdc3015a62d7a5d206003c5b4d754f2de3a2d9358114df3d0b1ec743bffffffff0100e1f505000000001976a914bef5a2f9a56a94aab12459f72ad9cf8cf19c7bbe88ac00000000

when I try to sendrawtransaction it throws a:

mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation)

I don't understand this error, but I've made a research about and found this: https://bitcoin.stackexchange.com/questions/84287/bitcoin-script-mandatory-script-verify-flag-failed-script-failed-an-op-equalver

As it suggested, I tried btcdeb:

btcdeb --txin=020000000001035a2fd7d9b2dfb25b03c3e602f652bd724db07acab3fd3eb1de68f7ad2f4694140000000000feffffff521441c610969652ba7cb017ce7db0731138013122b47aac1ce8caaa5e1fce190000000000feffffffa77a07589d12ceedaa27929b13654c2ca41e43ef1042d57f1f01e9efb65195d9000000006a47304402207212c1279c7e63439ec5ddc86ae6ac0faa13379af904791e1084a90d7b81638502204efae464a34cdf6125ea472540097de23930ce168b968b2850da5e3f761a9c5d012102e1ab11484eaa09e1955fe640a2e884b2900497428a895688ef586799b1f1ff1ffeffffff0200ca9a3b000000001976a91448bd61c0dcb03018ee6604f5b32edab07975e61688ac88f59505000000001976a914a8bb4f75fac6c10972b4c060a65efacead543be788ac0247304402202da78e9e1d4fec03a0b326f5b80db6446209d64d2138df1f0dc303b9454020250220216513e81182d2508aa1e0d036ddb4973170926a9f7e2237e4bb2eed621689a3012102b0dc39ccb8aea237695913d390a72d322b47eb6dda61c216a4ff1a3d06bac49402473044022039cfa24798c991e6b373772c5cadae6b898a680e78b9fd55b27225a3ed8ce7fe02205dddda9430c7d86a27a877ca77c99f563bca574565613d242f434673e662fe93012103188f0e4cc8aa6e88966b3fcb20494deaa771aeae6828241e00af852fb228f8080000000000 --tx=0100000001beabc86499ccbefa281da4ea818be45b05dcc4df55ecbb15199b5ce4e3013409000000006a47304402201b494b019df0b380331fdb728d67e61f95657d2f411fdf105c2a47411f72cb780220753560b7f00f60ab3ad53640efa325b34b3ef991392261a13d9886492228a8960121039355776cdc3015a62d7a5d206003c5b4d754f2de3a2d9358114df3d0b1ec743bffffffff0100e1f505000000001976a914bef5a2f9a56a94aab12459f72ad9cf8cf19c7bbe88ac00000000

output:

script                                                             |  stack 
-------------------------------------------------------------------+--------
304402201b494b019df0b380331fdb728d67e61f95657d2f411fdf105c2a474... | 
039355776cdc3015a62d7a5d206003c5b4d754f2de3a2d9358114df3d0b1ec743b | 
<<< scriptPubKey >>>                                               | 
OP_DUP                                                             | 
OP_HASH160                                                         | 
48bd61c0dcb03018ee6604f5b32edab07975e616                           | 
OP_EQUALVERIFY                                                     | 
OP_CHECKSIG                                                        | 
#0000 304402201b494b019df0b380331fdb728d67e61f95657d2f411fdf105c2a47411f72cb780220753560b7f00f60ab3ad53640efa325b34b3ef991392261a13d9886492228a89601

I'm running out of ideas, that's why I need your help.

EDIT:

My error was to convert my dumpprivkey from base58 to hex using non-bitcoin tools. Some of non-bitcoin tools do not removes the first byte and the checksum, so the private key is altered.

-> https://github.com/matja/bitcoin-tool
-> https://bitcoin.stackexchange.com/questions/52951/how-to-get-the-private-key-in-hex-from-the-output-of-dumpprivkey


Solution

  • The public key you are using, 039355776cdc3015a62d7a5d206003c5b4d754f2de3a2d9358114df3d0b1ec743b, has a HASH160 digest of b8e4fdb2bfa5a1cb796232ded6580c9ab52ffbb3.

    Since the HASH160 you have provided in the script is different from the one evaluated in the stack, it is failing the equal verify operation.