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

1 Answer 1


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": [
    "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.

  • 1
    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. May 17 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.