<p>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.</p>

CC BY-SA 4.0
2019-03-16T17:21:20.577Z
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
CC BY-SA 4.0
2019-03-16T15:49:00.930Z
2019-03-16T15:49:00.930Z
Ava Chow
<p>I'm trying to sign a transaction using <code>signrawtransactionwithkey</code> on bitcoin-core 0.17 but I'm getting the following error: </p>

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

<p>parameters sent correctly since it's working on the testnet network
it's just the mainnet</p>

<p>anyway the params sent as:</p>

<pre><code>["transaction_in_hex",["private_key"],[inputs]
</code></pre>

<p>the inputs are</p>

<pre><code>[{"txid":"c7e5bc9c9662384464182c713a6a6e20a2da72adb2b2a5799457be643d764139","vout":0,"scriptPubKey":"0014f3dd9523e2a801770513e00ed717fd610ea634af","amount":"0.00099784","address":"bc1q70we2glz4qqhwpgnuq8dw9lavy82vd903k7hpe","redeemScript":""}]]
</code></pre>

<p>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 <a href="https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/script/interpreter.cpp#L1435" rel="nofollow noreferrer">here</a></p>

<pre><code>  if (memcmp(hashScriptPubKey.begin(), program.data(), 32)) {
                return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH);
            }
</code></pre>

<p>and here</p>

<pre><code>if (witness.stack.size() != 2) {
                return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH); // 2 items in witness
            }
</code></pre>

CC BY-SA 4.0
2019-03-16T13:20:36.640Z
Could you please try removing the `redeemScript` parameter entirely?
MCCCS
CC BY-SA 4.0
2019-03-16T13:35:25.837Z
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
CC BY-SA 4.0
2019-03-16T15:45:45.523Z
Are you sure you're using the correct private key?
Ava Chow
<bitcoin-core><bech32-address>
Witness program hash mismatch while signing bech32 transaction
Tailer
# Witness program hash mismatch while signing bech32 transaction

(Asked by: username_0 on 2019-03-16)

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:

```
["transaction_in_hex",["private_key"],[inputs]

```

the inputs are

```
[{"txid":"c7e5bc9c9662384464182c713a6a6e20a2da72adb2b2a5799457be643d764139","vout":0,"scriptPubKey":"0014f3dd9523e2a801770513e00ed717fd610ea634af","amount":"0.00099784","address":"bc1q70we2glz4qqhwpgnuq8dw9lavy82vd903k7hpe","redeemScript":""}]]

```

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](https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/script/interpreter.cpp#L1435)

```
  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
            }

```

**Tags:** bitcoin-core, bech32-address

> **Comments:**
> **username_1**: Could you please try removing the `redeemScript` parameter entirely?  
> **username_0**: I have tried that but exact same error. what makes me wonder that current exact code is working for testnet but not for mainnet.  
> **username_2**: Are you sure you're using the correct private key?  

---

## 1 answers

### Answer by username_2 on 2019-03-16. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_0**: 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.  

---

