<p>A standard P2PKH requires the following script in scriptPubKey <a href="https://en.bitcoin.it/wiki/Script#Standard_Transaction_to_Bitcoin_address_.28pay-to-pubkey-hash.29" rel="nofollow noreferrer">ref</a>:</p>

<pre><code>OP_DUP OP_HASH160 &lt;pubKeyHash&gt; OP_EQUALVERIFY OP_CHECKSIG
</code></pre>

<p>Your scriptPubkey is currently short and malformed.</p>

<blockquote>
  <p>a91450628702abb40cc5fee219b9c834f4126c41988487</p>
</blockquote>

<p>Should be something like this:</p>

<pre><code>76 a9 14 50628702abb40cc5fee219b9c834f4126c419884 88 ac
</code></pre>

<p>(Assuming the address you are trying to pay to is <code>18L369eeqGbPECD2C62nvP7BbvRazwdsQt</code>. Also don't forget to change the variable integer indicating size of this script (the byte before this which is currently <code>0x17</code> but should be <code>0x19</code>.</p>

CC BY-SA 4.0
2018-09-24T12:53:48.497Z
2018-09-24T12:53:48.497Z
Coding Enthusiast
<p>Even though this question is a bit old by now, it might be useful to add a couple of things for future readers who might encounter the same <code>Signature is found in scriptCode</code> error.</p>

<p>First, the error appears when the policy change introduced in commit <code>9dabfe49c0</code> is triggered.  Specifically, the error will fire when <code>FindAndDelete()</code> detects the signature being passed to a <code>CHECK(MULTI)SIG(VERIFY)</code> operation to exist in the <code>scriptCode</code> itself.
This will never (actually, with neglible probability) happen when a simple <code>p2pkh</code> script is being redeemed.</p>

<p>Secondly, the spending transaction and signature in the original question is in fact valid :</p>

<pre><code>printf '%s\n' 01000000018df8ae6050992976497b63349c281bd05666842a6a82d6d8b26dc51812d58201000000006B483045022100c4befe583a3bc22eeaf1516c6d26fb3e1240bdfdf25db266494d82c77ccb36100220108ad79c4a34115eec23f5b0202d492dd88ec637df17a1982d4a63382e457599012102a018e21c743a4b67dcf38f9b693e807b1fbb833dfe705aa513abbf177b04adc2ffffffff01c0a6b9290100000017a91450628702abb40cc5fee219b9c834f4126c4198848700000000 '[{"txid":"0182D51218C56DB2D8D6826A2A846656D01B289C34637B497629995060AEF88D","vout":0,"scriptPubKey":"76A914E08E0B7AF54A0A5B4CA39ECC5430AB2730ECC2A188AC"}]' | regtest-cli -stdin signrawtransactionwithwallet 
{
  "hex": "01000000018df8ae6050992976497b63349c281bd05666842a6a82d6d8b26dc51812d58201000000006b483045022100c4befe583a3bc22eeaf1516c6d26fb3e1240bdfdf25db266494d82c77ccb36100220108ad79c4a34115eec23f5b0202d492dd88ec637df17a1982d4a63382e457599012102a018e21c743a4b67dcf38f9b693e807b1fbb833dfe705aa513abbf177b04adc2ffffffff01c0a6b9290100000017a91450628702abb40cc5fee219b9c834f4126c4198848700000000",
  "complete": true
}
</code></pre>

CC BY-SA 4.0
2018-12-29T07:03:38.020Z
2018-12-29T07:13:46.903Z
2018-12-29T07:13:46.903Z
arubi
<p>I am building a simple p2pkh transaction using libbitcoin. Trying to pass it through my regtest node. I am getting the following error message.</p>

<pre><code>error code: -26
error message:
16: mandatory-script-verify-flag-failed (Signature is found in scriptCode)
</code></pre>

<p>my transaction hash is as below:</p>

<pre><code>01000000018df8ae6050992976497b63349c281bd05666842a6a82d6d8b26dc51812d58201000000006b483045022100c4befe583a3bc22eeaf1516c6d26fb3e1240bdfdf25db266494d82c77ccb36100220108ad79c4a34115eec23f5b0202d492dd88ec637df17a1982d4a63382e457599012102a018e21c743a4b67dcf38f9b693e807b1fbb833dfe705aa513abbf177b04adc2ffffffff01c0a6b9290100000017a91450628702abb40cc5fee219b9c834f4126c4198848700000000
</code></pre>

<p>Can anyone suggest what is happening here?? </p>

<p>Please let me know if more information is required to understand the problem. </p>

<p>Thank you.</p>

<transactions><error><libbitcoin>
error code: -26 error message: 16: mandatory-script-verify-flag-failed (Signature is found in scriptCode)
Rajarshi Maitra
# error code: -26 error message: 16: mandatory-script-verify-flag-failed (Signature is found in scriptCode)

(Asked by: username_0 on 2018-09-23)

I am building a simple p2pkh transaction using libbitcoin. Trying to pass it through my regtest node. I am getting the following error message.

```
error code: -26
error message:
16: mandatory-script-verify-flag-failed (Signature is found in scriptCode)

```

my transaction hash is as below:

```
01000000018df8ae6050992976497b63349c281bd05666842a6a82d6d8b26dc51812d58201000000006b483045022100c4befe583a3bc22eeaf1516c6d26fb3e1240bdfdf25db266494d82c77ccb36100220108ad79c4a34115eec23f5b0202d492dd88ec637df17a1982d4a63382e457599012102a018e21c743a4b67dcf38f9b693e807b1fbb833dfe705aa513abbf177b04adc2ffffffff01c0a6b9290100000017a91450628702abb40cc5fee219b9c834f4126c4198848700000000

```

Can anyone suggest what is happening here??

Please let me know if more information is required to understand the problem.

Thank you.

**Tags:** transactions, error, libbitcoin


---

## 2 answers

### Answer by username_1 on 2018-09-24. Score: 1 | Accepted answer

A standard P2PKH requires the following script in scriptPubKey [ref](https://en.bitcoin.it/wiki/Script#Standard_Transaction_to_Bitcoin_address_.28pay-to-pubkey-hash.29):

```
OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

```

Your scriptPubkey is currently short and malformed.

> a91450628702abb40cc5fee219b9c834f4126c41988487

Should be something like this:

```
76 a9 14 50628702abb40cc5fee219b9c834f4126c419884 88 ac

```

(Assuming the address you are trying to pay to is `18L369eeqGbPECD2C62nvP7BbvRazwdsQt`. Also don't forget to change the variable integer indicating size of this script (the byte before this which is currently `0x17` but should be `0x19`.


---

### Answer by username_2 on 2018-12-29. Score: 2

Even though this question is a bit old by now, it might be useful to add a couple of things for future readers who might encounter the same `Signature is found in scriptCode` error.

First, the error appears when the policy change introduced in commit `9dabfe49c0` is triggered. Specifically, the error will fire when `FindAndDelete()` detects the signature being passed to a `CHECK(MULTI)SIG(VERIFY)` operation to exist in the `scriptCode` itself.
This will never (actually, with neglible probability) happen when a simple `p2pkh` script is being redeemed.

Secondly, the spending transaction and signature in the original question is in fact valid :

```
printf '%s\n' 01000000018df8ae6050992976497b63349c281bd05666842a6a82d6d8b26dc51812d58201000000006B483045022100c4befe583a3bc22eeaf1516c6d26fb3e1240bdfdf25db266494d82c77ccb36100220108ad79c4a34115eec23f5b0202d492dd88ec637df17a1982d4a63382e457599012102a018e21c743a4b67dcf38f9b693e807b1fbb833dfe705aa513abbf177b04adc2ffffffff01c0a6b9290100000017a91450628702abb40cc5fee219b9c834f4126c4198848700000000 '[{"txid":"0182D51218C56DB2D8D6826A2A846656D01B289C34637B497629995060AEF88D","vout":0,"scriptPubKey":"76A914E08E0B7AF54A0A5B4CA39ECC5430AB2730ECC2A188AC"}]' | regtest-cli -stdin signrawtransactionwithwallet 
{
  "hex": "01000000018df8ae6050992976497b63349c281bd05666842a6a82d6d8b26dc51812d58201000000006b483045022100c4befe583a3bc22eeaf1516c6d26fb3e1240bdfdf25db266494d82c77ccb36100220108ad79c4a34115eec23f5b0202d492dd88ec637df17a1982d4a63382e457599012102a018e21c743a4b67dcf38f9b693e807b1fbb833dfe705aa513abbf177b04adc2ffffffff01c0a6b9290100000017a91450628702abb40cc5fee219b9c834f4126c4198848700000000",
  "complete": true
}

```


---

