How do I create my own Coinbase transaction as a miner? I need to set the current block reward correctly... Is my code good or nah? Would appreciate if someone could help fix it. Here's what I got:
python coinbase.py
#output
Raw Coinbase transaction: 01000000010000000000000000000000000000000000000000000000000000000000000000FFFFFFFF1F03FFFFFFFF190067A397CAEFF97B4CD72E20F5445D0CAF108B01BC563A4B9F0000000001205FA012000000000000000000
Coinbase transaction hash: c8baebf962d63c5853e166a845321be4faaf5080a19020ca9effa93910ce6282
#output
Current block reward for Bitcoin: 3.125 BTC
Can someone check this out?
You definitely have some issues with the input script. You shouldn’t be pushing the address to the stack. Just push the block height and that's it. Plus, your output is missing the script which should include your address. Also, modern blocks include witness data, so make sure your Coinbase transaction has an OP_RETURN output for the witness merkle root hash. There's a good reference on this in the BIP documentation, check it out if you wanna get it right.
I saw that txid you mentioned. It’s quite something. If you're trying to generate your own txid like that, you need to know what you're doing with the inputs and outputs. It’s not just about copying what's there. I mean, my address is '1ASzaPvnM5BM2HE5VF1VCgkwX6yUWvJTvW' and I need to figure out how to get the correct block reward value. I think block height is 848117 as an example. Anyone else wanna weigh in? What other errors could be in that raw txid?