I'm asking this question to help others who run into the same problem I ran into. The error is, at least sometimes, misleading and might not be accurate.

The context in which this error is relevant is signing a raw transaction that you created with bitcoin software. This is a common practice for those who are paranoid, like me. Here's the basic procedure:

  1. Identify the TxOuts (txid and vout pairs) that you want to spend.
  2. Use https://chainquery.com/bitcoin-api/createrawtransaction or something similar to create a hex string.
  3. Use https://chainquery.com/bitcoin-api/signrawtransaction along with the private keys required to spend those unspent TxOuts.

In that third step, you might get this "operation not valid with the current stack size" error.

3 Answers 3


The signrawtransaction RPC will verify the input scripts of the transaction after it signs it. If the transaction has not been fully signed (i.e. it isn't complete), then the script verification will fail and produce this error.

This also happens with multisig transactions. When you don't have enough signatures, the script will fail to verify with the error that you see.

See also: https://github.com/bitcoin/bitcoin/issues/9988


I have faced the same issue i was trying to creat a raw transaction with erronerous Vout (1 instead 0)

bitcoin-cli  createrawtransaction "[{\"txid\": \"cd32cc233298662131dab1c2f5fa7b0407879b51bfaa7e26afa4abf453951b09\", \"vout\": 1}]" "{\"data\":\"68656c6c6f20776f726c64\",\"mpCALgNebBXBJByCG7W5XPXe2NvuQCD8au\":1.10000000}"

so by fixing the vout i've got it signing perfectly


If you use a private key that is for an address different from those from the TxOuts that you want to spend, you can get this error. I suppose there are other possible causes, but that is the one that got me.

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.