<p><a href="https://www.blocktrail.com/tBTC/tx/ba1da008a017aef58fe929cc4afeb52cf77110fff5721aa9487ffb4d6f35152f" rel="nofollow noreferrer">What you're spending</a> is a P2SH output. To spend those, the last element of the ScriptSig must be the script (encoded with a push opcode, not the script itself) that produces that P2SH address when hashed.</p>

<p>See <a href="https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki#specification" rel="nofollow noreferrer">BIP16</a>, especially rule #1.</p>

<blockquote>
  <p>Validation fails if there are any operations other than "push data" operations in the scriptSig</p>
</blockquote>

CC BY-SA 4.0
2018-08-29T13:29:12.090Z
trying to follow: the redeemscript is the last PUSHDATA structure (246d6d2202ad...), which is shown as last item in OP's raw transaction in the "asm" value of the "vin".
This hex value would be sha256'd and ripemd160'd. This should be the equivalent of the hash, that we see in the funding transaction as TX_Out[0] ("141a75cd53e9..." as part of the OP_Hash160 <hash> OP_Equal)?
(when I try to follow this logic, I get different hashes. Maybe the provided redeemscript is incorrect?)
pebwindkraft
CC BY-SA 4.0
2018-08-28T14:09:45.087Z
2018-08-28T14:09:45.087Z
MCCCS
<p>I'm trying to send transaction with scriptSig: <code>OP_PUSHDATA&lt;Sig&gt; OP_PUSHDATA&lt;Data1&gt; OP_PUSHDATA&lt;Data2&gt; OP_PUSHDATA&lt;Data3&gt; OP_PUSHDATA&lt;RedeemScript&gt;</code></p>

<p>But I get error: </p>

<blockquote>
  <p>mandatory-script-verify-flag-failed (Signature is found in scriptCode)</p>
</blockquote>

<p>Why am I getting this error? What is wrong?</p>

<p>Raw transaction:</p>

<pre><code>020000000001012f15356f4dfb7f48a91a72f5ff1071f72cb5fe4acc29e98ff5ae17a008a01dba000000007C160014ac09dd336a6fc10034fc44dcb706855668921ce7141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a246d6d2202ada9884dbd1e8bd90968ba66246f017cd77d83595027f7929ae3537f98c92d4aacffffffff01c005d9010000000017a914738292fc46dd7af803bd56035d0988af96a3168187024830450221009108d4e65a34fb50cd3283b6386a679f0dfc2b5fe97e3b3c3f6b8320814b3a2902204631daf2bb93605c9e079750092f304966b69fe28ce7701f4bc677714bca23af012102ada9884dbd1e8bd90968ba66256f017cd77d83595027f7929ae3537f98c92d4a00000000

{
  "result": {
    "txid": "441cf52028ee0acc8b4076681c7fd46dad03501be62c6b0050ca59090fa52973",
    "hash": "dad2b4c56556b74d87243149ca3384ce04584d3bd8d21d80e291c4f9eed7e3f8",
    "version": 2,
    "size": 317,
    "vsize": 235,
    "locktime": 0,
    "vin": [
      {
        "txid": "ba1da008a017aef58fe929cc4afeb52cf77110fff5721aa9487ffb4d6f35152f",
        "vout": 0,
        "scriptSig": {
          "asm": "0014ac09dd336a6fc10034fc44dcb706855668921ce7 1f8b0800ffc1765400038d78055c545df3ff5d4a 1f8b0800ffc1765400038d78055c545df3ff5d4a 1f8b0800ffc1765400038d78055c545df3ff5d4a 6d6d2202ada9884dbd1e8bd90968ba66246f017cd77d83595027f7929ae3537f98c92d4a OP_CHECKSIG",
          "hex": "160014ac09dd336a6fc10034fc44dcb706855668921ce7141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a246d6d2202ada9884dbd1e8bd90968ba66246f017cd77d83595027f7929ae3537f98c92d4aac"
        },
        "txinwitness": [
          "30450221009108d4e65a34fb50cd3283b6386a679f0dfc2b5fe97e3b3c3f6b8320814b3a2902204631daf2bb93605c9e079750092f304966b69fe28ce7701f4bc677714bca23af01",
          "02ada9884dbd1e8bd90968ba66256f017cd77d83595027f7929ae3537f98c92d4a"
        ],
        "sequence": 4294967295
      }
    ],
    "vout": [
      {
        "value": 0.31,
        "n": 0,
        "scriptPubKey": {
          "asm": "OP_HASH160 738292fc46dd7af803bd56035d0988af96a31681 OP_EQUAL",
          "hex": "a914738292fc46dd7af803bd56035d0988af96a3168187",
          "reqSigs": 1,
          "type": "scripthash",
          "addresses": [
            "2N3mz7o8v3YT4arXdQ5p8So6q3FUGjhUpEE"
          ]
        }
      }
    ]
  },
  "error": null,
  "id": "curltext"
}
</code></pre>

<transactions><raw-transaction><p2sh>
Error when sending transaction: "Signature is found in scriptCode"
Andr1i
# Error when sending transaction: "Signature is found in scriptCode"

(Asked by: username_0 on 2018-08-28)

I'm trying to send transaction with scriptSig: `OP_PUSHDATA<Sig> OP_PUSHDATA<Data1> OP_PUSHDATA<Data2> OP_PUSHDATA<Data3> OP_PUSHDATA<RedeemScript>`

But I get error:

> mandatory-script-verify-flag-failed (Signature is found in scriptCode)

Why am I getting this error? What is wrong?

Raw transaction:

```
020000000001012f15356f4dfb7f48a91a72f5ff1071f72cb5fe4acc29e98ff5ae17a008a01dba000000007C160014ac09dd336a6fc10034fc44dcb706855668921ce7141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a246d6d2202ada9884dbd1e8bd90968ba66246f017cd77d83595027f7929ae3537f98c92d4aacffffffff01c005d9010000000017a914738292fc46dd7af803bd56035d0988af96a3168187024830450221009108d4e65a34fb50cd3283b6386a679f0dfc2b5fe97e3b3c3f6b8320814b3a2902204631daf2bb93605c9e079750092f304966b69fe28ce7701f4bc677714bca23af012102ada9884dbd1e8bd90968ba66256f017cd77d83595027f7929ae3537f98c92d4a00000000

{
  "result": {
    "txid": "441cf52028ee0acc8b4076681c7fd46dad03501be62c6b0050ca59090fa52973",
    "hash": "dad2b4c56556b74d87243149ca3384ce04584d3bd8d21d80e291c4f9eed7e3f8",
    "version": 2,
    "size": 317,
    "vsize": 235,
    "locktime": 0,
    "vin": [
      {
        "txid": "ba1da008a017aef58fe929cc4afeb52cf77110fff5721aa9487ffb4d6f35152f",
        "vout": 0,
        "scriptSig": {
          "asm": "0014ac09dd336a6fc10034fc44dcb706855668921ce7 1f8b0800ffc1765400038d78055c545df3ff5d4a 1f8b0800ffc1765400038d78055c545df3ff5d4a 1f8b0800ffc1765400038d78055c545df3ff5d4a 6d6d2202ada9884dbd1e8bd90968ba66246f017cd77d83595027f7929ae3537f98c92d4a OP_CHECKSIG",
          "hex": "160014ac09dd336a6fc10034fc44dcb706855668921ce7141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a246d6d2202ada9884dbd1e8bd90968ba66246f017cd77d83595027f7929ae3537f98c92d4aac"
        },
        "txinwitness": [
          "30450221009108d4e65a34fb50cd3283b6386a679f0dfc2b5fe97e3b3c3f6b8320814b3a2902204631daf2bb93605c9e079750092f304966b69fe28ce7701f4bc677714bca23af01",
          "02ada9884dbd1e8bd90968ba66256f017cd77d83595027f7929ae3537f98c92d4a"
        ],
        "sequence": 4294967295
      }
    ],
    "vout": [
      {
        "value": 0.31,
        "n": 0,
        "scriptPubKey": {
          "asm": "OP_HASH160 738292fc46dd7af803bd56035d0988af96a31681 OP_EQUAL",
          "hex": "a914738292fc46dd7af803bd56035d0988af96a3168187",
          "reqSigs": 1,
          "type": "scripthash",
          "addresses": [
            "2N3mz7o8v3YT4arXdQ5p8So6q3FUGjhUpEE"
          ]
        }
      }
    ]
  },
  "error": null,
  "id": "curltext"
}

```

**Tags:** transactions, raw-transaction, p2sh


---

## 1 answers

### Answer by username_1 on 2018-08-28. Score: 0 | Accepted answer

[What you're spending](https://www.blocktrail.com/tBTC/tx/ba1da008a017aef58fe929cc4afeb52cf77110fff5721aa9487ffb4d6f35152f) is a P2SH output. To spend those, the last element of the ScriptSig must be the script (encoded with a push opcode, not the script itself) that produces that P2SH address when hashed.

See [BIP16](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki#specification), especially rule #1.

> Validation fails if there are any operations other than "push data" operations in the scriptSig

> **Comments:**
> **username_2**: trying to follow: the redeemscript is the last PUSHDATA structure (246d6d2202ad...), which is shown as last item in OP's raw transaction in the "asm" value of the "vin". This hex value would be sha256'd and ripemd160'd. This should be the equivalent of the hash, that we see in the funding transaction as TX_Out[0] ("141a75cd53e9..." as part of the OP_Hash160 <hash> OP_Equal)? (when I try to follow this logic, I get different hashes. Maybe the provided redeemscript is incorrect?)  

---

