Skip to content

Instantly share code, notes, and snippets.

@lucasmoten
Forked from mutatrum/taproot.sh
Last active May 2, 2021 21:56
Show Gist options
  • Save lucasmoten/fcf6c06ad06ac70cb30a955f232dbc16 to your computer and use it in GitHub Desktop.
Save lucasmoten/fcf6c06ad06ac70cb30a955f232dbc16 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.bip8`
SINCE=`echo $TAPROOT | jq .since`
ELAPSED=`echo $TAPROOT | jq .statistics.elapsed`
color_green='\033[0;32m'
color_red='\033[0;31m'
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 & 4) == 4))
case $SIGNAL in
(1) printf "${color_green}T";;
(0) printf "${color_red}_";;
esac
if (( ($BLOCK + 1) % 72 == 0 )); then printf "\n"; fi
done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment