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
}