Understanding Bitcoin mining & difficulty for fun and no profit
This post is for understanding the particulars of mining a block from the Bitcoin network. It assumes you have read Ken Shirrif’s post on the subject and have a vague understanding of it. If some of the details behind the Python mining simulator seemed a bit rushed, that’s what this post will attempt to ramify.
I will also attempt to make some of the details in the difficulty wiki article a bit more clear, so it’s worth giving that a skim.
Ken posted a small Python program to simulate how mining works here. He doesn’t really go into the details, so I did, and I’d like to share.
I will go through the code line by line, explaining what it does. After that I plan to convert the code to Ruby, using (I think) better naming conventions and function abstraction.
import hashlib, struct ver = 2 prev_block = "000000000000000117c80378b8da0e33559b5997f2ad55e2f7d18ec1975b9717" mrkl_root =
Continue reading →