Last active
September 14, 2022 20:26
-
-
Save mutatrum/98c60073c76fb4f742ed007ea6f941af to your computer and use it in GitHub Desktop.
Print all historical difficulty adjustments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CURRENTHEIGHT=$(bitcoin-cli getblockchaininfo | jq -r .blocks) | |
DIFFICULTY=1 | |
for ((HEIGHT = 0 ; HEIGHT < CURRENTHEIGHT ; HEIGHT += 2016)) | |
do | |
NEW_DIFFICULTY=$(bitcoin-cli getblock $(bitcoin-cli getblockhash $HEIGHT) | jq -r .difficulty) | |
ADJUSTMENT=$(bc <<< "scale=16 ; ((($NEW_DIFFICULTY * 100 / $DIFFICULTY)) - 100)" | awk '{printf("%.2f \n",$1)}') | |
echo $((HEIGHT / 2016)) $HEIGHT $NEW_DIFFICULTY $ADJUSTMENT | |
DIFFICULTY=$NEW_DIFFICULTY | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment