From face5133ec35b0a206e38339d2742da950460ff8 Mon Sep 17 00:00:00 2001 From: poka Date: Wed, 1 Jan 2020 07:11:38 +0100 Subject: [PATCH] MULTICANAL : FRED : Work in Progress ... --- shell/cron_IPFS_open_SSH.sh | 19 +++++++++++-------- shell/cron_VIR.recurrent.sh | 2 +- shell/good.nodes.txt | 1 + shell/sms_AIDE.sh | 18 ++++++++++++++++-- shell/sms_BILLET.sh | 4 ++-- shell/sms_DESTROY.sh | 14 +++++++------- shell/sms_EMAIL.sh | 5 ++++- shell/sms_G1TAG.sh | 33 +++++++++++++++++---------------- shell/sms_PAY.sh | 18 ++++++++++-------- shell/sms_REC.sh | 26 +++++++++++++------------- shell/sms_VIR.sh | 2 +- shell/sms_WHERE.sh | 12 ++++++------ shell/tata.sh | 3 +++ shell/test.sh | 22 ++++++++++++++++++++++ silkaj/src/constants.py | 2 +- 15 files changed, 115 insertions(+), 66 deletions(-) create mode 100755 shell/tata.sh create mode 100755 shell/test.sh diff --git a/shell/cron_IPFS_open_SSH.sh b/shell/cron_IPFS_open_SSH.sh index 09f3f4b..3fb7a25 100755 --- a/shell/cron_IPFS_open_SSH.sh +++ b/shell/cron_IPFS_open_SSH.sh @@ -19,12 +19,15 @@ cd $GPATH if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1) -if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi -IPFSNODEID=$(su $YOU -c "ipfs id -f='\n'") -# UIDNA NODE -[[ -f ./wallets/.$IPFSNODEID/$IPFSNODEID.uidna ]] && UIDNA=$(cat ./wallets/.$IPFSNODEID/$IPFSNODEID.uidna) || UIDNA="ssh" -su $YOU -c "ipfs p2p close --all" -su $YOU -c "ipfs p2p listen /x/$UIDNA /ip4/127.0.0.1/tcp/22" -su $YOU -c "ipfs p2p listen /x/$IPFSNODEID /ip4/127.0.0.1/tcp/80" -echo $(su $YOU -c "ipfs p2p ls") +su $YOU -c "ipfs p2p close --all" +su $YOU -c "ipfs p2p listen /x/ssh /ip4/127.0.0.1/tcp/22" +su $YOU -c "ipfs p2p listen /x/http /ip4/127.0.0.1/tcp/80" +su $YOU -c "ipfs p2p listen /x/https /ip4/127.0.0.1/tcp/443" +$(su $YOU -c "ipfs p2p ls") + +echo "================================== +CONNECT TO XPORT = ssh, http, https +XPORT=ssh +LOCALPORT=$((10000 + RANDOM % 64000)) +ipfs p2p forward /x/$XPORT /ip4/127.0.0.1/tcp/$LOCALPORT /ipfs/$IPFSNODEID" diff --git a/shell/cron_VIR.recurrent.sh b/shell/cron_VIR.recurrent.sh index 74723f0..0ee2286 100755 --- a/shell/cron_VIR.recurrent.sh +++ b/shell/cron_VIR.recurrent.sh @@ -42,7 +42,7 @@ while read line sms_INIT_ACCOUNT "$PHONE" "NOSMS" # echo -salt="$PHONE" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $REF / $NB" - PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $REF / $NB" -y) + PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $REF / $NB" -y) if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then new=$(./shell/checknodes.sh "BAN") sms_ERROR "$PHONE" "Il est survenu un problème avec votre virement. Retour silkaj: $PAY ... $new"; diff --git a/shell/good.nodes.txt b/shell/good.nodes.txt index b5b717b..5409f60 100755 --- a/shell/good.nodes.txt +++ b/shell/good.nodes.txt @@ -1,4 +1,5 @@ duniter.dethegeek.eu.org:443 +duniter.moul.re:443 g1.duniter.fr:443 g1.duniter.org:443 g1.le-sou.org:443 diff --git a/shell/sms_AIDE.sh b/shell/sms_AIDE.sh index 7c182dd..5e9b2a3 100755 --- a/shell/sms_AIDE.sh +++ b/shell/sms_AIDE.sh @@ -4,8 +4,22 @@ # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ################################################################################ -source ./shell/init.sh -source ./shell/functions.sh +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +if [[ -f $MY_PATH/.profile ]]; then + source $MY_PATH/.profile +elif [[ -f $MY_PATH/../.profile ]]; then + source $MY_PATH/../.profile +else + echo -e "${c_red}Le .profile n'existe pas$c_" + exit 1 +fi + +#source $GPATH/shell/tata.sh || echo "pas trouvé" + +source $GPATH/shell/init.sh +source $GPATH/shell/functions.sh +[[ $1 == "chat" ]] && echo "Bonjours chat" && exit 0 log "X sms_AIDE.sh ($1=phone)" sms_INIT_ACCOUNT "$1" "NOSMS" diff --git a/shell/sms_BILLET.sh b/shell/sms_BILLET.sh index f902841..e05b0c0 100755 --- a/shell/sms_BILLET.sh +++ b/shell/sms_BILLET.sh @@ -101,7 +101,7 @@ then log_history $PHONE "G1BILLET, $TRANSAC, $BILLETPUBKEY" sleep 3 # Fill BILLET with TRANSAC amount - PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$TRANSAC" --output="$BILLETPUBKEY" --comment="G1Billet $NUMBER" -y) + PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$TRANSAC" --output="$BILLETPUBKEY" --comment="G1Billet $NUMBER" -y) if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then # NOTES ARE FILES STORED IN DICEWARE COMPOSED SUBDIR echo "$(date +%Y%m%d)" > "./billets/$bpath/note.creationdate" @@ -136,7 +136,7 @@ then # + G1SMS Commission sleep 2 - COM=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$BILLCOM" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Achat G1Billets" -y) + COM=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$BILLCOM" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Achat G1Billets" -y) # POUR IMPRIMER LES BILLETS! Brancher votre imprimante, configurer cups, activer code lp ;) num=$(date +%Y%m%d) diff --git a/shell/sms_DESTROY.sh b/shell/sms_DESTROY.sh index 4b53d1c..7ca3e2c 100755 --- a/shell/sms_DESTROY.sh +++ b/shell/sms_DESTROY.sh @@ -12,10 +12,10 @@ PHONE="$1" MEMBERUID="$2" TODAY=$(date '+%Y%m%d') -if [[ -f "./wallets/$PHONE/VIREMENTS" ]]; then +if [[ -f "./wallets/PHONE/$PHONE/VIREMENTS" ]]; then # CHECK IF ALL DONE. - log "__SUB:sms_DESTROY.sh: FOUND "./wallets/$PHONE/VIREMENTS" decrypting with Node key" - echo "${GPGPASS}" | gpg -d -q --output "/tmp/VIREMENTS.$PHONE" --yes --pinentry-mode loopback --passphrase-fd 0 "./wallets/$PHONE/VIREMENTS.gpg" + log "__SUB:sms_DESTROY.sh: FOUND "./wallets/PHONE/$PHONE/VIREMENTS" decrypting with Node key" + echo "${GPGPASS}" | gpg -d -q --output "/tmp/VIREMENTS.$PHONE" --yes --pinentry-mode loopback --passphrase-fd 0 "./wallets/PHONE/$PHONE/VIREMENTS.gpg" for next in $(cat /tmp/VIREMENTS.$PHONE | cut -d ' ' -f 1); do if [[ $next -ge $TODAY ]]; then log "__SUB:sms_DESTROY.sh: VIREMENT $next >= $TODAY" @@ -36,9 +36,9 @@ if [[ "$MEMBERUID" == "DON" || "$MEMBERUID" == "" || "$MEMBERUID" == "$MEMBER" ] AMOUNTG1=$(./silkaj/silkaj amount "$PUBKEY") GETLIMIT=$(bc <<< "$AMOUNTG1 - $LIMIT") - PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$GETLIMIT" --output="$MEMRIB" --comment="[G1sms+] Wallet DESTROY $MEMBER $MEMBERUID" -y) + PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$GETLIMIT" --output="$MEMRIB" --comment="[G1sms+] Wallet DESTROY $MEMBER $MEMBERUID" -y) sleep 5 - back=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$LIMIT" --output="$NODEPUB" --comment="[G1sms+] Wallet DESTROY Send $LIMIT To NODE" -y) + back=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$LIMIT" --output="$NODEPUB" --comment="[G1sms+] Wallet DESTROY Send $LIMIT To NODE" -y) if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" && "$PAY" != "" && "$(echo $back | cut -d '|' -f 1)" != "KO" ]]; then # DESTROY FILESYSTEM AND G1sms WALLET SWARM REFERENCE @@ -54,8 +54,8 @@ $ADMINPSEUDO @ $NODEUIDNA $back" sms_SEND "$PHONE" "$mess" - rm -Rf ./wallets/$PHONE; - rm -Rf ./wallets_swarm/$PHONE; + rm -Rf ./wallets/PHONE/$PHONE; + rm -Rf ./wallets_swarm/PHONE/$HASHLINK; cents=$(echo $(bc -l <<< "scale=0; $GETLIMIT * 100") | cut -d '.' -f 1) move_g1cents "$PHONE" "$MEMRIB" "$cents" cents=$(echo $(bc -l <<< "scale=0; $LIMIT * 100") | cut -d '.' -f 1) diff --git a/shell/sms_EMAIL.sh b/shell/sms_EMAIL.sh index 9df63c6..959bd0f 100755 --- a/shell/sms_EMAIL.sh +++ b/shell/sms_EMAIL.sh @@ -16,7 +16,7 @@ log "__SUB:sms_EMAIL.sh.sh: START ($1=phone, $2=mail)" phone="$1" mail="$2" -MAILFILE="./wallets/$phone/$phone.email" # Contains the member EMAIL (Send BILLET) +MAILFILE="./wallets/PHONE/$phone/_email" # Contains the member EMAIL (Send BILLET) # Initialise PHONE, PIN, PUBKEY, UNIT ... sms_INIT_ACCOUNT "$phone" "NOSMS" @@ -27,7 +27,10 @@ Envoyez N suivi de votre pseudo membre (en respectant Majuscule et minuscule)." fi if [[ "$mail" != "" ]]; then + # STORE EMAIL AND NODE CYPHER IT BEFORE PUSH TO IPFS echo "$mail" > "$MAILFILE" + ./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "$MAILFILE" -o "$MAILFILE.node.crypt" + echo "" > "$MAILFILE" log "__SUB:sms_EMAIL.sh.sh: EMAIL $MEMBER ($PHONE) NOUVEAU: $mail... Publishing to IPFS" ipfs_node_wallets_add else diff --git a/shell/sms_G1TAG.sh b/shell/sms_G1TAG.sh index 4d4d528..8cfb174 100755 --- a/shell/sms_G1TAG.sh +++ b/shell/sms_G1TAG.sh @@ -79,8 +79,8 @@ fi ##### IS G1DAB NODE? if [[ ! $PASSENGER && ! $G1DAB ]]; then - if [[ -f ./wallets/$PHONE/ipfsid.G1TAGNODE ]]; then - DABnode=$(cat ./wallets/$PHONE/ipfsid.G1TAGNODE) + if [[ -f ./wallets/PHONE/$PHONE/MASTERPHONE.ipfsid ]]; then + DABnode=$(cat ./wallets/PHONE/$PHONE/MASTERPHONE.ipfsid) if [[ "$DABnode" == "$IPFSNODEID" ]]; then sms_ERROR "$PHONE" "IMPRIMANTE G1Tag non détectée!! Choisissez un autre G1Dab... $spot" log "__SUB:sms_G1TAG.sh: IMPRIMANTE G1Tag non détectée!!" @@ -100,7 +100,7 @@ fi ########################################### # PAY VIR + PERCENT G1 ML=$(bc -l <<< "scale=2; $VIR + $PERCENT") -PAY=$(./shell/timeout.sh -t 29 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$ML" --output="$NODE_G1PUBKEY" --comment="[G1sms+] ACHAT $3 G1Tag(s) - $2 $UNIT" -y) +PAY=$(./shell/timeout.sh -t 29 ./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$ML" --output="$NODE_G1PUBKEY" --comment="[G1sms+] ACHAT $3 G1Tag(s) - $2 $UNIT" -y) if [[ "$PAY" == "" || "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then new=$(./shell/checknodes.sh "BAN") sms_ERROR "$PHONE" "Il est survenu un problème lors de votre virement: $PAY / Silkaj: $new"; @@ -217,8 +217,8 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash composite -compose Over -resize 133% -gravity West "./TAG/${RR}/TAG_READ.png" "./shell/g1tag.png" "./TAG/${RR}/${RR}.png" composite -compose Over -gravity SouthEast "./TAG/${RR}/TAG_WRITE.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png" # ADD Avatar in the Center -# if [[ $(file "./wallets/$PHONE/$PHONE.avatar.png" | grep 'PNG') ]]; then -# composite -compose Over -resize 150% -gravity Center "./wallets/$PHONE/$PHONE.avatar.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png" +# if [[ $(file "./wallets/PHONE/$PHONE/_avatar.png" | grep 'PNG') ]]; then +# composite -compose Over -resize 150% -gravity Center "./wallets/PHONE/$PHONE/_avatar.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png" # else # composite -compose Over -resize 100% -gravity Center "./shell/G1Anar.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png" # fi @@ -234,22 +234,23 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash # ROTATION (FIXE AVATAR & CHIFFRE)? # convert "./TAG/${RR}/${RR}.png" -rotate -180 "./TAG/${RR}/${RR}.png" # QL-700 PRINT PREPARE - if [[ -f "./wallets/$PHONE/ipfsid.G1TAGNODE" ]]; then - destnode=$(cat "./wallets/$PHONE/ipfsid.G1TAGNODE") + if [[ -f "./wallets/PHONE/$PHONE/MASTERPHONE.ipfsid" ]]; then + destnode=$(cat "./wallets/PHONE/$PHONE/MASTERPHONE.ipfsid") if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then log "__SUB:sms_G1TAG.sh: Local PRINT ${RR} # ipfs ls /ipns/${J}" brother_ql_create --model QL-700 "./TAG/${RR}/${RR}.png" --label-size 62 > "./TAG/${RR}/${RR}.bin" brother_ql_print "./TAG/${RR}/${RR}.bin" /dev/usb/lp0 else - # PRINT ON ANOTHER G1Dab. Send files to G1Tag Printer TODO: Could use DESTNODEPUB instead of NODE_G1PUBKEY ? - log "__SUB:sms_G1TAG.sh: Remote PRINT :: ./wallets/.$destnode/PRINT/${RR}.bin " + # PRINT ON ANOTHER G1Dab. Send files to G1Tag Printer Use .$destnode/_pub CRYPTINGKEY ? + CRYPTINGKEY=$(cat ./wallets_swarm/.$destnode/_pub) + log "__SUB:sms_G1TAG.sh: Remote PRINT :: ./wallets/.$destnode/PRINT/${RR}.png.node.crypt ($CRYPTINGKEY)" mkdir -p "./wallets/.$destnode/PRINT/" - ./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./TAG/${RR}/${RR}.png" -o "./wallets/.$destnode/PRINT/${RR}.bin" + ./shell/natools.py encrypt -p $CRYPTINGKEY -i "./TAG/${RR}/${RR}.png" -o "./wallets/.$destnode/PRINT/${RR}.png.node.crypt" fi else # log "__SUB:sms_G1TAG.sh: Becoming default PRINTER :: $IPFSNODEID" - echo "$IPFSNODEID" > "./wallets/$PHONE/ipfsid.G1TAGNODE" + echo "$IPFSNODEID" > "./wallets/PHONE/$PHONE/ipfsid.G1TAGNODE" brother_ql_create --model QL-700 "./TAG/${RR}/${RR}.png" --label-size 62 > "./TAG/${RR}/${RR}.bin" brother_ql_print "./TAG/${RR}/${RR}.bin" /dev/usb/lp0 destnode="$IPFSNODEID" @@ -259,14 +260,14 @@ done if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then # PRINT $PHONE WALLET PUBKEY - qrencode -s 5 -o "/tmp/G1PubQR.$PHONE.png" "$(cat ./wallets/$PHONE/$PHONE.pub)" + qrencode -s 5 -o "/tmp/G1PubQR.$PHONE.png" "$(cat ./wallets/PHONE/$PHONE/_pub)" composite -compose Over -gravity West "/tmp/G1PubQR.$PHONE.png" "./shell/g1tag.png" "/tmp/G1PubQR.$PHONE.png" - if [[ $(file "./wallets/$PHONE/$PHONE.avatar.png" | grep 'PNG') ]]; then - composite -compose Over -gravity Center "./wallets/$PHONE/$PHONE.avatar.png" "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png" + if [[ $(file "./wallets/PHONE/$PHONE/_avatar.png" | grep 'PNG') ]]; then + composite -compose Over -gravity Center "./wallets/PHONE/$PHONE/_avatar.png" "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png" fi - if [[ -f ./wallets/$PHONE/$PHONE.uidrib ]]; then - qrencode -s 6 -o "/tmp/G1MemQR.$PHONE.png" "$(cat ./wallets/$PHONE/$PHONE.uidrib)"; + if [[ -f ./wallets/PHONE/$PHONE/_uidrib ]]; then + qrencode -s 6 -o "/tmp/G1MemQR.$PHONE.png" "$(cat ./wallets/PHONE/$PHONE/_uidrib)"; composite -compose Over -gravity SouthEast "/tmp/G1MemQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png" && rm /tmp/G1MemQR.$PHONE.png fi diff --git a/shell/sms_PAY.sh b/shell/sms_PAY.sh index f2add6a..cbad7af 100755 --- a/shell/sms_PAY.sh +++ b/shell/sms_PAY.sh @@ -14,6 +14,7 @@ PHONEDEST="$2" # Initialise PHONE, PIN, PUBKEY, UNIT sms_INIT_ACCOUNT "$phone" "NOSMS" pin=$PIN +uidna=$UIDNA if [[ $UNKNOWN == "unknown" ]]; then sms_ERROR "$phone" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer." exit @@ -36,12 +37,13 @@ fi # Add COUNTRY code to PHONEDEST + PHONEDEST INIT PHONEDEST="$COUNTRY${PHONEDEST:1:10}" - +HASHLINKDEST=$(echo -n $PHONEDEST | sha256sum | cut -d ' ' -f 1) + # CHECK if PHONEDEST have an account in IPFS G1sms+ SWARM -if [[ -f "./wallets_swarm/$PHONEDEST/$PHONEDEST.pub" ]] +if [[ -f "./wallets_swarm/PHONE/$HASHLINKDEST/_pub" ]] then - PUBKEYDEST=$(cat "./wallets_swarm/$PHONEDEST/$PHONEDEST.pub") - UNITDEST=$(cat "./wallets_swarm/$PHONEDEST/$PHONEDEST.unit") + PUBKEYDEST=$(cat "./wallets_swarm/PHONE/$HASHLINKDEST/_pub") + UNITDEST=$(cat "./wallets_swarm/PHONE/$HASHLINKDEST/_unit") log "__SUB:sms_PAY.sh: PUBKEYDEST found in swarn... $PUBKEYDEST" else # NO, then create NEW Wallet @@ -53,8 +55,8 @@ else fi # Payement -log "./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST"" -PAY=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST" --comment="[G1sms+] PAY $AMOUNT $UNIT" -y) +log "./silkaj/silkaj transaction --auth-scrypt -salt="$uidna" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST"" +PAY=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$uidna" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST" --comment="[G1sms+] PAY $AMOUNT $UNIT" -y) if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then sms_ERROR "$phone" "PIN : $PAY ? Voyez vous votre code secret: $pin? NON, Reinitaliser Compte. Envoyer: RAZ @@ -70,8 +72,8 @@ fi sleep 2 # + G1SMS Commission -log "./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY"" -COM=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY" --comment="[G1sms+] P Commission" -y) +log "./silkaj/silkaj transaction --auth-scrypt -salt="$uidna" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY"" +COM=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$uidna" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY" --comment="[G1sms+] P Commission" -y) if [[ "$(echo $COM | cut -d '|' -f 1)" == "KO" || "$COM" == "" ]]; then sms_ERROR "$phone" "Problème de bourrage blockchain : $COM"; log "__SUB:sms_PAY.sh: Problème de payement avec silkaj : $COM" diff --git a/shell/sms_REC.sh b/shell/sms_REC.sh index 911e01d..01dc2d6 100755 --- a/shell/sms_REC.sh +++ b/shell/sms_REC.sh @@ -41,7 +41,7 @@ esac ########################################################### # Initialise PHONE, PIN, PUBKEY, UNIT sms_INIT_ACCOUNT "$PHONE" "NOSMS" -if [[ $MEMBER == "" ]]; then MEMBER=$UIDNA; fi +[[ $MEMBER == "" ]] && MEMBER=$UIDNA # Wallet self UIDNA?? ########################################################### # CHECK FOR ERRORS if [[ $UNKNOWN == "unknown" ]]; then @@ -79,20 +79,20 @@ else log "__SUB:sms_REC.sh: SEARCH $VIRDEST related wallet!!! $DESTRIB " DESTMEM="$VIRDEST" # SEARCH IN WALLETS - LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidname | tail -n 1 | cut -f 3 -d '/') - if [[ "$LOCAL" == "" ]]; then LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi - if [[ "$LOCAL" != "" ]]; then - # LOCAL G1sms account - DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub) - DESTPHONE=$LOCAL - log "__SUB:sms_REC.sh: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)" + LOCALPHONE=$(grep -Rwl "$DESTMEM" ./wallets/PHONE/*/_uidname | tail -n 1 | cut -f 4 -d '/') + [[ ! $LOCALPHONE ]] && LOCALPHONE=$(grep -Rwl "$DESTMEM" ./wallets/PHONE/*/_uidna | tail -n 1 | cut -f 4 -d '/') + if [[ "$LOCALPHONE" != "" ]]; then + # LOCALPHONE G1sms account + DESTRIB=$(cat ./wallets/PHONE/$LOCALPHONE/_pub) + DESTPHONE=$LOCALPHONE + log "__SUB:sms_REC.sh: FOUND LOCALPHONE ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCALPHONE)" else # SEARCH IN WALLETS SWARM (MEMBER THEN UIDNA) - INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidname | tail -n 1 | cut -f 3 -d '/') - if [[ "$INSWARM" == "" ]]; then INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi + INSWARMHASH=$(grep -Rwl "$DESTMEM" ./wallets_swarm/PHONE/*/_uidname | tail -n 1 | cut -f 4 -d '/') + [[ ! $INSWARMHASH ]] && INSWARMHASH=$(grep -Rwl "$DESTMEM" ./wallets_swarm/PHONE/*/_uidna | tail -n 1 | cut -f 4 -d '/') if [[ "$INSWARM" != "" ]]; then - REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms) - DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.pub) + REMOTENODE=$(cat ./wallets_swarm/PHONE/$INSWARM/MASTERPHONE.sms) + DESTRIB=$(cat ./wallets_swarm/PHONE/$INSWARM/_pub) DESTPHONE=$INSWARM log "__SUB:sms_REC.sh: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($INSWARM)" else @@ -106,7 +106,7 @@ fi # ADD DATES TO VIREMENTS if [[ "$DESTRIB" != "" ]]; then log "__SUB:sms_REC.sh: TRAITEMENT DU VIREMENT DE $AMOUNT $UNIT = 1ER VIREMENT de $VIR G1 vers $VIRDEST ($DESTRIB) $TIME FOIS. OK..." - PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] REC 1/$TIME ($PERIOD)" -y) + PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] REC 1/$TIME ($PERIOD)" -y) if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then new=$(./shell/checknodes.sh "BAN") sms_ERROR "$PHONE" "Problème de payement avec silkaj (changement de serveur $new): $PAY"; diff --git a/shell/sms_VIR.sh b/shell/sms_VIR.sh index 5847be3..c994db1 100755 --- a/shell/sms_VIR.sh +++ b/shell/sms_VIR.sh @@ -73,7 +73,7 @@ else fi if [[ "$DESTRIB" != "" ]]; then - PAY=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $VIR G1" -y) + PAY=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $VIR G1" -y) if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" && "$PAY" != "" ]]; then log "__SUB:sms_VIR.sh: VIREMENT VERS $DESTMEM OK" mess="[G1sms+] $MEMBER diff --git a/shell/sms_WHERE.sh b/shell/sms_WHERE.sh index b998159..adb22c7 100755 --- a/shell/sms_WHERE.sh +++ b/shell/sms_WHERE.sh @@ -21,19 +21,19 @@ Envoyez N pour créer votre portefeuille G1sms" fi if [[ "$askeduidna" == "" ]]; then #SELF - if [[ -f "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna" ]]; then - nodeuidnafile="./wallets/.$IPFSNODEID/$IPFSNODEID.uidna" + if [[ -f "./wallets/.$IPFSNODEID/_uidna" ]]; then + nodeuidnafile="./wallets/.$IPFSNODEID/_uidna" uidna=$(cat $nodeuidnafile) fi else - nodeuidnafile=$(grep -Rwl "$askeduidna" ./wallets_swarm/.*/*.uidna) + nodeuidnafile=$(grep -Rwl "$askeduidna" ./wallets_swarm/.Qm*/_uidna | tail -n 1) uidna=$(cat $nodeuidnafile) fi if [[ -f $nodeuidnafile && "$uidna" != "" ]]; then ipfsnodeid=$(echo $nodeuidnafile | cut -d '/' -f 3 | cut -d '.' -f 2 ) - echo $uidna > ./wallets/$PHONE/uidna.G1TAGNODE - echo $ipfsnodeid > ./wallets/$PHONE/ipfsid.G1TAGNODE + echo $uidna > ./wallets/PHONE/$PHONE/uidna.G1TAGNODE + echo $ipfsnodeid > ./wallets/PHONE/$PHONE/ipfsid.G1TAGNODE log "__SUB:sms_WHERE.sh: Distributeur de G1Tag $uidna : $ipfsnodeid " I=$(ipfs_node_wallets_add) log_history $PHONE "G1TagNode, $uidna, $ipfsnodeid" @@ -47,7 +47,7 @@ fi mess="[G1sms+] $MEMBER Votre distributeur de G1Tag par défaut est $uidna ($ipfsnodeid), situé: -$(cat ./wallets_swarm/.$ipfsnodeid/$ipfsnodeid.where)" +$(cat ./wallets_swarm/.$ipfsnodeid/_where)" sms_SEND "$PHONE" "$mess" diff --git a/shell/tata.sh b/shell/tata.sh new file mode 100755 index 0000000..434773e --- /dev/null +++ b/shell/tata.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo yoyoyo diff --git a/shell/test.sh b/shell/test.sh new file mode 100755 index 0000000..c987554 --- /dev/null +++ b/shell/test.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +pwd=$(pwd) + +if [[ -f $MY_PATH/.profile ]]; then + source $MY_PATH/.profile +elif [[ -f $MY_PATH/../.profile ]]; then + source $MY_PATH/../.profile +else + echo -e "${c_red}Le .profile n'existe pas$c_" + exit 1 +fi + +source $GPATH/shell/tata.sh || echo "pas trouvé" + +echo "je suis là: $GPATH/shell !" + +#$GPATH/shell/sms_AIDE.sh $1 + +exit 0 diff --git a/silkaj/src/constants.py b/silkaj/src/constants.py index b49f415..3612867 100644 --- a/silkaj/src/constants.py +++ b/silkaj/src/constants.py @@ -2,4 +2,4 @@ SILKAJ_VERSION = "silkaj 0.5.0" NO_MATCHING_ID = "No matching identity" G1_SYMBOL = "Ğ1" GTEST_SYMBOL = "ĞTest" -G1_DEFAULT_ENDPOINT = "duniter.moul.re", "443" +G1_DEFAULT_ENDPOINT = "duniter-g1.p2p.legal", "443"