jimmysong / programmingbitcoin

Repository for the book
Other
1.75k stars 656 forks source link

Answer wrong for chapter 9 exercise 12 #165

Open jrawsthorne opened 5 years ago

jrawsthorne commented 5 years ago

A mistake in the code leads to an incorrect answer for the exercise. The first block is used as the last block and the last block is used as the first. This results in a negative time differential thus is caught by the < TWO_WEEKS // 4 statement. This means that what is actually calculated is the minimum difficulty adjustment from block 471744 rather than the correct difficulty adjustment from block 473759. The correct answer should be 308d0118 which can be seen on a block explorer e.g. https://blockstream.info/block/000000000000000000802ba879f1b7a638dcea6ff0ceb614d91afc8683ac0502