Skip to content

Instantly share code, notes, and snippets.

@scriptzteam
Forked from mutatrum/taproot.sh
Created May 4, 2021 16:41
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 scriptzteam/4149db8f6f0de40b68b3b780ce47713a to your computer and use it in GitHub Desktop.
Save scriptzteam/4149db8f6f0de40b68b3b780ce47713a to your computer and use it in GitHub Desktop.
Print a taproot signalling block diagram
#!/bin/bash
BLOCKCHAININFO=$(bitcoin-cli getblockchaininfo)
TAPROOT=$(echo "$BLOCKCHAININFO" | jq .softforks.taproot.bip9)
SINCE=$(echo "$TAPROOT" | jq .since)
ELAPSED=$(echo "$TAPROOT" | jq .statistics.elapsed)
for BLOCK in $(seq "$SINCE" $((SINCE + ELAPSED - 1))); do
HASH=$(bitcoin-cli getblockhash "$BLOCK")
HEADER=$(bitcoin-cli getblockheader "$HASH")
VERSION=$(echo "$HEADER" | jq .version)
SIGNAL=$(((VERSION & 3758096388) == 536870916))
case $SIGNAL in
(1) echo -n "🟩";;
(0) echo -n "🟥";;
esac
if ((($BLOCK + 1) % 48 == 0)); then echo; fi
done
echo
PERCENTAGE=`echo $BLOCKCHAININFO | jq '.softforks.taproot.bip9.statistics | .count / .elapsed * 100'`
echo $PERCENTAGE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment