2020-05-01 15:19:51 +02:00
|
|
|
#!/bin/bash
|
|
|
|
################################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
|
|
|
# Version: 0.1
|
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
################################################################################
|
2020-05-07 02:27:11 +02:00
|
|
|
# TODO: Before June 2020: Get "~/.zen/g1billets/$bpath/note.authfile.IPFSPrivKey.gpg" for automatic Payback
|
2020-05-01 15:19:51 +02:00
|
|
|
# Search for old G1Billets for final CHK : Forget & Transfer G1 ?
|
2020-05-03 23:37:47 +02:00
|
|
|
source ./init.sh
|
|
|
|
source ./functions.sh
|
2020-05-01 15:19:51 +02:00
|
|
|
|
|
|
|
# Existence days number can be $1
|
|
|
|
if [[ "$1" ]]; then vieux="$1"; else vieux=210; fi
|
|
|
|
if [[ "$2" ]]; then dest="$2"; else dest=$NODE_G1PUBKEY; fi
|
|
|
|
|
|
|
|
echo "Recherche de G1Billets plus vieux que $vieux jours."
|
|
|
|
Nbillets=$(find billets/ -daystart -mtime +$vieux -type f -name "*.pubkey" | wc -l)
|
|
|
|
echo "$Nbillets G1Billets trouvés..."
|
|
|
|
|
|
|
|
for result in $(find billets/ -daystart -mtime +$vieux -type d -name "*"); do
|
|
|
|
billetname=$(echo $result | cut -d '/' -f 2)
|
|
|
|
if [[ $billetname && "$billetname" != "MEMBERS" ]]; then
|
|
|
|
((Nbillets --))
|
|
|
|
numero=$(echo $billetname | sed s/_/\ /g )
|
|
|
|
creator=$(cat "$result/note.creator")
|
|
|
|
value=$(cat "$result/note.value")
|
|
|
|
unit=$(cat "$result/note.unit")
|
|
|
|
pubkey=$(cat "$result/note.pubkey")
|
|
|
|
salt=$(cat "$result/note.salt")
|
|
|
|
secret=$(cat "$result/note.secret")
|
|
|
|
|
|
|
|
solde=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 balance $pubkey | grep Quantitative | cut -d '=' -f 2 | cut -d ' ' -f 2)
|
|
|
|
|
|
|
|
# GET creator member wallet ($dest) and refund if still at initial G1 value (lost or unused BILL).
|
|
|
|
virement=$solde
|
|
|
|
[[ -f "$result/note.g1" ]] && initialvalue=$(cat "$result/note.g1") && if [[ $solde -eq $initialvalue ]]; then virement=$solde; else virement=1; fi
|
|
|
|
[[ -f "$result/note.memrib" ]] && dest=$(cat "$result/memrib")
|
|
|
|
|
|
|
|
echo ">>> $billetname $pubkey créé par $creator, valeur initiale $virement G1 (initialement $initialvalue G1)."
|
|
|
|
echo ">>> Virer à $dest $virement G1 du G1billet !! ID / Pass:"
|
|
|
|
echo $numero
|
|
|
|
echo $secret $salt
|
|
|
|
echo "/usr/local/bin/silkaj tx --amount=\"$virement\" --output=\"$dest\""
|
|
|
|
|
|
|
|
if [[ "$virement" == "0.0" ]]; then
|
|
|
|
echo "G1Billet déjà vide, suppression de $result"; rm -Rf $result;
|
|
|
|
else
|
|
|
|
PAY=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 tx --amount="$virement" --output="$dest" --comment="[G1Billet] $numero" -y)
|
|
|
|
if [[ ! $(echo $PAY | grep "successfully sent") ]]; then
|
|
|
|
echo "!!!! ERREUR: $virement Something Wrong happened with $result. Moving to /tmp/ERROR_BILL_$billetname (please check or remove)"
|
|
|
|
mkdir -p /tmp/ERROR_BILL_$billetname
|
|
|
|
mv $result/* /tmp/ERROR_BILL_$billetname
|
|
|
|
else
|
|
|
|
echo $PAY
|
|
|
|
echo "OK! On supprime $result et continue avec le billet $Nbillets"
|
|
|
|
echo
|
|
|
|
rm -Rf $result
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "MEMBER:" $result
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|