Struggling to successfully broadcast a p2pkh transaction

by cryptodescriptor   Last Updated November 08, 2018 23:27 PM

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:


when I try to broadcast the signed transaction using

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:


Signed tx parsed with my python parser:

Segwit: False
txn version: 1
Flag: 00

Inputs: 1

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

Outputs: 2

Value (satoshis): 20300
pubKeyScript: 76a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac

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?

Related Questions

Bech32 conversion to legacy P2PKH?

Updated November 08, 2017 02:27 AM

Pycoin: How to sign SegWit transaction via Pycoin?

Updated August 17, 2018 09:27 AM