-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathstats
More file actions
executable file
·241 lines (207 loc) · 8.65 KB
/
stats
File metadata and controls
executable file
·241 lines (207 loc) · 8.65 KB
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/bash
# Stats script for Komodo Notary Nodes
#
# @author webworker01
#
scriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $scriptpath/main
color_red=$'\033[0;31m'
color_reset=$'\033[0m'
checkRepo () {
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
return
fi
prevdir=${PWD}
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
}
#Do not change below for any reason!
#The LTC and KMD address here must remain the same. Do not need to enter yours!
utxoamt=0.00010000
ntrzdamt=-0.00083600
# btcntrzaddr=1P3rU1Nk1pmc2BiWC8dEy9bZa1ZbMp5jfg
ltcntrzaddr=LhGojDga6V1fGzQfNGcYFAfKnDvsWeuAsP
kmdntrzaddr=RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA
# Only count KMD->BTC after this timestamp
# Season 5 kmd block 2437301
timefilter=1623711782
# Second time filter for assetchains
# season 5 ACs - Season 5 Monday, June 14th, 2021 (03:00:00 PM UTC) (Komodo commit 7e380a1)
timefilter2=1623682800
format="%-11s %6s %7s %6s %.20s %8s %7s %5s %6s %6s %6s"
outputstats ()
{
count=0
totalntrzd=0
now=$(date +"%H:%M")
printf "\n\n"
printf "%-11s %6s %7s %6s %8s %8s %7s %5s %6s %6s\n" "-CHAIN-" "-NOTR-" "-LASTN-" "-UTXO-" "-BAL-" "-BLOX-" "-LASTB-" "-CON-" "-SIZE-" "-TIME-";
kmdinfo=$($komodocli getinfo)
kmdtxinfo=$($komodocli listtransactions "" $txscanamount)
kmdlastntrztime=$(echo $kmdtxinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
kmdutxos=$($komodocli listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')
TIMEFORMAT="%R"
wallettime=$( (time $komodocli listunspent) 2>&1 > /dev/null )
if (( $thirdpartycoins < 1 )); then
othercoins="coinsfirst[@]"
mined="$(echo $kmdtxinfo | jq '[.[] | select(.generated==true)] | length') mined"
else
othercoins="coinsthird[@]"
mined=""
fi
printf "$format\n" "KMD" \
"" \
"$(timeSince $kmdlastntrztime)" \
"$kmdutxos" \
"$(printf "%8.3f" $(echo $kmdinfo | jq .balance))" \
"$(echo $kmdinfo | jq .blocks)" \
"$(timeSince $($komodocli getblock $($komodocli getbestblockhash) | jq .time))" \
"$(echo $kmdinfo | jq .connections)" \
"$(ls -lh ~/.komodo/wallet.dat | awk '{print $5}')" \
"$wallettime" \
"$mined"
for coins in "${!othercoins}"; do
coin=($coins)
seasonfilter=$timefilter2
#expand coinexec
eval $(echo coinexec=${coin[1]})
if [[ -f "${HOME}/${coin[3]}/wallets/wallet.dat" ]]; then
coinwalletpath="${HOME}/${coin[3]}/wallets/wallet.dat"
else
coinwalletpath="${HOME}/${coin[3]}/wallet.dat"
fi
case ${coin[0]} in
BTC)
coinsutxoamount=$utxoamt
coinsntraddr=$btcntrzaddr
seasonfilter=$timefilter
;;
LTC)
coinsutxoamount=$utxoamt
coinsntraddr=$ltcntrzaddr
seasonfilter=$timefilter
;;
EMC2)
coinsutxoamount=0.00100000
coinsntraddr=EfCkxbDFSn4X1VKMzyckyHaXLf4ithTGoM
;;
AYA)
coinsutxoamount=0.00100000
coinsntraddr=Adpj7WENLyRkq9vVknHa82rf3cVHjYvzCG
;;
SFUSD)
coinsutxoamount=$utxoamt
coinsntraddr=SjLrVr9tkBxoYVVxjZcKX3k8Dno2A28YD7
;;
MIL)
coinsutxoamount=0.00100000
coinsntraddr=MVx1hSH9WqwQurgqR7HBDRCu3ESkuhQC8r
;;
*)
coinsutxoamount=$utxoamt
coinsntraddr=$kmdntrzaddr
;;
esac
coinstxinfo=$($coinexec 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 $seasonfilter '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
otherutxo=$($coinexec listunspent | jq --arg amt "$coinsutxoamount" '[.[] | select(.amount==($amt|tonumber))] | length')
totalntrzd=$(( $totalntrzd + $coinsntrzd ))
wallettime=$( (time $coinexec listunspent) 2>&1 >/dev/null )
balance=$($coinexec getbalance)
if (( $(bc <<< "$balance < 0.02") )); then
balance="${color_red}$(printf "%8.3f" $balance)${color_reset}"
else
balance=$(printf "%8.3f" $balance)
fi
laststring=""
if (( thirdpartycoins > 0 )); then
lastcoin=(${coinsthird[-1]})
secondlast=(${coinsthird[-2]})
if [[ ${coin[0]} == ${lastcoin[0]} ]]; then
laststring="@ $now"
fi
if [[ ${coin[0]} == ${secondlast[0]} ]]; then
laststring="All:$totalntrzd"
fi
fi
printf "$format\n" "${coin[0]}" \
"$coinsntrzd" \
"$(timeSince $coinslastntrztime)" \
"$otherutxo" \
"$balance" \
"$($coinexec getblockchaininfo | jq .blocks)" \
"$(timeSince $($coinexec getblock $($coinexec getbestblockhash) | jq .time))" \
"$($coinexec getnetworkinfo | jq .connections)" \
"$(ls -lh ${coinwalletpath} | awk '{print $5}')" \
"$wallettime" \
"$laststring"
done
if (( thirdpartycoins < 1 )); then
lastcoin=(${coinlist[-1]})
secondlast=(${coinlist[-2]})
for coins in "${coinlist[@]}"; do
coin=($coins)
if [[ ! ${ignoreacs[*]} =~ ${coin[0]} ]]; then
info=$($komodocli -ac_name=${coin[0]} getinfo)
mininginfo=$($komodocli -ac_name=${coin[0]} getmininginfo)
txinfo=$($komodocli -ac_name=${coin[0]} 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 ))
acutxo=$($komodocli -ac_name=${coin[0]} listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')
wallettime=$( (time $komodocli -ac_name=${coin[0]} listunspent) 2>&1 >/dev/null )
balance=$(jq .balance <<< $info)
if (( $(bc <<< "$balance < 0.02") )); then
balance="${color_red}$(printf "%8.3f" $balance)${color_reset}"
else
balance=$(printf "%8.3f" $balance)
fi
laststring=""
if [[ ${coin[0]} == ${lastcoin[0]} ]]; then
laststring="@ $now"
fi
if [[ ${coin[0]} == ${secondlast[0]} ]]; then
laststring="All:$totalntrzd"
fi
printf "$format" "${coin[0]}" \
"$acntrzd" \
"$(timeSince $lastntrztime)" \
"$acutxo" \
"$balance" \
"$(echo $info | jq .blocks)" \
"$(timeSince $($komodocli -ac_name=${coin[0]} getblock $($komodocli -ac_name=${coin[0]} getbestblockhash) | jq .time))" \
"$(echo $info | jq .connections)" \
"$(ls -lh ~/.komodo/${coin[0]}/wallet.dat | awk '{print $5}')" \
"$wallettime" \
"$laststring"
if [[ ${coin[0]} != ${lastcoin[0]} ]]; then
echo
fi
fi
done
fi
# Check if repos defined in paths file have an update compared to local
for repoindex in "${!repos[@]}"; do
repo=(${repos[${repoindex}]})
hasupdate=$(checkRepo ${repoindex} ${repo[0]} ${repo[1]})
if [[ ! -z ${hasupdate} ]]; then
echo -e "\n${repoindex} has an update ${hasupdate}"
fi
done
}
if [ "$sleepytime" != "false" ]; then
while true; do
outputstats
sleep $sleepytime
done
else
outputstats
echo
fi