Creating a custom transactions I am currently learning how to create raw transactions. I can already create standard using bitcoin core (0.19.1), but when I wanted to create with custom opcode like this:

asm: OP_HASH160 d0c3f50336b5f109207d722c692191ff86263e96 OP_EQUAL OP_DROP 1
hex: a914d0c3f50336b5f109207d722c692191ff86263e96877551



I created raw transaction


createrawtransaction '[{"txid":"1c164f99a7cd0fe6dba9a7fe10ad3c2be132a9260d4ccdeaf7e279073946ac52","vout":0}]' '{"2MxmdfXx8rKGUmWUwQu59GksMNRdnQiRRM2":0.195}'

020000000152ac46390779e2f7eacd4c0d26a932e12b3cad10fea7a9dbe60fcda7994f161c0000000000ffffffff01e08b29010000000017a9143c98df42d7a69c7fd165aeb6128d45f21eeeac4d8700000000



But when I wanted to sign this transaction I occured an error (I also tried to modify raw transaction from first step) here is result with modified raw transaction from above but it still doesn't work


signrawtransactionwithkey '020000000152ac46390779e2f7eacd4c0d26a932e12b3cad10fea7a9dbe60fcda7994f161c0000000000ffffffff0130c11d000000000019a914d0c3f50336b5f109207d722c692191ff86263e9687755100000000' '["$privkey"]' '[{"txid":"1c164f99a7cd0fe6dba9a7fe10ad3c2be132a9260d4ccdeaf7e279073946ac52","vout":0,"scriptPubKey":"a914d0c3f50336b5f109207d722c692191ff86263e96877551","redeemScript":"001453352afbbaa8cad22304201de8fbcc29e83fb2db","amount":0.02}]'

Previous output scriptPubKey mismatch:
OP_HASH160 d0c3f50336b5f109207d722c692191ff86263e96 OP_EQUAL
vs:
OP_HASH160 d0c3f50336b5f109207d722c692191ff86263e96 OP_EQUAL OP_DROP 1 (code -22)



Now I know I'm doing something wrong, but I don't know what and I can't find any information on how to do it correctly. That's why I have questions:


What am I doing wrong?
Can I create custom transactions using the Bitcoin core, if so how?
If I can't use this wallet, how can I do it? I would be grateful for an example
In your script the previous ScriptPubKey is different.
If you want create custom script you need to sign manually the transaction, you can't use signrawtransactionwithkey. Bitcoin core sign only the standard transaction