Created
February 1, 2021 14:12
-
-
Save patricklodder/1a505e6521d1059aad4e3fec912d6d41 to your computer and use it in GitHub Desktop.
Crawl block fees paid to miners
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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