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:


Can anyone suggest what is happening here??

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

Thank you.


A standard P2PKH requires the following script in scriptPubKey ref:


Your scriptPubkey is currently short and malformed.


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.

| improve this answer | |

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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