<p>If you look at input 0, it doesn't contain a <code>witness</code> element, this means it isn't signed. You need to sign both inputs to be able to broadcast.</p>

CC BY-SA 4.0
2021-10-14T20:15:24.097Z
Thanks Ben, had missed that. Appreciate it
satirn
CC BY-SA 4.0
2021-10-14T17:53:54.303Z
2021-10-14T17:53:54.303Z
benthecarman
<p>I'm attempting to construct a funding transaction for a DLC. So far I have created the following transaction which encodes entry of a bet for local/remote collateral of 1000/1000 sats and binary win/lose all or nothing outcome.</p>
<p>As far as I can tell, the transactions are accurate in terms of inputs/outputs addresses etc, and the signatures were provided (see below), but I'm getting this error:</p>
<p><code>non-mandatory-script-verify-flag (Witness program hash mismatch) (code 64)</code></p>
<p>when attempting to broadcast the transaction.
hex:</p>
<pre><code>&lt;txhash&gt;
</code></pre>
<p>I also attempted broadcasting with another service, which had a more descriptive error so I'll also post this here:</p>
<p><code>Error validating transaction: Error running script for input 0 referencing &lt;hash&gt; at 1: incorrect number of witness items for version 0 witness program of length 20.</code></p>
<p>I'm not really sure how to interpret this error and also unsure of how to go about debugging, so any pointers would be really appreciated.
Searching for these errors on StackExchange doesn't seem to provide any relevant hits except maybe <a href="https://bitcoin.stackexchange.com/questions/85352/witness-program-hash-mismatch-while-signing-bech32-transaction">this</a> answer. Is it possible that incorrect private keys used to sign the transactions could lead to the witness program hash mismatch? (as <a href="https://bitcoin.stackexchange.com/a/85360/127763">suggested by Andrew Chow</a>).</p>
<pre><code>{
    &quot;addresses&quot;: [
        &quot;&lt;addrs&gt;&quot;,
        &quot;&lt;addrs&gt;&quot;,
        &quot;&lt;addrs&gt;&quot;,
        &quot;&lt;addrs&gt;&quot;,
        &quot;&lt;addrs&gt;&quot;
    ],
    &quot;block_height&quot;: -1,
    &quot;block_index&quot;: -1,
    &quot;confirmations&quot;: 0,
    &quot;double_spend&quot;: false,
    &quot;fees&quot;: &lt;amt&gt;,
    &quot;hash&quot;: &quot;d6c6069357ed571c91294d736f44db57a22b1e422ebd6947cc912ef8f498f8ca&quot;,
    &quot;inputs&quot;: [
        {
            &quot;addresses&quot;: [
                &quot;&lt;addrs&gt;&quot;
            ],
            &quot;age&quot;: 00,
            &quot;output_index&quot;: 1,
            &quot;output_value&quot;:&lt;amt&gt;,
            &quot;prev_hash&quot;: &quot;&lt;hash&gt;&quot;,
            &quot;script_type&quot;: &quot;pay-to-witness-pubkey-hash&quot;,
            &quot;sequence&quot;: 4294967295
        },
        {
            &quot;addresses&quot;: [
                &quot;&lt;addrs&gt;&quot;
            ],
            &quot;age&quot;: 00,
            &quot;output_index&quot;: 1,
            &quot;output_value&quot;: &lt;amt&gt;,
            &quot;prev_hash&quot;: &quot;f174bf45da30a7a43360c37fde80955ad3e0b45e6913b0aab1314fdfabe2e0c7&quot;,
            &quot;script_type&quot;: &quot;pay-to-witness-pubkey-hash&quot;,
            &quot;sequence&quot;: 4294967295,
            &quot;witness&quot;: [
                &quot;304402207bb9cffa80ee109758b6c0c74ac2d5745cb42bb06c76b0cf7a86e64cc4159bba0220351f1ae477c5703c2990336a2888a4ff1c52e3d01897931ba3b48fce694797c101&quot;,
                &quot;022b89efbabb2ab7f712912c399ef161216b07d101fa95a3ffbb4ce675548b64e1&quot;
            ]
        }
    ],
    &quot;outputs&quot;: [
        {
            &quot;addresses&quot;: [
                &quot;&lt;addrs&gt;&quot;
            ],
            &quot;script&quot;: &quot;002002349639c02aee43f4474e269bc03860d0290f7f3fc15f0bcea54b2025dffae8&quot;,
            &quot;script_type&quot;: &quot;pay-to-witness-script-hash&quot;,
            &quot;value&quot;: &lt;amt&gt;
        },
        {
            &quot;addresses&quot;: [
                &quot;&lt;addrs&gt;&quot;
            ],
            &quot;script&quot;: &quot;00147bd21f276fa2e6a81a69a1d89c4217876810bf98&quot;,
            &quot;script_type&quot;: &quot;pay-to-witness-pubkey-hash&quot;,
            &quot;value&quot;: &lt;amt&gt;
        },
        {
            &quot;addresses&quot;: [
                &quot;&lt;addrs&gt;&quot;
            ],
            &quot;script&quot;: &quot;00148e0892c30b293a2ae1fa90988cc6004f03eadc1c&quot;,
            &quot;script_type&quot;: &quot;pay-to-witness-pubkey-hash&quot;,
            &quot;value&quot;: &lt;amt&gt;
        }
    ],
    &quot;preference&quot;: &quot;low&quot;,
    &quot;received&quot;: &quot;&lt;datetime&gt;&quot;,
    &quot;relayed_by&quot;: &quot;&lt;ip&gt;&quot;,
    &quot;size&quot;: &lt;size&gt;,
    &quot;total&quot;: &lt;amt&gt;,
    &quot;ver&quot;: 2,
    &quot;vin_sz&quot;: 2,
    &quot;vout_sz&quot;: 3,
    &quot;vsize&quot;: &lt;vsize&gt;
}
</code></pre>

<raw-transaction><discreet-log-contract>
DLC funding transaction error: non-mandatory-script-verify-flag (Witness program hash mismatch) (code 64)
satirn
# DLC funding transaction error: non-mandatory-script-verify-flag (Witness program hash mismatch) (code 64)

(Asked by: username_0 on 2021-10-14)

I'm attempting to construct a funding transaction for a DLC. So far I have created the following transaction which encodes entry of a bet for local/remote collateral of 1000/1000 sats and binary win/lose all or nothing outcome.

As far as I can tell, the transactions are accurate in terms of inputs/outputs addresses etc, and the signatures were provided (see below), but I'm getting this error:

`non-mandatory-script-verify-flag (Witness program hash mismatch) (code 64)`

when attempting to broadcast the transaction.
hex:

```
<txhash>

```

I also attempted broadcasting with another service, which had a more descriptive error so I'll also post this here:

`Error validating transaction: Error running script for input 0 referencing <hash> at 1: incorrect number of witness items for version 0 witness program of length 20.`

I'm not really sure how to interpret this error and also unsure of how to go about debugging, so any pointers would be really appreciated.
Searching for these errors on StackExchange doesn't seem to provide any relevant hits except maybe [this](https://bitcoin.stackexchange.com/questions/85352/witness-program-hash-mismatch-while-signing-bech32-transaction) answer. Is it possible that incorrect private keys used to sign the transactions could lead to the witness program hash mismatch? (as [suggested by Andrew Chow](https://bitcoin.stackexchange.com/a/85360/127763)).

```
{
    "addresses": [
        "<addrs>",
        "<addrs>",
        "<addrs>",
        "<addrs>",
        "<addrs>"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": <amt>,
    "hash": "d6c6069357ed571c91294d736f44db57a22b1e422ebd6947cc912ef8f498f8ca",
    "inputs": [
        {
            "addresses": [
                "<addrs>"
            ],
            "age": 00,
            "output_index": 1,
            "output_value":<amt>,
            "prev_hash": "<hash>",
            "script_type": "pay-to-witness-pubkey-hash",
            "sequence": 4294967295
        },
        {
            "addresses": [
                "<addrs>"
            ],
            "age": 00,
            "output_index": 1,
            "output_value": <amt>,
            "prev_hash": "f174bf45da30a7a43360c37fde80955ad3e0b45e6913b0aab1314fdfabe2e0c7",
            "script_type": "pay-to-witness-pubkey-hash",
            "sequence": 4294967295,
            "witness": [
                "304402207bb9cffa80ee109758b6c0c74ac2d5745cb42bb06c76b0cf7a86e64cc4159bba0220351f1ae477c5703c2990336a2888a4ff1c52e3d01897931ba3b48fce694797c101",
                "022b89efbabb2ab7f712912c399ef161216b07d101fa95a3ffbb4ce675548b64e1"
            ]
        }
    ],
    "outputs": [
        {
            "addresses": [
                "<addrs>"
            ],
            "script": "002002349639c02aee43f4474e269bc03860d0290f7f3fc15f0bcea54b2025dffae8",
            "script_type": "pay-to-witness-script-hash",
            "value": <amt>
        },
        {
            "addresses": [
                "<addrs>"
            ],
            "script": "00147bd21f276fa2e6a81a69a1d89c4217876810bf98",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": <amt>
        },
        {
            "addresses": [
                "<addrs>"
            ],
            "script": "00148e0892c30b293a2ae1fa90988cc6004f03eadc1c",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": <amt>
        }
    ],
    "preference": "low",
    "received": "<datetime>",
    "relayed_by": "<ip>",
    "size": <size>,
    "total": <amt>,
    "ver": 2,
    "vin_sz": 2,
    "vout_sz": 3,
    "vsize": <vsize>
}

```

**Tags:** raw-transaction, discreet-log-contract


---

## 1 answers

### Answer by username_1 on 2021-10-14. Score: 5 | Accepted answer

If you look at input 0, it doesn't contain a `witness` element, this means it isn't signed. You need to sign both inputs to be able to broadcast.

> **Comments:**
> **username_0**: Thanks Ben, had missed that. Appreciate it  

---

