How to generate coinbase transaction in Python?
How to generate coinbase transaction in Python?
Loading saved threads...
Alex Radik · External communityPost link
External question — Bitcoin Stack Exchange
Author: Alex Radik
Original post: https://bitcoin.stackexchange.com/questions/122815
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I know that on this forum a lot of questions on this topic, I have checked most of these, but can't find the solution for my task. I am creating my own algorithm for solo mining bitcoin on Python. I wrote all necessary methods for that, including hashing the Merkle root, calculating the block header etc. But now, I am stuck for a few weeks on the coinbase transaction. I have studied the
coinbase transaction page on LearnMeABitcoin.com
and tried to implement all logic for it, but can't fully understand how to make one. I want to include new rules (BIP34 - block header, BIP141 - SegWit tx) in this algorithm, but my knowledge about hashing this is not enough. :(
Can someone provide maybe more materials, some samples of code, or describe details about generating a coinbase transaction? Any information will be very helpful, hope on your help.
Also, I am training on Bitcoin core in regtest mode, and when I use "generatetoaddress" method (for generate blocks) this one doesn't gen coinbase tx with BIP34 & BIP141 requirements, maybe I need set more config for this one? I found someone say about blockversion arg, is it true?
Thank you all ^^
P.S. If i miss some details about my task, fell free to ask and I provide all info which I have, of sample of code which I have (it's not working)
UPDATE
I have greate news, I find the solution and complete this) thanks all for yout support, some later I share my code for gen coinbaseTx in python.
But left only one question, i use object for generate tx like on screen, and it have some difference with coinbase tx from generataing by Bitcoin Core using generatetoaddress only in one place, filed n in first output, and it always "00000000", like 0 in little-endian with 4 bytes I hope. Can someone explain what it is? I use p2wpkh script for hashing address, maybe this one is type for this? When I add this value all worked fine, and I successfully gen CoinbaseTx, after build block header and full block and broadcast it to node. But just for fully understanding my code, wanna to know what this "00000000" mean) Name "n" for field was by me, just temporary name.
Quote
Report
Lee · External communityPost link
External answer — Bitcoin Stack Exchange
Author: Lee
Original post: https://bitcoin.stackexchange.com/a/122825
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
How to generate coinbase transaction in Python?
Pycoin
might be worth looking at. It has a transaction class with a
coinbase_tx function
.
There also appears to be a
python based test framework in the Bitcoin Core repo
.
Can someone provide maybe more materials, some samples of code, or
describe details about generating a coinbase transaction?
Pycoin
Bitcoin Core test framework
bit
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Bitcoin Stack Exchange Author: Lee Source score (net votes, not local likes): 0 Original post: https://bitcoin.stackexchange.com/a/122825 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. How to generate coinbase transaction in Python? Pycoin might be worth looking at. It has a transaction class with a coinbase_tx function . There also appears to be a python based test framework in the Bitcoin Core repo . Can someone provide maybe more materials, some samples of code, or describe details about generating a coinbase transaction? Pycoin Bitcoin Core test framework bit
Checking account access…