Bitcoin Forum

Bitcoin => Project Development => Topic started by: klama98 on January 08, 2018, 02:01:13 PM



Title: Quick and dirty bitcoin and ETH address monitoring
Post by: klama98 on January 08, 2018, 02:01:13 PM
Here is a solution that allows to quickly and easily monitor some BTC or ETH addresses, so you can be notified when a transaction is made (receiving or sending coins). An email is sent when address balance has changed. This solution written for 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.

usage: command address coin(BTC or ETH)

Code:
#!/bin/bash
adresse=$1
crypto=$2
repertoire="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ ! -f "$repertoire"/"$adresse".txt ]; then

        #premiere utilisation, CREATION DU FICHIER

        if [ $crypto = "BTC" ] ; 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}')"; fi
        if [ $crypto = "ETH" ] ; then soldeactuel="$(curl -s https://api.gastracker.io/addr/"$adresse" | jq -r '.balance.ether')"; fi
        printf "$soldeactuel" > "$repertoire"/"$adresse".txt
        exit
else
        #le fichier existe, on peut comparer

        anciensolde="$(cat "$repertoire"/"$adresse".txt)"
        if [ $crypto = "BTC" ] ; 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}')"; fi
        if [ $crypto = "ETH" ] ; then soldeactuel="$(curl -s https://api.gastracker.io/addr/"$adresse" | jq -r '.balance.ether')"; fi

        if [ $anciensolde != $soldeactuel ]
        then
                # les soldes sont differents
                mail -s  ""$crypto" monitored adress has changed" someemail@gmail.com <<< ""$crypto" adress "$adresse" just received a new transaction. Balance is now: "$soldeactuel""
                printf "$soldeactuel" > "$repertoire"/"$adresse".txt
        fi
fi


Title: Re: Quick and dirty bitcoin and ETH address monitoring
Post by: cryptocropty on January 11, 2018, 07:50:59 PM
Bonsoir, I like it. Had to install jq, but so I learned about it.


Title: Re: Quick and dirty bitcoin and ETH address monitoring
Post by: mortalys on January 11, 2018, 10:42:06 PM
Hello,

 You use a software that I develop for Windows - walletZ - check my thread


 https://bitcointalk.org/index.php?topic=2384747

 It has support for alot of coin :) Just for monitoring!


Title: Re: Quick and dirty bitcoin and ETH address monitoring
Post by: stantpro on January 12, 2018, 03:41:32 PM
This is incredibly genius! I need to know where to install this code in order to test-run its functionality.
Hope it works as app o a mobile phone or as an application in a desktop computer.I guess it helps one
to monitor activities in the wallet addresses.