A Simple Guide to Bitcoin


SUBMITTED BY: bitminter

DATE: April 4, 2017, 9:18 p.m.

FORMAT: Text only

SIZE: 2.2 kB

HITS: 625

  1. Here is an extremely simplified sketch of the problem, but it should give a pretty good idea of what the problem is.
  2. The data:
  3. This is the hash of the lastest block (shortened to 30 characters):
  4. 00000000000001adf44c7d69767585
  5. These are the hashes of a few valid transactions waiting for inclusion (shortened).
  6. 5572eca4dd4
  7. db7d0c0b845
  8. And this the hash of one special transaction that you just crafted, which gives 25BTC (the current reward) to yourself:
  9. 916d849af76
  10. Building the next block:
  11. Now, let's use a gross approximation of what a new block might look like (the real one uses binary format). It contains the hash of the previous block and the hashes of those 3 transactions:
  12. 00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--
  13. Now let's do mining by hand! Our goal is to complete this block with a nonce (a piece of garbage) such that the hash of the new block starts with 13 zeros (considering the previous hash, it seems that 13 zeroes is the current difficulty!).
  14. Mining (trying to finalize this block):
  15. Let's try with nonce=1, and compute the hash of the block (I'm using the md5 hash algorithm, but Bitcoin uses double sha256):
  16. > echo "00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--1" | md5sum
  17. 8b9b994dcf57f8f90194d82e234b72ac
  18. No luck, the hash does not start with a 0… Let's try with nonce=2
  19. > echo "00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--2" | md5sum
  20. 5b7ce5bcc07a2822f227fcae7792fd90
  21. No luck…
  22. If we pursue until nonce=16, we get our first leading zero.
  23. > echo "00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--16" | md5sum
  24. 03b80c7a34b060b33dd8fbbece79cee3
  25. For nonce=208, we get two leading zeroes!
  26. > echo "00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--208" | md5sum
  27. 0055e55df5758517c9bed0981b52ce4a
  28. Continue like this… If you finally find a hash that has 13 leading zeroes… you're a winner! Other miners will now build upon your block, you've just got 25BTC.
  29. But you'll have to be fast!
  30. Back to step 1…
  31. If someone manages to build a block before you do, you'll have to start again from the beginning with the new block's hash (the one of the winner).

comments powered by Disqus