Skip to content

Instantly share code, notes, and snippets.

@mutatrum
Last active August 25, 2021 22:33
Show Gist options
  • Save mutatrum/c66b835b529a45d2605d193b8c5617df to your computer and use it in GitHub Desktop.
Save mutatrum/c66b835b529a45d2605d193b8c5617df to your computer and use it in GitHub Desktop.
Estimate taproot activation date
#!/bin/bash
CURRENT_BLOCK="$(bitcoin-cli getblockcount)"
CURRENT_BLOCK_HASH="$(bitcoin-cli getblockhash $CURRENT_BLOCK)"
CURRENT_BLOCK_TIME="$(bitcoin-cli getblock $CURRENT_BLOCK_HASH | jq '.mediantime')"
TAPROOT_BLOCK="$(bitcoin-cli getblockchaininfo | jq '.softforks.taproot.bip9.min_activation_height')"
BLOCK_DELTA="$(($TAPROOT_BLOCK-$CURRENT_BLOCK))"
PREVIOUS_BLOCK="$(($CURRENT_BLOCK-$BLOCK_DELTA))"
PREVIOUS_BLOCK_HASH="$(bitcoin-cli getblockhash $PREVIOUS_BLOCK)"
PREVIOUS_BLOCK_TIME="$(bitcoin-cli getblock $PREVIOUS_BLOCK_HASH | jq '.mediantime')"
DELTA_TIME="$(($CURRENT_BLOCK_TIME-$PREVIOUS_BLOCK_TIME))"
TAPROOT_TIME="$(($CURRENT_BLOCK_TIME+$DELTA_TIME))"
echo "$(date -d @$TAPROOT_TIME +'%F %R')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment