Struggling to successfully broadcast a p2pkh transaction I've been experimenting with sending bitcoin transactions with python for the past week. I successfully was able to send p2wpkh->ALL address types, p2sh-p2wpkh->ALL address types.

What I am struggling with is sending a legacy p2pkh transaction. I keep getting:

SIGNATURE MUST BE ZERO FOR FAILED CHECK(MULTI)SIG OPERATION

when I try to broadcast the signed transaction using https://testnet.smartbit.com.au/txs/pushtx

It seems to me like it is a signature error. But I can't understand why I am able to generate good signatures for other payment types but then bad signatures for p2pkh.

My rawtx:


  01000000 01 4f8fe5092e16ad3da3327c36a6c5209c9aede34fc68615cfdf3049945e91ca61 00000000 00 ffffffff 02 4c4f000000000000 1976a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac 546f4b0000000000 1976a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac 00000000


My signed TX:


  01000000014f8fe5092e16ad3da3327c36a6c5209c9aede34fc68615cfdf3049945e91ca61000000006a47304402205881bb01ff20100233d6c1284eb6fe1857fb25a8cee52f5fe48ef8bbf61e42fe02201b00187031f299283b60b214d801c5ca0db8342a8e68c8020caf96e9a064b471012102a7b51771f972f4d2de85129886415af3e13efe943c12f149ab7c43c318f45ae9ffffffff024c4f0000000000001976a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac546f4b00000000001976a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac00000000


Signed tx parsed with my python parser:

Segwit: False
txn version: 1
Flag: 00

------------------------------------------------------------
Inputs: 1
------------------------------------------------------------

(1)
Previous txn hash: 61ca915e944930dfcf1586c64fe3ed9a9c20c5a6367c32a33dad162e09e58f4f
Index: 0
sigScript: 47304402205881bb01ff20100233d6c1284eb6fe1857fb25a8cee52f5fe48ef8bbf61e42fe02201b00187031f299283b60b214d801c5ca0db8342a8e68c8020caf96e9a064b471012102a7b51771f972f4d2de85129886415af3e13efe943c12f149ab7c43c318f45ae9
Sequence: ffffffff

------------------------------------------------------------
Outputs: 2
------------------------------------------------------------

(1)
Value (satoshis): 20300
pubKeyScript: 76a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac

(2)
Value (satoshis): 4943700
pubKeyScript: 76a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac

--------------------

Locktime: 0


Can I use compressed public keys in normal p2pkh transactions or does it have to be normal uncompressed?

In my script I build the preImage the same way as my other segwit inputs/outputs but obviously I dont use flag, marker witness fields. I also followed another post on here attempting to only sign a single input and I got other errors different from the one at the top of this post.

How does the segwit signing process differ from legacy?
Nevermind.

I combined the two answers from these posts and managed to get something working:

Redeeming a raw transaction step by step example required

https://bitcoin.stackexchange.com/a/41226/89247

Yes. You can use compressed public keys with p2pkh. There are no restrictions.