Skip to content

Instantly share code, notes, and snippets.

@bitstein
bitstein / halving.sh
Last active May 11, 2020 15:05 — forked from mutatrum/halving.sh
Get estimated halving date from a bitcoin node
#!/bin/bash
CURRENT_BLOCK="$(bitcoin-cli getblockcount)"
if [ $CURRENT_BLOCK -ge 630000 ]
then
SUBSIDY=$(bitcoin-cli getblockstats $CURRENT_BLOCK | jq '.subsidy')
SATS_PER_BTC=100000000
SUBSIDY_BTC=$(bc -l <<< "scale=2; $SUBSIDY / $SATS_PER_BTC")
echo "HALVING COMPLETE!"
echo "Current block: $CURRENT_BLOCK"
echo "Current subsidy: $SUBSIDY_BTC"