Skip to content

Instantly share code, notes, and snippets.

@patricklodder
Created February 1, 2021 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patricklodder/1a505e6521d1059aad4e3fec912d6d41 to your computer and use it in GitHub Desktop.
Save patricklodder/1a505e6521d1059aad4e3fec912d6d41 to your computer and use it in GitHub Desktop.
Crawl block fees paid to miners
#!/bin/bash
#
# requirements: bash, up-to-date dogecoind with -txindex, jq, bc
# usage: ./crawl_block_fee.sh <number of blocks to look back>
START=`dogecoin-cli getbestblockhash`
NUM_BLOCKS=$1
CUR=$START
COUNTER=$NUM_BLOCKS
while [ $COUNTER -gt 0 ]; do
JSON=`dogecoin-cli getblock $CUR true`
HEIGHT=`echo $JSON | jq -r .height`
HASH=`echo $JSON | jq -r .hash`
TIME=`echo $JSON | jq -r '.time | todate'`
COINBASE_TXID=`echo $JSON | jq -r '.tx[0]'`
COINBASE=`dogecoin-cli getrawtransaction $COINBASE_TXID true`
MINER_FEES=`echo $COINBASE | jq -r '.vout | map(.value) | join(" + ")'`
TOTAL_FEE=`echo $MINER_FEES | bc`
echo $TIME $HEIGHT $HASH $TOTAL_FEE;
CUR=`echo $JSON | jq -r .previousblockhash`
COUNTER=`expr $COUNTER - 1`
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment