Skip to content

Instantly share code, notes, and snippets.

@midnightmagic
Created September 17, 2012 06:37
Show Gist options
  • Save midnightmagic/3735859 to your computer and use it in GitHub Desktop.
Save midnightmagic/3735859 to your computer and use it in GitHub Desktop.
search bitcoin tx for amounts
#!/bin/bash
if [ $# -ne 2 ]
then
echo usage: $0 '[top|head|N] [tail|bottom|-M|M]'
echo " "-M means first arg minus integer M
exit 1
fi
FIRST=$1; [ "$1" = "head" -o "$1" = "top" ] && \
FIRST=$( bitcoind getinfo|grep blocks|awk '{ print $3 }'|sed -e 's/,//g' )
echo using $FIRST as top search param
LAST=$2; [ "$2" = "tail" -o "$1" = "bottom" ] && LAST=1
[[ "$LAST" = -* ]] && LAST=$(( $FIRST + $LAST ))
echo using $LAST as bottom search param
INCR=1; [ $FIRST -gt $LAST ] && INCR=-1
for i in $( seq $FIRST $INCR $LAST )
do
echo working on $i
for j in $( bitcoind getblock $( bitcoind getblockhash $i ) \
| grep -E '"[0-9a-f]{64}"'|grep -vE '(hash|root)' \
|sed -e 's/"//g' -e "s/,//g" )
do
bitcoind getrawtransaction "$j" 1 | grep -E '("value"|txid)'
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment