You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
5.8 KiB

7 years ago
#!/bin/bash
#==Options - Only Change These==
#Seconds in display loop, change to false if you don't want it to loop
sleepytime=600
#How many transactions back to scan for notarizations
txscanamount=77777
#Only count tx after this timestamp (currently set for block 814000)
timefilter=1525032458
#You can modify this list of ACs to exclude or comment out the line to show all
ignoreacs=('VOTE2018' 'BEER' 'PIZZA')
#==End Options==
7 years ago
IFS=
timeSince()
{
local currentimestamp=$(date +%s)
local timecompare=$1
if [ ! -z $timecompare ] && [[ $timecompare != "null" ]]
then
local t=$((currentimestamp-timecompare))
local d=$((t/60/60/24))
local h=$((t/60/60%24))
local m=$((t/60%60))
local s=$((t%60))
if [[ $d > 0 ]]; then
echo -n "${d}d"
fi
if [[ $h > 0 ]]; then
echo -n "${h}h"
fi
if [[ $d = 0 && $m > 0 ]]; then
echo -n "${m}m"
fi
if [[ $d = 0 && $h = 0 && $m = 0 ]]; then
echo -n "${s}s"
fi
fi
}
7 years ago
#Do not change for any reason!
#The BTC and KMD address here must remain the same. Do not need to enter yours!
source coinlist
utxoamt=0.00010000
ntrzdamt=-0.00083600
btcntrzaddr=1P3rU1Nk1pmc2BiWC8dEy9bZa1ZbMp5jfg
kmdntrzaddr=RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA
format="%-8s %7s %6s %7s %12s %8s %7s %7s\n"
7 years ago
outputstats ()
{
count=0
totalntrzd=0
7 years ago
now=$(date +"%Y-%m-%d %T%z")
printf "\n\n"
printf "$format" "-ASSET-" "-NTRZd-" "-UTXO-" "-BLOX-" "-BALANCE-" "-LAST-" "-CNCT-";
btctxinfo=$(bitcoin-cli listtransactions "" $txscanamount)
btclastntrztime=$(echo $btctxinfo | jq -r --arg address "$btcntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
btcntrzd=$(echo $btctxinfo | jq --arg address "$btcntrzaddr" --arg timefilter $timefilter '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $btcntrzd ))
printf "$format" "BTC" \
"$btcntrzd" \
7 years ago
"$(bitcoin-cli listunspent | grep $utxoamt | wc -l)" \
"$(bitcoin-cli getblockchaininfo | awk ' /\"blocks\"/ {printf $2}' | sed 's/,//')" \
"$(bitcoin-cli getbalance)" \
"$(timeSince $btclastntrztime)" \
"$(bitcoin-cli getnetworkinfo | awk ' /\"connections\"/ {printf $2}' | sed 's/,//')"
7 years ago
kmdinfo=$(komodo-cli getinfo)
kmdmininginfo=$(komodo-cli getmininginfo)
kmdtxinfo=$(komodo-cli listtransactions "" $txscanamount)
kmdlastntrztime=$(echo $kmdtxinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
kmdntrzd=$(echo $kmdtxinfo | jq --arg address "$kmdntrzaddr" --arg timefilter $timefilter '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $kmdntrzd ))
7 years ago
printf "$format" "KMD" \
"$kmdntrzd" \
7 years ago
"$(komodo-cli listunspent | grep $utxoamt | wc -l)" \
"$(echo $kmdinfo | awk ' /\"blocks\"/ {printf $2}' | sed 's/,//')" \
"$(echo $kmdinfo | awk ' /\"balance\"/ {printf $2}' | sed 's/,//')" \
"$(timeSince $kmdlastntrztime)" \
"$(echo $kmdinfo | awk ' /\"connections\"/ {printf $2}' | sed 's/,//')" \
"$(echo $kmdtxinfo | grep '\"generated\": true,' | wc -l) mined"
7 years ago
chipsinfo=$(chips-cli getinfo)
chipstxinfo=$(chips-cli listtransactions "" $txscanamount)
chipslastntrztime=$(echo $chipstxinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
chipsntrzd=$(echo $chipstxinfo | jq --arg address "$kmdntrzaddr" --arg timefilter $timefilter '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $chipsntrzd ))
7 years ago
printf "$format" "CHIPS" \
"$chipsntrzd" \
7 years ago
"$(chips-cli listunspent | grep $utxoamt | wc -l)" \
"$(echo $chipsinfo | awk ' /\"blocks\"/ {printf $2}' | sed 's/,//')" \
"$(echo $chipsinfo | awk ' /\"balance\"/ {printf $2}' | sed 's/,//')" \
"$(timeSince $chipslastntrztime)" \
"$(echo $chipsinfo | awk ' /\"connections\"/ {printf $2}' | sed 's/,//')"
7 years ago
while [[ $count -le ${#coinlist[@]} ]]
7 years ago
do
all=${coinlist[count]}
name=${all%% *}
if [ "$name" != "" ] && [[ ! ${ignoreacs[*]} =~ $name ]]
7 years ago
then
info=$(komodo-cli -ac_name=$name getinfo)
mininginfo=$(komodo-cli -ac_name=$name getmininginfo)
txinfo=$(komodo-cli -ac_name=$name listtransactions "" $txscanamount)
lastntrztime=$(echo $txinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
acntrzd=$(echo $txinfo | jq --arg address "$kmdntrzaddr" --arg timefilter $timefilter '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $acntrzd ))
7 years ago
printf "$format" "$name" \
"$acntrzd" \
7 years ago
"$(komodo-cli -ac_name=$name listunspent | grep $utxoamt | wc -l)" \
"$(echo $info | awk ' /\"blocks\"/ {printf $2}' | sed 's/,//')" \
"$(echo $info | awk ' /\"balance\"/ {printf $2}' | sed 's/,//')" \
"$(timeSince $lastntrztime)" \
"$(echo $info | awk ' /\"connections\"/ {printf $2}' | sed 's/,//')"
7 years ago
fi
count=$(( $count +1 ))
done
printf "Total: %9s %44s" "$totalntrzd" "$now";
7 years ago
}
if [ "$sleepytime" != "false" ]
then
while true
do
outputstats
sleep $sleepytime
done
else
outputstats
echo
fi