Skip to content

Instantly share code, notes, and snippets.

@nicovs
Last active May 9, 2018 13:11
Show Gist options
  • Save nicovs/39116961e8d97f13ec655fc3646437b0 to your computer and use it in GitHub Desktop.
Save nicovs/39116961e8d97f13ec655fc3646437b0 to your computer and use it in GitHub Desktop.
Newyorkcoin electrumx checkpoints file
#!/bin/zsh
EXPLORERAPI=https://explorer.nycoin.community/api
BLOCKHIGHT=$(curl -s "$EXPLORERAPI/getblockcount")
calc(){ awk "BEGIN{ print $* }" ;}
counter=0
echo "["
for i in {2015..$BLOCKHIGHT..2016}
do
HASH=$(curl -s "$EXPLORERAPI/getblockhash?index=$i")
sleep .5
DATA=$(curl -s "$EXPLORERAPI/getblock?hash=$HASH")
BITS=$(echo $DATA | jq -r ' .bits')
TIME=$(echo $DATA | jq -r ' .time')
EXP="$((16#${BITS:0:2}))"
C=$(echo $BITS | sed 's/^..//')
COEF=$((16#${C}))
echo " ["
echo " \"$HASH\","
echo " $(calc "($COEF*(2^(8*($EXP-3))))"),"
echo " $TIME"
echo " ],"
sleep .5
done
echo "]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment