I'm trying to sign a transaction using signrawtransactionwithkey on bitcoin-core 0.17 but I'm getting the following error:

{"ERROR":"[{"txid":"c7e5bc9c9662384464182c713a6a6e20a2da72adb2b2a5799457be643d764139","vout":0,"witness":[],"scriptSig":"","sequence":4294967295,"error":"Witness program hash mismatch"}] 

parameters sent correctly since it's working on the testnet network it's just the mainnet

anyway the params sent as:


the inputs are


I have been reading the bitcoin source code trying to understand what's the problem and it's obvious that the exception been thrown on here

  if (memcmp(hashScriptPubKey.begin(), program.data(), 32)) {
                return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH);

and here

if (witness.stack.size() != 2) {
                return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH); // 2 items in witness
  • Could you please try removing the redeemScript parameter entirely?
    – MCCCS
    Commented Mar 16, 2019 at 13:20
  • I have tried that but exact same error. what makes me wonder that current exact code is working for testnet but not for mainnet.
    – Tailer
    Commented Mar 16, 2019 at 13:35
  • Are you sure you're using the correct private key?
    – Ava Chow
    Commented Mar 16, 2019 at 15:45

1 Answer 1


This error means that the transaction wasn't signed, which given that all of the inputs look correct, means that you are providing the wrong private key to sign the transaction with.

  • Thanks a lot it's was a rare error caused by an update to mysql server, which caused the problem. Thanks again and I wish that bitcoin-core make the errors a little bit cleaner.
    – Tailer
    Commented Mar 16, 2019 at 17:21

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.