Skip to content

Instantly share code, notes, and snippets.

@meeDamian
Last active April 25, 2019 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meeDamian/c83f0e6231f17d474340f75c1e9a8c89 to your computer and use it in GitHub Desktop.
Save meeDamian/c83f0e6231f17d474340f75c1e9a8c89 to your computer and use it in GitHub Desktop.
Fetches and compares blockchain size growth between BTC & BCH.
#!/bin/bash
BLOCKCHAIN_INFO_URL="https://api.blockchain.info/charts/blocks-size?timespan=2years&format=csv"
VERy_BITCOIN="https://charts.bitcoin.com/bch/api/chart/blockchain-size"
SPLIT_DATE="2017-08-01"
# I use date for two days ago, as depending on your TZ, bc.info might not have the data yet
RECENT_DATE="$(date -v-2d +%F)"
AT_SPLIT=$(curl -s ${BLOCKCHAIN_INFO_URL} | grep "${SPLIT_DATE}" | cut -d, -f2 | cut -d. -f1)
BTC_NOW=$(curl -s ${BLOCKCHAIN_INFO_URL} | grep "${RECENT_DATE}" | cut -d, -f2 | cut -d. -f1)
BCH_NOW=$(curl -s ${VERy_BITCOIN} | jq '.[-1][1] | . / 1024 / 1024 | round')
BTC_GROW=$(expr $BTC_NOW - $AT_SPLIT)
BCH_GROW=$(expr $BCH_NOW - $AT_SPLIT)
DIFF=$(expr $BTC_GROW / $BCH_GROW)
printf "BTC growth: ${BTC_GROW} MB\n"
printf "BCH growth: ${BCH_GROW} MB\n"
printf "\tdiff: ${DIFF}x\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment