btc-halvening (489B)
1 #!/usr/bin/env sh 2 past=${1:-50} 3 blocks=$(bcli getblockcount) 4 blockstogo=$((210000 - ($blocks % 210000))) 5 blocktimes=$(btc-blocktimes $past) 6 countdown=$(qalc -t "$blocktimes seconds * $blockstogo") 7 blocktimes=$(qalc -t "$blocktimes seconds") 8 estimate=$(qalc -t "now + $countdown" | tr -d '"') 9 10 printf "blocks\t%d\nblocks to go\t%d\naverage block time (past $past blocks)\t%s\ntime until halvening\t%s\nestimate\t%s\n" \ 11 "$blocks" "$blockstogo" "$blocktimes" "$countdown" "$estimate" | ct