Add new script to get balance of each wallets

This commit is contained in:
poka 2020-10-16 21:14:11 +02:00
parent dadf846f90
commit 8bf72a01b4
1 changed files with 41 additions and 0 deletions

41
scripts/walletsBalance.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
source $GPATH/.env
node=$(cut -d '/' -f3 <<<"$DUNITER")
rm -f silkaj_error.log
work() {
for i in $wallets; do
exec() {
balance=$(silkaj -p $node balance $i)
}
exec
while [[ $? == 1 ]]; do echo "Erreur $i $k" | tee -a silkaj_error.log; ((k++)); exec; done
unset k
balance=$(awk '/Total Quantitative =/ { print $4 }' <<<"$balance")
[[ $1 == "members" ]] && username=$(curl -m 20 -s $DUNITER/wot/members | jq -r --arg pubkey "$i" '.results[] | select(.pubkey==$pubkey) | .uid')
formatedBalance="$balance"$'\t'"$i"
[[ $username ]] && formatedBalance="$formatedBalance"$'\t'"$username"
unset username
echo "$formatedBalance"
totalBalance="$totalBalance"$'\n'"$formatedBalance"
# For tests only
# [[ $i == "13fn6X3XWVgshHTgS8beZMo9XiyScx6MB6yPsBB5ZBia" ]] && break
# [[ $i == "12JDJibbgZPRfD6Hoecg8rQRvCR5VYrMnqzfhQYmAr3k" ]] && break
done
}
wallets=$(curl -s https://g1-stats.axiom-team.fr/data/wallets-g1-membres.txt)
work members
wallets=$(curl -s https://g1-stats.axiom-team.fr/data/wallets-g1-simple.txt)
work
totalBalance=$(sort -nr <<<$totalBalance)
grep . <<<"$totalBalance" > $GPATH/db/wallets_balance.txt