-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstatsext
224 lines (194 loc) · 6.96 KB
/
statsext
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/bin/bash
# Stats script for Komodo Notary Nodes
#
# by webworker01
#
# mod by mrlynch for use with separated accounts for external coins
#
# Requires jq v1.5+, bc - sudo apt-get install jq bc
#
# komodo-cli, bitcoin-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=600
#How many transactions back to scan for notarizations
txscanamount=777
#You can modify this list of ACs to exclude or comment out the line to show all
#ignoreacs=('VOTE2018' 'BEER' 'PIZZA')
#Full path to komodo-cli
komodoexec=/usr/local/bin/komodo-cli
#git checking - path and remote branch
declare -A repos=(
[KMD]='$HOME/komodo origin/beta'
[SUPERNET]='$HOME/SuperNET origin/dev'
[CHIPS]='<chips_home>/chips3 origin/dev'
[GAME]='<game_home>/GameCredits origin/master'
[EMC2]='<einsteinium_home>/einsteinium origin/master'
[GIN]='<gincoin_home>/gincoin-core origin/master'
)
#declare non komodo clis - symlink them to /usr/local/bin or set the full path accessible as the second part of each string, the 3rd entry is the name of the data dir for the coin and assumes they are in $HOME
othercoins=(
'CHIPS chips-cli <chips_home>/.chips'
'GAME gamecredits-cli <game_home>/.gamecredits'
'EMC2 einsteinium-cli <einsteinium_home>/.einsteinium'
'GIN gincoin-cli <gincoin_home>/.gincoincore'
)
#==End Options==
color_red=$'\033[0;31m'
color_reset=$'\033[0m'
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 (( d < 2 && h > 0 )); then
echo -n "${h}h"
fi
if (( d == 0 && h < 4 && m > 0 )); then
echo -n "${m}m"
fi
if (( d == 0 && h == 0 && m == 0 )); then
echo -n "${s}s"
fi
fi
}
checkRepo () {
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
return
fi
prevdir=${PWD}
eval cd "$2"
git remote update > /dev/null 2>&1
localrev=$(git rev-parse HEAD)
remoterev=$(git rev-parse $3)
cd $prevdir
if [ $localrev != $remoterev ]; then
printf "$color_red[U]$color_reset"
fi
case $1 in
KMD)
printf " "
;;
CHIPS)
printf " "
;;
GAME)
printf " "
;;
HUSH)
printf " "
;;
EMC2)
printf " "
;;
VRSC)
printf " "
;;
esac
}
#Do not change below for any reason!
#The BTC and KMD address here must remain the same. Do not need to enter yours!
#source ~/nnutils/coinlist
utxoamt=0.00010000
ntrzdamt=-0.00083600
btcntrzaddr=1P3rU1Nk1pmc2BiWC8dEy9bZa1ZbMp5jfg
kmdntrzaddr=RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA
#Only count KMD->BTC after this timestamp (block 814000)
timefilter=1525032458
#Second time filter for assetchains (SuperNET commit 07515fb)
timefilter2=1525513998
format="%-11s %6s %7s %6s %.20s %8s %7s %5s %6s %6s"
outputstats ()
{
count=0
totalntrzd=0
now=$(date +"%H:%M")
printf "\n\n"
printf "%-11s %6s %7s %6s %8s %8s %7s %5s %6s\n" "-CHAIN-" "-NOTR-" "-LASTN-" "-UTXO-" "-BAL-" "-BLOX-" "-LASTB-" "-CON-" "-SIZE-";
kmdinfo=$($komodoexec getinfo)
kmdtxinfo=$($komodoexec listtransactions "" $txscanamount)
kmdlastntrztime=$(echo $kmdtxinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
kmdutxos=$($komodoexec listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')
repo=(${repos[KMD]})
printf "$format\n" "KMD$(checkRepo KMD ${repo[0]} ${repo[1]})" \
"" \
"$(timeSince $kmdlastntrztime)" \
"$kmdutxos" \
"$(printf "%8.3f" $(echo $kmdinfo | jq .balance))" \
"$(echo $kmdinfo | jq .blocks)" \
"$(timeSince $($komodoexec getblock $($komodoexec getbestblockhash) | jq .time))" \
"$(echo $kmdinfo | jq .connections)" \
"$(ls -lh ~/.komodo/wallet.dat | awk '{print $5}')" \
"$(echo $kmdtxinfo | jq '[.[] | select(.generated==true)] | length') mined"
for coins in "${othercoins[@]}"; do
coin=($coins)
case ${coin[0]} in
BTC)
coinsutxoamount=$utxoamt
coinsntraddr=$btcntrzaddr
;;
GAME)
coinsutxoamount=0.00100000
coinsntraddr=Gftmt8hgzgNu6f1o85HMPuwTVBMSV2TYSt
;;
GIN)
coinsutxoamount=$utxoamt
coinsntraddr=Gftmt8hgzgNu6f1o85HMPuwTVBMSV2TYSt
;;
HUSH)
coinsutxoamount=$utxoamt
coinsntraddr=t1fvTULnsz9ZCcpmQ8ZSN6xhUpfkgEuqeNX
;;
EMC2)
coinsutxoamount=0.00100000
coinsntraddr=EfCkxbDFSn4X1VKMzyckyHaXLf4ithTGoM
;;
VRSC)
coinsutxoamount=$utxoamt
coinsntraddr=$kmdntrzaddr
;;
*)
coinsutxoamount=$utxoamt
coinsntraddr=$kmdntrzaddr
;;
esac
coinstxinfo=$(${coin[1]} listtransactions "" $txscanamount)
coinslastntrztime=$(echo $coinstxinfo | jq -r --arg address "$coinsntraddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
coinsntrzd=$(echo $coinstxinfo | jq --arg address "$coinsntraddr" --arg timefilter $timefilter2 '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
otherutxo=$(${coin[1]} listunspent | jq --arg amt "$coinsutxoamount" '[.[] | select(.amount==($amt|tonumber))] | length')
totalntrzd=$(( $totalntrzd + $coinsntrzd ))
repo=(${repos[${coin[0]}]})
balance=$(${coin[1]} getbalance)
if (( $(bc <<< "$balance < 0.02") )); then
balance="${color_red}$(printf "%8.3f" $balance)${color_reset}"
else
balance=$(printf "%8.3f" $balance)
fi
printf "$format\n" "${coin[0]}$(checkRepo ${coin[0]} ${repo[0]} ${repo[1]})" \
"$coinsntrzd" \
"$(timeSince $coinslastntrztime)" \
"$otherutxo" \
"$balance" \
"$(${coin[1]} getblockchaininfo | jq .blocks)" \
"$(timeSince $(${coin[1]} getblock $(${coin[1]} getbestblockhash) | jq .time))" \
"$(${coin[1]} getnetworkinfo | jq .connections)" \
"$(ls -lh ${coin[2]}/wallet.dat | awk '{print $5}')"
done
}
if [ "$sleepytime" != "false" ]; then
while true; do
outputstats
sleep $sleepytime
done
else
outputstats
echo
fi