Skip to content

Instantly share code, notes, and snippets.

@pointbiz
Created July 23, 2017 03: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 pointbiz/ff5f33dc3db1e6599eb26d36e48a591a to your computer and use it in GitHub Desktop.
Save pointbiz/ff5f33dc3db1e6599eb26d36e48a591a to your computer and use it in GitHub Desktop.
#!/bin/bash
#get current block height from blockchain.infoecho $(date)
wget -4 https://blockchain.info/q/getblockcount &> /dev/null
netblk=$(<getblockcount)
echo "Current Block: $netblk"
#get current block from local bitcoin-cli
./bitcoin-cli getblockcount > locblock
nodeblk=$(<locblock)
echo "Local Block: $nodeblk"
#if bitcoin-cli responds, compare local with network blocks
if [ "$nodeblk" == "" ]; then
echo "checking recent blocks. please wait"
else
diff=$((netblk-nodeblk))
echo "$diff" "blocks behind"
rm getblockcount
rm locblock
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment