forked from KMDLabs/LabsNotary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats
executable file
·112 lines (90 loc) · 4.01 KB
/
stats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
myscriptDir="$( cd "$(dirname -- "$0")" ; pwd -P )"
cd $myscriptDir
#Stats script for Komodo Notary Nodes
#
#Requires jq v1.5+ and bitcoin-cli, komodo-cli, chips-cli and gamecredits-cli installed (e.g. symlinked to /usr/local/bin)
#==Options - Only Change These==
#Seconds in display loop, change to false if you don't want it to loop
sleepytime=false
#How many transactions back to scan for notarizations
txscanamount=77777
#==End Options==
# Just to be sure printf doesn't reject with "invalid number" error because of decimal separator
LC_NUMERIC="en_US.UTF-8"
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
}
#Do not change below for any reason!
#The BTC and KMD address here must remain the same. Do not need to enter yours!
utxoamt=0.00010000
ntrzdamt=-0.00083600
kmdntrzaddr=RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA
timefilter2=1525513998
#format="%-13s %6s %6s %7s %12.4f %6s %6s %6s"
format="%-13s %12.4f %7s %7s %7s %7s %7s %7s %7s %7s %7s"
outputstats ()
{
count=0
totalntrzd=0
now=$(date +"%H:%M")
printf "\n\n"
printf "%-13s %12s %7s %7s %7s %7s %7s %7s %7s %7s %7s\n" "-ASSET-" "-BALANCE-" "-TXN-" "-UTXO-" "-DUST-" "-NOTR-" "-BLOX-" "-PCT-" "-LAST-" "-CNCT-";
kmddust=
kmdinfo=$(komodo-cli getinfo)
kmdtxinfo=$(komodo-cli listtransactions "" $txscanamount)
kmdlastntrztime=$(echo $kmdtxinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
printf "$format\n" "KMD" \
"$(printf "%12.4f" $(echo $kmdinfo | jq .balance))" \
"$(komodo-cli getwalletinfo | jq .txcount)" \
"$(komodo-cli listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(komodo-cli listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount<($amt|tonumber))] | length')" \
" " \
"$(echo $kmdinfo | jq .blocks)" \
" "\
"$(timeSince $kmdlastntrztime)" \
"$(echo $kmdinfo | jq .connections)"
./listassetchains.py | while read coins; do
coin=($coins)
info=$(komodo-cli -ac_name=${coin} getinfo)
blocks=$(echo $info | jq .blocks)
txinfo=$(komodo-cli -ac_name=${coin} 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 $timefilter2 '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $acntrzd ))
pct=$(echo "${acntrzd}/${blocks}*100" | bc -l)
printf "$format" "${coin[0]}" \
"$(printf "%12.4f" $(echo $info | jq .balance))" \
"$(komodo-cli -ac_name=${coin[0]} getwalletinfo | jq .txcount)" \
"$(komodo-cli -ac_name=${coin[0]} listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(komodo-cli -ac_name=${coin[0]} listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount<($amt|tonumber))] | length')" \
"$acntrzd" \
"$blocks" \
"$(printf "%2.1f" $(echo $pct))%" \
"$(timeSince $lastntrztime)" \
"$(echo $info | jq .connections)"
echo ""
done
}
outputstats