<blockquote>
<p>Code: -26, Error: non-mandatory-script-verify-flag (Witness requires empty scriptSig)</p>
</blockquote>
<p><code>bitcoin-cli</code> is telling you that, in order for a SegWit transaction to be valid, the <code>scripSig</code> field must be empty (the data is placed in the witness instead). Assuming your witness is right, you should see something like this when decoding the raw transaction:</p>
<pre><code>&quot;vin&quot;: [
  {
    &quot;txid&quot;: &quot;0af3df27cec1a0b41bd5fdf1a3078155e57df5458ac5f1cabe56bce6cf2b1c70&quot;,
    &quot;vout&quot;: 9,
    &quot;scriptSig&quot;: {
      &quot;asm&quot;: &quot;&quot;,
      &quot;hex&quot;: &quot;&quot;
    },
    &quot;txinwitness&quot;: [
      &quot;3044022012e3cee7d952acf046e3e282162d1cb4e6ff954a01b19fba8d3606b63256c9eb022079099799cb58d3b45ca85c678336c802889fe7d6c18012c5a1509d1b5444149201&quot;,
      &quot;03220927928080eecf1af164e3413ed6733cfc27172174683aecb3bd2041d06a00&quot;
    ],
    &quot;sequence&quot;: 4294967295
}
]
</code></pre>
<p>However, yours does have data in the <code>scriptSig</code>:</p>
<pre><code>&quot;scriptSig&quot;: {
      &quot;asm&quot;: &quot;0014e38512a037ee9199b5dd5e7af4b928453b523cc2&quot;,
      &quot;hex&quot;: &quot;160014e38512a037ee9199b5dd5e7af4b928453b523cc2&quot;
}
</code></pre>
<blockquote>
<p>Anyhow I'm pretty sure I'm just not passing the right parameter to the library but idk wich</p>
</blockquote>
<p>I'm not familiar with NBitcoin, but I'm pretty sure you're right in assuming you may be passing a wrong parameter to your transaction constructor.</p>

CC BY-SA 4.0
2023-05-17T23:01:29.890Z
Thank, it you make sense.
Actually I find out was just using a wrong Private Key to sign the transaction... And the library was building this weird input script/witness because the PK did not match the UTXO unlocking script.
Maxime CATY
CC BY-SA 4.0
2023-05-17T13:41:40.293Z
2023-05-17T13:41:40.293Z
sr_gi
<p>I'm developping Bitcoin integration for Microsoft Dynamics Business Central to offer enterprise capability to apply Bitcoin receivable and payable to accounting.</p>
<p>To send a transaction, I'm using NBitcoin C# lib to prepare and sign raw transaction data before broadcasting but I keep having bellow error on Main Net.</p>
<p>It is the most basic transaction with one input and one output.
Both addresses are P2SH.
The transaction signature verification pass correctly in NBitcoin but the node keep returning the error &quot;Code: -26, Error: non-mandatory-script-verify-flag (Witness requires empty scriptSig)&quot;.</p>
<p>Raw Transaction Data :
<code>01000000000101701c2bcfe6bc56becaf1c58a45f57de5558107a3f1fdd51bb4a0c1ce27dff30a0900000017160014e38512a037ee9199b5dd5e7af4b928453b523cc2ffffffff01701101000000000016001425ce1fbd74537b45319cb0553deec89f4289430102473044022012e3cee7d952acf046e3e282162d1cb4e6ff954a01b19fba8d3606b63256c9eb022079099799cb58d3b45ca85c678336c802889fe7d6c18012c5a1509d1b54441492012103220927928080eecf1af164e3413ed6733cfc27172174683aecb3bd2041d06a0000000000</code></p>
<p>When I decode the transaction I see the witness on input correctly and the output adress look fine too.</p>
<p>If I try to send the same transaction but using P2WPKH address I'm having a different error : 'non-mandatory-script-verify-flag (Script failed an OP_EQUALVERIFY operation)&quot;'</p>
<p>Could someone know whats wrong in my transaction ? Anyhow I'm pretty sure I'm just not passing the right parameter to the library but idk wich</p>

<signature><raw-transaction><p2sh><nbitcoin><p2sh-p2wpkh>
Transaction keep beeing rejected "non-mandatory-script-verify-flag"
Maxime CATY
# Transaction keep beeing rejected "non-mandatory-script-verify-flag"

(Asked by: username_0 on 2023-05-16)

I'm developping Bitcoin integration for Microsoft Dynamics Business Central to offer enterprise capability to apply Bitcoin receivable and payable to accounting.

To send a transaction, I'm using NBitcoin C# lib to prepare and sign raw transaction data before broadcasting but I keep having bellow error on Main Net.

It is the most basic transaction with one input and one output.
Both addresses are P2SH.
The transaction signature verification pass correctly in NBitcoin but the node keep returning the error "Code: -26, Error: non-mandatory-script-verify-flag (Witness requires empty scriptSig)".

Raw Transaction Data :
`01000000000101701c2bcfe6bc56becaf1c58a45f57de5558107a3f1fdd51bb4a0c1ce27dff30a0900000017160014e38512a037ee9199b5dd5e7af4b928453b523cc2ffffffff01701101000000000016001425ce1fbd74537b45319cb0553deec89f4289430102473044022012e3cee7d952acf046e3e282162d1cb4e6ff954a01b19fba8d3606b63256c9eb022079099799cb58d3b45ca85c678336c802889fe7d6c18012c5a1509d1b54441492012103220927928080eecf1af164e3413ed6733cfc27172174683aecb3bd2041d06a0000000000`

When I decode the transaction I see the witness on input correctly and the output adress look fine too.

If I try to send the same transaction but using P2WPKH address I'm having a different error : 'non-mandatory-script-verify-flag (Script failed an OP\_EQUALVERIFY operation)"'

Could someone know whats wrong in my transaction ? Anyhow I'm pretty sure I'm just not passing the right parameter to the library but idk wich

**Tags:** signature, raw-transaction, p2sh, nbitcoin, p2sh-p2wpkh


---

## 1 answers

### Answer by username_1 on 2023-05-17. Score: 2 | Accepted answer

> Code: -26, Error: non-mandatory-script-verify-flag (Witness requires empty scriptSig)

`bitcoin-cli` is telling you that, in order for a SegWit transaction to be valid, the `scripSig` field must be empty (the data is placed in the witness instead). Assuming your witness is right, you should see something like this when decoding the raw transaction:

```
"vin": [
  {
    "txid": "0af3df27cec1a0b41bd5fdf1a3078155e57df5458ac5f1cabe56bce6cf2b1c70",
    "vout": 9,
    "scriptSig": {
      "asm": "",
      "hex": ""
    },
    "txinwitness": [
      "3044022012e3cee7d952acf046e3e282162d1cb4e6ff954a01b19fba8d3606b63256c9eb022079099799cb58d3b45ca85c678336c802889fe7d6c18012c5a1509d1b5444149201",
      "03220927928080eecf1af164e3413ed6733cfc27172174683aecb3bd2041d06a00"
    ],
    "sequence": 4294967295
}
]

```

However, yours does have data in the `scriptSig`:

```
"scriptSig": {
      "asm": "0014e38512a037ee9199b5dd5e7af4b928453b523cc2",
      "hex": "160014e38512a037ee9199b5dd5e7af4b928453b523cc2"
}

```

> Anyhow I'm pretty sure I'm just not passing the right parameter to the library but idk wich

I'm not familiar with NBitcoin, but I'm pretty sure you're right in assuming you may be passing a wrong parameter to your transaction constructor.

> **Comments:**
> **username_0**: Thank, it you make sense. Actually I find out was just using a wrong Private Key to sign the transaction... And the library was building this weird input script/witness because the PK did not match the UTXO unlocking script.  

---

