Quick and dirty bitcoin address monitoring

Here is a solution that allows to quickly and easily monitor some bitcoin addresses, so you can be notified when a transaction is made (receiving or sending bitcoins). An email is sent when address balance has changed. This solution written in bash has the advantage of not requiring the installation of third party packages. Of course it’s quick and dirty, do not wait for a very elaborated code, but the work is done and that’s the main thing.

repertoire="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ ! -f "$repertoire"/"$adresse".txt ]; then
        soldeactuel="$(wget -qO- blockchain.info/rawaddr/"$adresse" 2>&1 | grep -Po '"final_balance":\K[0-9]+' | awk '{s=$1/100000000} END {printf "%0.8f\n", s}')"
        printf "$soldeactuel" > "$repertoire"/"$adresse".txt
        anciensolde="$(cat "$repertoire"/"$adresse".txt)"
        soldeactuel="$(wget -qO- blockchain.info/rawaddr/"$1" 2>&1 | grep -Po '"final_balance":\K[0-9]+' | awk '{s=$1/100000000} END {printf "%0.8f\n", s}')"
        if [ $anciensolde != $soldeactuel ]
               mail -s "Bitcoin monitored adress has changed" somemail@somemail.com <<< "Bitcoin adress "$adresse" just received a new transaction. Balance is now: "$soldeactuel"" 
               printf "$soldeactuel" > "$repertoire"/"$adresse".txt

usage: command somebitcoinaddress
to put in the crontab, for example every 15 minutes.



Leave a Comment

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *