I have fixed my initial transactions and have been able to send coins to a p2sh address

Now I want to spend those coins but when I try to broadcast my transactions either the website (blockcypher) accept it and it is then later not accepted by miners or rejected (blockstream) with:

sendrawtransaction RPC error: {"code":-26,"message":"non-mandatory-script-verify-flag (Extra items left on stack after execution)"}

I think I have made the the correct ScriptSig for the 2 of 2 multisig (OP_0, sig1, sig2, redeemscript) so I am not sure of my error:

OP_0 3045022100e91708339615eb38326a5c513b5dcc040bf59a1b97faef2c1f59a7b16426519a02200a4ca9d8c9f05ec824c70d1564ae2952650bc0ddc8bce92f081dd7d29d33d7ea01 3045022100ca0e751242a6d33ab2e895a9b1d9e5dce18426f2d11e69009e794ebc1004ba1a0220022a95a3f335fd84b380d6482948c24817a9f021f0dea75689eccf59e1540ae901 2d5214a175b609a7c37011420585f1fcf392fdda9a025414b1e9f0fa01914ff497607f99bf90dbd8a41bd8bb52ae

And here is my full tx:


and the code I use to create it:


  • I think you might have prepended the length of the redeem script. The redeem script must start with "52" and not with "2d". Since this changes the tx, the signatures are no longer valid. Try signing the tx again without the "2d". Mar 1, 2021 at 22:09

1 Answer 1


Your redeem script has the length of the script prepended to it (2d), which causes the stack execution to finalize with the redeem script in the stack as data instead of interpreting it as another script.

The script interprets the 2d as if you intended to put data in the stack with a length of 45 bytes, instead of actually interpreting your redeem script as a script. Therefore, Your redeem script must start with 52 and not the legth of the script which is 0x2d.

After you delete the 2d from the redeem script, sign the tx again since this extra byte also changes the whole tx to sign.

Also, if you used that redeem script to compute your p2sh address, it is possible that you sent the money to the wrong address.

  • It is funny while searching for help online I stumbled upon one of your question from here, Im gonna change my code then do the whole process again as you advise, luckily thats not real bitcoins
    – Saxtheowl
    Mar 1, 2021 at 22:54
  • lol nice. Let me know how it goes. Mar 2, 2021 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.