Skip to content

Instantly share code, notes, and snippets.

@disq
Created June 12, 2011 09:11
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 disq/1021366 to your computer and use it in GitHub Desktop.
Save disq/1021366 to your computer and use it in GitHub Desktop.
Script to send e-mail on new transactions in bitcoin
#!/bin/bash
RET=`/usr/local/bin/bitcoind --rpcconnect listtransactions`
RETCNT=`echo ${RET}|php -r '$x = file_get_contents("php://stdin");$a=json_decode($x);echo count($a);'`
LASTCNT=`cat ~/gen-check.last 2>/dev/null`
if [ "$LASTCNT" == "" ]; then
LASTCNT=0
fi
if [ $RETCNT -gt $LASTCNT ]; then
echo "sound the alarm, we have transactions"
echo "`date` ${RET}" | sendemail -q -f from@gmail.com -t to@gmail.com -u "BITCOIN TRANSACTIONS!" -s smtp.gmail.com:587 -o tls=auto -xu from@gmail.com -xp password-of-from-gmail
echo ${RETCNT} >~/gen-check.last
sync
exit 0
fi
echo "its ok"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment