0

I am trying to learn how mining is done in bitcoin , wrote a simple mining code in python that works fine on sample data set of raw json coming from https://btc.cryptoid.info/btc/block.dws?693649.htm, but these are all mined blocks .

How to get unconfirmed transactions and make a block and submit the proof of work. I referred to below link but none of the links mentioned in the page are working.

https://en.bitcoin.it/wiki/Getblocktemplate

This is purely for learning purpose, I am not trying to make money out of this mining .

Thanks In Advance.

1 Answer 1

1

How to get unconfirmed transactions [...]

To be notified of new unconfirmed transactions, to retrieve them and to make other nodes aware of blocks you have mined you will need to implement the Bitcoin peer to peer protocols as described at https://developer.bitcoin.org/reference/p2p_networking.html

[...] and make a block [...]

You say you already have written code that does this.

[...] and submit the proof of work

The proof of work is in the block header you produced, it's the hash you produced that is lower than the current network target.

You "submit" the block by using the Bitcoin peer to peer protocol to make peers aware that you have new block data they can retrieve. Essentially you send an inv message that lists your new block. Any interested peer can then send your node a request for that block.

If you are mining in a pool, you instead implement whichever network protocols are used by your chosen pool. For example stratum V2

Since you are doing this for learning purposes you should not do any of this on mainnet, but should probably do all this on the network designated for testing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.