g1sms cleanup

This commit is contained in:
qo-op 2020-05-05 04:41:17 +02:00
parent 70d345cd9e
commit 2707cf25c9
22 changed files with 213 additions and 326 deletions

View File

@ -16,7 +16,7 @@ echo "COMMENTAIRES?"
read COMMENT
# CREATE CURRENT NODE "SWARM_CODE_MASTER" ipns key
if [[ ! -f "/home/$YOU/.ipfs/keystore/SWARM_CODE_MASTER" ]]; then
if [[ ! -f "~/.ipfs/keystore/SWARM_CODE_MASTER" ]]; then
echo "Vous ne possédez pas la clef SWARM_CODE_MASTER de ce CODE..."
# echo "FORK ? su $YOU -c \"ipfs key gen -t rsa -s 2048 SWARM_CODE_MASTER\""
echo "Si vous souhaiter participer au CODE, contactez https://g1sms.fr "
@ -25,7 +25,7 @@ if [[ ! -f "/home/$YOU/.ipfs/keystore/SWARM_CODE_MASTER" ]]; then
else
# Only "SWARM_CODE_MASTER" key owner(s) can update & publish this _official _chain
#rm "./$dir/_publishkey.pgp" # TEMP for file name correction...
cat "/home/$YOU/.ipfs/keystore/SWARM_CODE_MASTER" | base64 | gpg -q --output "./$dir/_publishkey.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "/home/$YOU/.ipfs/keystore/SWARM_CODE_MASTER"
cat "~/.ipfs/keystore/SWARM_CODE_MASTER" | base64 | gpg -q --output "./$dir/_publishkey.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "~/.ipfs/keystore/SWARM_CODE_MASTER"
fi
## Backup $ROOT

View File

@ -20,7 +20,7 @@ for tag in ~/.zen/ipfs/.$IPFSNODEID/TAG/*; do
rm -Rf ./TAG/${tagj}
rm -f ~/.zen/ipfs/.$IPFSNODEID/TAG/${tagj}
rm -f ~/.zen/ipfs_swarm/.$IPFSNODEID/TAG/${tagj}
rm -f /home/$YOU/.ipfs/keystore/${tagj}
rm -f ~/.ipfs/keystore/${tagj}
}
# Refresh G1Tag created by this NODE
@ -59,14 +59,14 @@ for tag in ~/.zen/ipfs/.$IPFSNODEID/TAG/*; do
if [[ $timediff -gt 21600000000000 ]]; then
# GET PUBLISHKEY for that G1TAG
if [[ ! -f /home/$YOU/.ipfs/keystore/${RR} ]]; then
if [[ ! -f ~/.ipfs/keystore/${RR} ]]; then
echo "__SUB:cron_G1TAG_REFRESH.sh: GET PUBLISHKEY for that G1TAG";
su $YOU -c "ipfs get -o /home/$YOU/.ipfs/keystore/${RR}.crypt /ipns/$tagj/TAG_publishkey.MASTER.crypt"
if [[ ! -f /home/$YOU/.ipfs/keystore/${RR}.crypt ]]; then log "__SUB:cron_MINUTE.sh: error getting publishkey"; continue; fi
./natools.py decrypt -k "$NODE_G1AUTHFILE" -i /home/$YOU/.ipfs/keystore/${RR}.crypt -o /home/$YOU/.ipfs/keystore/$RR
rm /home/$YOU/.ipfs/keystore/${RR}.crypt
su $YOU -c "ipfs get -o ~/.ipfs/keystore/${RR}.crypt /ipns/$tagj/TAG_publishkey.MASTER.crypt"
if [[ ! -f ~/.ipfs/keystore/${RR}.crypt ]]; then log "__SUB:cron_MINUTE.sh: error getting publishkey"; continue; fi
./natools.py decrypt -k "$NODE_G1AUTHFILE" -i ~/.ipfs/keystore/${RR}.crypt -o ~/.ipfs/keystore/$RR
rm ~/.ipfs/keystore/${RR}.crypt
fi
echo "__SUB:cron_G1TAG_REFRESH.sh: G1Tag PUBLISHKEY OK : /home/$YOU/.ipfs/keystore/${RR}"
echo "__SUB:cron_G1TAG_REFRESH.sh: G1Tag PUBLISHKEY OK : ~/.ipfs/keystore/${RR}"
echo ${NANODATE} > ./TAG/${RR}/TAG_nanodate
# PUBLISH VERIFIED G1Tag VERSION
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")

View File

@ -19,7 +19,7 @@ log "__SUB:cron_VIR.reccurent.sh: Searching payements to do for $TODAY"
for file in ~/.zen/g1sms_wallets/*/VIREMENTS.gpg ; do
if [[ -f $file ]]; then
log "__SUB:cron_VIR.reccurent.sh: FOUND $file decrypting with Node key"
echo "${GPGPASS}" | gpg -d -q --output "/tmp/VIREMENTS" --yes --pinentry-mode loopback --passphrase-fd 0 "$file"
echo "${IPFSPrivKey}" | gpg -d -q --output "/tmp/VIREMENTS" --yes --pinentry-mode loopback --passphrase-fd 0 "$file"
cat /tmp/VIREMENTS | sort >> /tmp/VIR$TODAY
else
continue
@ -44,13 +44,9 @@ while read line
# 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)
if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then
new=$(./checknodes.sh "BAN")
sms_ERROR "$PHONE" "Il est survenu un problème avec votre virement. Retour silkaj: $PAY ... $new";
else
new=$(./checknodes.sh)
sms_SEND "$PHONE" "$TODAY Virement automatique $REF vers $DESTUID : $PAY (Reste $NB)"
cents=$(echo $(bc -l <<< "scale=0; $VIR * 100") | cut -d '.' -f 1)
move_g1cents "$PHONE" "$DESTRIB" "$cents"
sms_SEND "$PHONE" "$TODAY Virement automatique $REF vers $DESTUID : $PAY (Reste $NB)"
fi
log "__SUB:cron_VIR.reccurent.sh: $TODAY VIR DONE.... Rotation Silkaj : $new "
else
@ -63,7 +59,7 @@ done < /tmp/VIR$TODAY
for virfile in "~/.zen/g1sms_wallets/*/VIREMENTS.gpg"; do
phone=$(echo $virfile | cut -d '/' -f 3)
if [[ "$phone" == "*" ]]; then exit; fi
echo "${GPGPASS}" | gpg -d -q --output "/tmp/$phone.VIREMENTS" --yes --pinentry-mode loopback --passphrase-fd 0 "~/.zen/g1sms_wallets/$phone/VIREMENTS.gpg"
echo "${IPFSPrivKey}" | gpg -d -q --output "/tmp/$phone.VIREMENTS" --yes --pinentry-mode loopback --passphrase-fd 0 "~/.zen/g1sms_wallets/$phone/VIREMENTS.gpg"
nv=0; tot=0;
while read ligne
do virs=(${ligne});

View File

@ -12,7 +12,7 @@ MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
## Récupère les données du profile
[[ -f $MY_PATH/.profile ]] && source $MY_PATH/.profile
source ~/.zen/secret.astroport.key
function sms_SEND () {
# sms_SEND ($1=phone, $2=message)
@ -24,11 +24,7 @@ function sms_SEND () {
gammu-smsd-inject TEXT "$dest" -text "$mess" 1>&2
else
# Send SMS through $dest NODE (TODO: send it like PRINT, TASK, ...)
DESTNODEID=$(cat ~/.zen/g1sms_wallets_swarm/$dest/MASTERPHONE.ipfsid)
log "$dest is managed by NODE: $DESTNODEID)"
mkdir "~/.zen/g1sms_wallets/.$DESTNODEID/SMS"
echo $mess > "~/.zen/g1sms_wallets/.$DESTNODEID/SMS/$dest.sms2send"
I=$(ipfs_node_wallets_add)
# SEARCH FOR HASH in ~/.zen/ipfs_swarm/.Qm*/G1SMS/$hash_dest/)
fi
else
log ">>>>>>>>>>SMS ERROR BAD DESTINATION $dest"
@ -55,7 +51,7 @@ $2"
#################################################################################################################################
function log_history () {
function log_history () { # TODO REMOVE
log "__SUB:log_history: history ($1, $2)"
PHONE="$1"
HISTFILE="./history.$IPFSNODEID.log.csv"
@ -110,18 +106,19 @@ find /tmp -ctime +1 -type f -name "sms_SPAM_*" -exec rm -f '{}' \;
#################################################################################################################################
function ipfs_node_wallets_add (){
##########################
log "TODO ipfs_node_wallets_add"
##########################
IWALLETS=$(su $YOU -c "ipfs add -rHq '~/.zen/g1sms_wallets' | tail -n 1")
# IWALLETS=$(su $YOU -c "ipfs add -rHq '~/.zen/g1sms_wallets' | tail -n 1")
# CHAIN STATE FOR $IPFSNODEID
echo $IWALLETS > ~/.zen/ipfs/.$IPFSNODEID.wallets.chain
log "__SUB:ipfs_node_wallets_add: NEW '~/.zen/g1sms_wallets' HASH ipfs ls $IWALLETS"
# echo $IWALLETS > ~/.zen/ipfs/.$IPFSNODEID.wallets.chain
# log "__SUB:ipfs_node_wallets_add: NEW '~/.zen/g1sms_wallets' HASH ipfs ls $IWALLETS"
# PUBLISH IPNS NODE WALLETS
NODEWALLETS=$(su $YOU -c "ipfs name publish --quieter /ipfs/$IWALLETS")
log "__SUB:ipfs_node_wallets_add: G1smsWallet = ipfs cat /ipns/$NODEWALLETS/$PHONE/$PHONE.g1cents Zen"
# NODEWALLETS=$(su $YOU -c "ipfs name publish --quieter /ipfs/$IWALLETS")
# log "__SUB:ipfs_node_wallets_add: G1smsWallet = ipfs cat /ipns/$NODEWALLETS/$PHONE/$PHONE.g1cents Zen"
echo $IWALLETS
# echo $IWALLETS
}
@ -154,7 +151,7 @@ function sms_uid2key (){
fi
# Search fo duplicate
DUP=$(grep -Rwl "$ASKWALLET" ~/.zen/g1sms_wallets/*/*.uidname | cut -f 3 -d '/')
DUP=$(grep -Rwl "$ASKWALLET" ~/.zen/g1sms_wallets/*/*.uidname | cut -f 6 -d '/')
if [[ "$DUP" != "" && "$DUP" != "$PHONE" ]]; then
sms_SEND "$ADMINPHONE" "ADMIN! INFO: $PHONE prend le même $ASKWALLET, que $DUP"
sms_SEND "$DUP" "Vous devez savoir que $ASKWALLET est associé à un autre téléphone que le votre également!"
@ -164,7 +161,7 @@ function sms_uid2key (){
# FIND ASKWALLET into wallets, wallest_swarm OR duniter (silkaj)
DESTMEM="$VIRDEST"
# SEARCH IN WALLETS
LOCAL=$(grep -Rwl "$ASKWALLET" ~/.zen/g1sms_wallets/*/*.uidna | cut -f 3 -d '/')
LOCAL=$(grep -Rwl "$ASKWALLET" ~/.zen/g1sms_wallets/*/*.uidna | cut -f 6 -d '/')
if [[ "$LOCAL" != "" ]]; then
# LOCAL G1sms account
DESTRIB=$(cat ~/.zen/g1sms_wallets/$LOCAL/$LOCAL.pub)
@ -172,16 +169,18 @@ function sms_uid2key (){
log "__SUB:sms_uid2key: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)"
else
# SEARCH IN WALLETS SWARM
INSWARM=$(grep -Rwl "$ASKWALLET" ~/.zen/g1sms_wallets_swarm/*/*.uidna | cut -f 3 -d '/')
INSWARM=$(grep -Rwl "$ASKWALLET" ~/.zen/ipfs_swarm/.*/*/_uidna | cut -f 6 -d '/' )
MYIPFS=$( echo $INSWARM | cut -f 6 -d '/' )
MYHASH=$( echo $INSWARM | cut -f 7 -d '/' )
if [[ "$INSWARM" != "" ]]; then
REMOTENODE=$(cat ~/.zen/g1sms_wallets_swarm/$INSWARM/MASTERPHONE.sms)
DESTRIB=$(cat ~/.zen/g1sms_wallets_swarm/$INSWARM/$INSWARM.pub)
REMOTENODE=$(cat ~/.zen/ipfs_swarm/$MYIPFS/MASTERPHONE.sms)
DESTRIB=$(cat ~/.zen/ipfs_swarm/$MYHASH/_pub)
DESTPHONE=$INSWARM
log "__SUB:sms_uid2key: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($INSWARM)"
else
# SEARCH WITH SILKAJ
log "__SUB:sms_uid2key: GETTING FROM SILKAJ MEMBER ID"
DESTRIB=$(./silkaj/silkaj id "$ASKWALLET" | grep -w "$ASKWALLET" | awk '{print $2}')
DESTRIB=$(silkaj id "$ASKWALLET" | grep -w "$ASKWALLET" | awk '{print $2}' | tail -n 1)
log "__SUB:sms_uid2key: OUT OFF SWARM MEMBER wallet: $DESTRIB"
# GET CESIUM+ geoPoint DATA (TODO: cron for GCHANGE SMS Alert)
curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.geoPoint' > "~/.zen/g1sms_wallets/$PHONE/$PHONE.uidgeo.json"
@ -194,7 +193,9 @@ function sms_uid2key (){
echo "$DESTRIB" > "$RIBFILE"
echo "$ASKWALLET" > "$NAMEFILE"
log "__SUB:sms_uid2key: NEW EXTERNAL RELATED $DESTRIB / FOR MEMBER OR WALLET = $ASKWALLET - INIT 0.1 TX"
INIT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="0.1" --output=$DESTRIB --comment="[G1sms+] Porte Monnaie $(cat $UIDNAFILE) -> $(cat $NAMEFILE)" -y)
duniter_server=$(./tools/duniter_getnode.sh)
INIT=$(silkaj -p "$duniter_server" -af --file ~/.zen/g1sms_wallets/$PHONE/secret.dunikey tx --output $DESTRIB --amount 0.1 --comment "[G1sms+] Porte Monnaie $(cat $UIDNAFILE) -> $(cat $NAMEFILE)" -y)
log "__SUB:sms_uid2key: INIT = $INIT | Create Connection with related Wallet."
log_history "$PHONE" "MEMBER, $ASKWALLET"
sms_SEND "$ADMINPHONE" "ADMIN! LOG: $PHONE Nouveau compte lié $UIDNA -- $ASKWALLET ($INIT)"
@ -230,14 +231,13 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
GEOFILE="~/.zen/g1sms_wallets/$PHONE/$PHONE.uidgeo.json" # Contains the member GeoPoint from member Cesium+ related to wallet
RECFILE="~/.zen/g1sms_wallets/$PHONE/VIREMENTS" # File showing recurrent payements are left to be done with this G1sms Wallet
GPGRECFILE="~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg" # Cypher file with GPGPASS (Node .Identity.PrivKey)
GPGRECFILE="~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg" # Cypher file with IPFSPrivKey (Node .Identity.PrivKey)
G1COUNTFILE="~/.zen/g1sms_wallets/$PHONE/$PHONE.g1cents" # Last sms_COUNT.sh call value
CHAINFILE="~/.zen/g1sms_wallets/$PHONE/$PHONE.chain" # Contains wallet last IPFS hash before ZEN value change
DABUIDF="~/.zen/g1sms_wallets/$PHONE/uidna.G1TAGNODE" # Contains G1Dab Name
# GET CURRENT NODE UIDNA (default DABUID)
NODEUIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/$IPFSNODEID.uidna")
[[ $NODEUIDNA == "" ]] && NODEUIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna")
NODEUIDNA=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)
######################################################################
# (NO PIN) = FIRST ACCOUNT: Create wallet
if [ ! -f "$PINFILE" ]; then
@ -245,21 +245,6 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
if [[ $2 == "NOSMS" ]]; then UNKNOWN="unknown"; return; fi
#######################
# Create Account Files
#######################
mkdir -p "~/.zen/g1sms_wallets/$PHONE/"
PIN=$(./diceware.sh | xargs)
python3 $MY_PATH/tools/key_create_dunikey.py "$PHONE" "$PIN" ## Copy PubSec file to /tmp/secret.dunikey
PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$PHONE" -password="$PIN")
# BACKUP authfile available to authfile or PIN owner (DOUBLON AVEC PIN) TEST
log "__SUB:sms_INIT_ACCOUNT: ./natools.py encrypt -p $PUBKEY -i ""./authfile"" -o ""$AUTHCRYPTFILE"""
./natools.py encrypt -p $NODE_G1PUBKEY -i "./authfile" -o "$AUTHCRYPTFILE"
rm -f ./authfile
log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE $PIN : $PUBKEY"
#######################
# GIVE NAME TO WALLET
#######################
# 4 derniers chiffres du numéro de téléphone
@ -267,28 +252,42 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
# No UIDNA yet. Create new
UIDNA=$(./diceware.sh 1 | xargs)
# Check if already existing among all swarm wallets
while [[ $(grep -Rwl $UIDNA$TAIL ~/.zen/g1sms_wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./diceware.sh 1 | xargs); done
echo "$UIDNA$TAIL" > "$UIDNAFILE"
while [[ $(grep -Rwl "$UIDNA$TAIL" ~/.zen/ipfs_swarm/.*/G1*/_uidna) ]]; do UIDNA=$(./diceware.sh 1 | xargs); done
UIDNA="$UIDNA$TAIL"
echo "$UIDNA" > "$UIDNAFILE"
#######################
# Create Account Files
#######################
mkdir -p "~/.zen/g1sms_wallets/$PHONE/"
PIN=$(./diceware.sh | xargs)
python3 ./tools/key_create_dunikey.py "$UIDNA" "$PIN" ## Copy PubSec file to /tmp/secret.dunikey
mv /tmp/secret.dunikey ~/.zen/g1sms_wallets/$PHONE/
PUBKEY=$(cat ~/.zen/g1sms_wallets/$PHONE/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE = $UIDNA $PIN : $PUBKEY"
#######################
# ACTIVATE G1SMS WALLET
#######################
# log "$NODE_G1AUTHFILE $PUBKEY THIRD_PARTY_MANAGER:$NODE_G1PUBKEY"
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$NODE_G1AUTHFILE" --amount=3.24 --output=$PUBKEY --comment="[G1sms+] $UIDNA$TAIL 3RD:$NODE_G1PUBKEY " -y)
duniter_server=$(./tools/duniter_getnode.sh)
TX_IN=$(silkaj -p "$duniter_server" -af --file ~/.ssb/secret.dunikey tx --output $PUBKEY --amount 3.24 --comment "[G1sms+] $UIDNA$TAIL 3RD:$NODE_G1PUBKEY" -y)
log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX IN: $TX_IN"
sleep 2
TX_OUT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount=0.1 --output=$NODE_G1PUBKEY --comment="[G1sms+] $UIDNA$TAIL 3RD:$NODE_G1PUBKEY:ACK" -y)
TX_OUT=$(silkaj -p "$duniter_server" -af --file ~/.zen/g1sms_wallets/$PHONE/secret.dunikey tx --output $NODE_G1PUBKEY --amount 0.1 --comment "[G1sms+] $UIDNA$TAIL 3RD:$NODE_G1PUBKEY:ACK" -y)
log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX OUT: $TX_OUT"
################
# GPG cypher PIN (ONLY CREATOR NODE CAN ACCESS IT !)
################
echo "$PIN" > "$PINFILE"
echo "${GPGPASS}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE"
echo "${IPFSPrivKey}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE"
PIN=$(cat "$PINFILE" | xargs)
[[ "$PIN" != "" ]] && echo "" > "$PINFILE" || log "SYSTEM ERROR :: PIN EMPTY !!! GPG???"
echo "114" > "$G1COUNTFILE"
echo "$PUBKEY" > "$PUBKEYFILE"
echo "$COIN" > "$UNITFILE"
echo "$MASTERPHONE" > "$SMSNODE"
@ -303,60 +302,24 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
# PUBLISH G1sms+ WALLET PROPERTIES MAIN PROCESS
#################################################
######################################################################
if [[ ! -f "$GPGPINFILE" ]]
then
# ------------8<------------------
# WALLET MIGRATION -> CRYPT PIN (For Old G1sms clear PIN WALLETs...)
# ADD NEW PARAMS TO WALLET
#######################
# 4 derniers chiffres du numéro de téléphone
echo "$MASTERPHONE" > "$SMSNODE"
TAIL=${PHONE:8:4}
# No UIDNA yet. Create new
UIDNA=$(./diceware.sh 1 | xargs)
# Check if already existing among all swarm wallets
while [[ $(grep -Rwl $UIDNA$TAIL ~/.zen/g1sms_wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./diceware.sh 1 | xargs); done
echo "$UIDNA$TAIL" > "$UIDNAFILE"
log "__SUB:sms_INIT_ACCOUNT: Déchiffrage PGP PIN..."
# GPG decypher PIN
# TODO make decypher less stress on filesystem, use /tmp and ramdisk
echo "${IPFSPrivKey}" | gpg -d -q --output "$PINFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGPINFILE"
PIN=$(cat "$PINFILE" | xargs)
[[ "$PIN" == "" && -f "$PINFILE.$NODE_UIDNA.crypt" ]] && ./natools.py decrypt -k "$NODE_G1AUTHFILE" -i "$PINFILE.$NODE_UIDNA.crypt" -o "$PINFILE" && PIN=$(cat "$PINFILE");
[[ "$PIN" != "" ]] && echo "" > "$PINFILE" || log "SYSTEM ERROR :: PIN EMPTY !!! GPG???"
PIN=$(cat "$PINFILE" | xargs)
log "__SUB:sms_INIT_ACCOUNT: Old G1sms wallet ;) SECURITY HOLE... Chiffrage PGP du PIN !!!"
echo "${GPGPASS}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE";
./natools.py encrypt -p $NODE_G1PUBKEY -i "$PINFILE" -o "$PINFILE.$NODE_UIDNA.crypt"
else
# ------------>8------------------
log "__SUB:sms_INIT_ACCOUNT: Déchiffrage PGP PIN..."
# GPG decypher PIN
# TODO make decypher less stress on filesystem, use /tmp and ramdisk
echo "${GPGPASS}" | gpg -d -q --output "$PINFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGPINFILE"
PIN=$(cat "$PINFILE" | xargs)
[[ "$PIN" == "" && -f "$PINFILE.$NODE_UIDNA.crypt" ]] && ./natools.py decrypt -k "$NODE_G1AUTHFILE" -i "$PINFILE.$NODE_UIDNA.crypt" -o "$PINFILE" && PIN=$(cat "$PINFILE");
[[ "$PIN" != "" ]] && echo "" > "$PINFILE" || log "SYSTEM ERROR :: PIN EMPTY !!! GPG???"
fi
# CYPHER EMAIL FILE
if [[ ! -f "$GPGMAILFILE" ]]; then
# ------------8<------------------
log "__SUB:sms_INIT_ACCOUNT: NO EMAIL .gpg file, CREATING it"
if [ -f "$MAILFILE" ]; then
MAIL=$(cat "$MAILFILE");
echo "${GPGPASS}" | gpg -q --output "$GPGMAILFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$MAILFILE";
else
MAIL="";
fi
# ------------>8------------------
else
# HIDE EMAIL FILE
if [[ -f "$GPGMAILFILE" ]]; then
log "__SUB:sms_INIT_ACCOUNT: DECODING EMAIL .gpg... "
echo "${GPGPASS}" | gpg -d -q --output "$MAILFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGMAILFILE"
echo "${IPFSPrivKey}" | gpg -d -q --output "$MAILFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGMAILFILE"
MAIL=$(cat "$MAILFILE");
[[ $MAIL == "" && -f "$MAILFILE.node.crypt" ]] && ./natools.py decrypt -k "$NODE_G1AUTHFILE" -i "$MAILFILE.node.crypt" -o "$MAILFILE" && MAIL=$(cat "$MAILFILE");
# EMPTY CLEAR EMAIL FILE
[[ $MAIL != "" ]] && echo "" > "$MAILFILE" || log "SYSTEM ERROR :: MAIL EMPTY !!! GPG???"
fi
# ------------8<------------------
# REMOVE OLD HISTORY FILES
rm -f ~/.zen/g1sms_wallets/$PHONE/$PHONE.hist
# ------------>8------------------
# PUBLISH GLOBAL VARS FROM ACCOUNT FILES
echo $IPFSNODEID > $IPFSNODEIDFILE
@ -385,7 +348,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
esac
log "__SUB:sms_INIT_ACCOUNT: $AMOUNTG1 = $AMOUNT $UNIT"
# LOG # TODO REMOVE PIN LOG!!
# LOG # TODO SECURITY REMOVE PIN LOG!!
log "#####################"
log "PHONE: $PHONE"
log "PIN: $PIN"
@ -406,8 +369,21 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
#################################################################################################################################
function check_account (){
log "__SUB:check_account: SILKAJ...... max 30 sec....."
AMOUNTG1=$(./timeout.sh -t 30 ./silkaj/silkaj amount "$PUBKEY")
silkajQuantitativeAmountPattern='Total\sQuantitative\s+=\s+(.*)\s+Ğ1'
while [ $silkajExitCode -ne 0 ]
do
duniter_server=$(./tools/duniter_getnode.sh)
silkajOutput=$(silkaj -p "${duniter_server}" balance $PUBKEY 2>/dev/null)
silkajExitCode=$?
((i++))
done
if [[ $silkajOutput =~ $silkajQuantitativeAmountPattern ]]
then
AMOUNTG1="${BASH_REMATCH[1]}"
fi
AMOUNTDU=$(bc <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
AMOUNTLOVE=$(bc <<< "$AMOUNTG1 * 100 / $DUFACTOR")
@ -422,24 +398,6 @@ case "$UNIT" in
AMOUNT=$AMOUNTLOVE
;;
esac
G1cents=$(echo "$AMOUNTG1*100" | bc -l | awk '{print int($0)}')
log "__SUB:check_account: $PHONE: $AMOUNTG1 = $AMOUNT $UNIT ($G1cents) - $PUBKEY"
if [[ "$G1cents" != "" ]]; then
NN=$(cat "~/.zen/g1sms_wallets/$PHONE/$PHONE.n")
((NN++))
echo "$NN" > "~/.zen/g1sms_wallets/$PHONE/$PHONE.n"
echo $G1cents > "~/.zen/g1sms_wallets/$PHONE/$PHONE.g1cents"
# REFRESH NODE IPFS wallets & PUBLISH
I=$(ipfs_node_wallets_add)
# Register modification
echo "$I" > "~/.zen/g1sms_wallets/$PHONE/$PHONE.chain"
else
# BAN actual Duniter Node in case of silkaj timeout.
export NEWDUNITER=$(./checknodes.sh 'BAN')
log "__SUB:check_account: !!! SILKAJ IS TOO SLOW !!! => NEW DUNITER SERVER: $NEWDUNITER"
fi
declare -a aaa
aaa=( "$AMOUNTG1" "$AMOUNT" "$UNIT" )
@ -469,8 +427,20 @@ esac
###########################################################
# GET G1sms wallet AMOUNTG1 and CHECK for right balance
log "__SUB:make_accounting: LOCAL $VIR amount for $PHONE : $PUBKEY"
# Try to ask silkaj. If timeout, use SWARM last known $PHONE.g1cents value
AMOUNTG1=$(./timeout.sh -t 30 ./silkaj/silkaj amount "$PUBKEY")
silkajQuantitativeAmountPattern='Total\sQuantitative\s+=\s+(.*)\s+Ğ1'
while [ $silkajExitCode -ne 0 ]
do
duniter_server=$(./tools/duniter_getnode.sh)
silkajOutput=$(silkaj -p "${duniter_server}" balance $PUBKEY 2>/dev/null)
silkajExitCode=$?
((i++))
done
if [[ $silkajOutput =~ $silkajQuantitativeAmountPattern ]]
then
AMOUNTG1="${BASH_REMATCH[1]}"
fi
if [[ "$AMOUNTG1" == "" ]]; then AMOUNTG1=0; fi
# TAX AND MINIMUM WALLET ACCOUNT CALCULATION
PERCENT=0$(bc -l <<< "scale=2; $VIR / $SWARMCOMM")
@ -486,53 +456,6 @@ echo ${myarray[@]}
}
#################################################################################################################################
function move_g1cents (){
# MODIFY $PHONE.g1cents value according to current silkaj
# TODO MAKE ALL SILKAJ TX CALL HERE. OR REMOVE???
# USE TASK COMMUNICATION BETWEEN NODES.
phonesrc=$1
pubkeydest=$2
zenvalue=$3
log "__SUB:move_g1cents: $phonesrc ($zenvalue) -> $pubkeydest :: $G1COUNTFILE ::"
### CHANGE INPUT VALUE ####
curvalue=$(cat ~/.zen/g1sms_wallets/$phonesrc/$phonesrc.g1cents | cut -d '.' -f 1)
newvalue=$(bc -l <<< "$curvalue - $zenvalue")
echo $newvalue > ~/.zen/g1sms_wallets/$phonesrc/$phonesrc.g1cents
log "__SUB:move_g1cents: DEBIT: OK APPLY $curvalue - $zenvalue = $newvalue TO ~/.zen/g1sms_wallets/$phonesrc/$phonesrc.g1cents"
### CHANGE OUTPUT VALUE ####
# TEST IF $dest is a wallets_ G1sms PUBKEY?
winnerphone=$(grep -Rwl "$pubkeydest" ~/.zen/g1sms_wallets_swarm/*/*.pub | cut -d '.' -f 2 | cut -d '/' -f 3)
if [[ $winnerphone ]]; then
# GET INFORMATON ON MANAGER NODE
NODEID=$(cat ~/.zen/g1sms_wallets_swarm/$winnerphone/MASTERPHONE.ipfsid)
if [[ "$NODEID" == "$IPFSNODEID" ]]; then
# ACTUAL NODE IS WALLET MANAGING NODE ;)
curvalue=$(cat ~/.zen/g1sms_wallets/$winnerphone/$winnerphone.g1cents | cut -d '.' -f 1)
newvalue=$(bc -l <<< "$curvalue + $zenvalue")
echo $newvalue > ~/.zen/g1sms_wallets/$winnerphone/$winnerphone.g1cents
log "__SUB:move_g1cents: CREDIT: OK APPLY $curvalue + $zenvalue = $newvalue TO ~/.zen/g1sms_wallets/$winnerphone/$winnerphone.g1cents"
else
# MUST ASK MANAGER NODE TO CORRECT g1cents FOR $winnerphone WALLET
# WRITE TASK TO .$NODEID CHANNEL
mkdir -p ~/.zen/g1sms_wallets/.$NODEID/TASK/
# USE natools with NODEPUB crypt
echo "$zenvalue" > "/tmp/move_g1cents.$winnerphone"
# GET NODE G1sms Wallet PUBKEY
NODEPUB=$(cat ~/.zen/g1sms_wallets_swarm/.$NODEID/$NODEID.pub)
./natools.py encrypt -p $NODEPUB -i "/tmp/move_g1cents.$winnerphone" -o "~/.zen/g1sms_wallets/.$NODEID/TASK/$NANODATE.move_g1cents.$winnerphone.NODEPUB.crypt"
log "__SUB:move_g1cents: CREDIT: WRITE TASK TO ~/.zen/g1sms_wallets/.$NODEID/$NANODATE.move_g1cents.$winnerphone.NODEPUB.crypt "
rm -f /tmp/move_g1cents.$winnerphone
fi
else
log "__SUB:move_g1cents: ERROR: NO $pubkeydest WALLET FOUND"
fi
# UPDATE MY new ./wallet STATUS to SWARM
I=$(ipfs_node_wallets_add)
}
#################################################################################################################################
# Contact database management

View File

@ -1,22 +1,14 @@
#!/bin/bash
##################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# Version: 0.2
# License: GPL (http://www.google.com/search?q=GPL)
##################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi
# Adapter les valeurs au contexte spatio-temporel du NODE G1SMS
function log () {
# log ($1=text)
if [ "$DOLOG" == "YES" ]
then
echo "$PHONE:$1" >> /tmp/g1sms.log
fi
[[ "$DOLOG" == "YES" ]] && echo "$PHONE:$1" >> /tmp/g1sms.log;
}
@ -25,19 +17,20 @@ fn_exists() {
# appended double quote is an ugly trick to make sure we do get a string -- if $1 is not a known command, type does not output anything
[ `type -t $1`"" == 'file' ]
}
# ATOMATIC gammu-smsd-inject desactivation if no gammu is installed on system
if ! fn_exists gammu-smsd-inject; then
log ":p) DESACTIVATION ENVOI DE SMS .............."
function gammu-smsd-inject () {
log "$PHONE: >>> SENDING SMS $4 TO $2 "
}
log ":p) DESACTIVATION ENVOI DE SMS .............."
function gammu-smsd-inject () {
log "$PHONE: >>> SENDING SMS $4 TO $2 "
}
else
export G1SMS="YES"
export G1SMS="YES"
fi
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
cd $GPATH
cd $MY_PATH
##################################################################
# Activate logging to /tmp/g1sms.log (YES/NO)
export DOLOG="YES"
@ -75,10 +68,11 @@ fi
export ADMINPSEUDO="Fred"
##################################################################
# DUNITER/CESIUM+ DEFAULT SERVERS
export DUNITER="https://g1.duniter.org"
export CESIUM="https://g1.data.le-sou.org"
# TODO Use latest Silkaj from "sudo fredp3 install silkaj"
# export SILKAJ="/usr/local/bin/silkaj"
source $GPATH/shell/init_keys.sh
source $MY_PATH/init_keys.sh

View File

@ -19,12 +19,8 @@ NANODATE=$(date -u +%s%N) #1569692075385428020
##################################################################
# G1sms+ Node KEYS (G1wallet, gpg, IPNS)
##################################################################
export GPGPASS=$(cat "/home/$YOU/.ipfs/config" | jq '.Identity.PrivKey' | sed s/\"//g) #"
if [ ! $GPGPASS ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey GPGPASS EMPTY"; exit; fi
# GET SWARM KEY G1sms+ .ipfs/swarm.key
export SWARMKEY=$(cat "/home/$YOU/.ipfs/swarm.key" | tail -n 1)
if [ ! $SWARMKEY ]; then echo "FATAL ERROR:: .ipfs/swarm.key EMPTY"; exit; fi
export IPFSPrivKey=$(cat "~/.ipfs/config" | jq -r '.Identity.PrivKey') #"
if [ ! $IPFSPrivKey ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey IPFSPrivKey EMPTY"; exit; fi
##################################################################
# G1sms+ Swarm KEYS
@ -35,12 +31,8 @@ if [ ! $SWARMKEY ]; then echo "FATAL ERROR:: .ipfs/swarm.key EMPTY"; exit; fi
SWARM_G1PUBKEY=$(cat "${GPATH}/g1sms.pub.key")
SWARM_G1AUTHFILE="${GPATH}/g1sms.priv.key"
# CLEF G1 NODE = CLEF G1 SWARM !!
if [[ ! -e "./g1sms.preoni.pub.key" && -f "./g1sms.priv.key" ]]; then
log "__SUB:initkeys.sh: Linking preoni Keys to SWARM G1 Keys"
ln -s ./g1sms.priv.key ./g1sms.preoni.priv.key
ln -s ./g1sms.pub.key ./g1sms.preoni.pub.key
elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
# ONE TIME GIVE NODE_UIDNA
if [[ ! -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]]; then
# CREATE NODE G1 KEYS AND FILES
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/TASK
################################################
@ -50,60 +42,45 @@ elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
# 4 derniers chiffres du MASTERPHONE + diceware
PRE=${MASTERPHONE:8:4}
ZUID=$(./diceware.sh 1 | xargs)
# Check if already existing among all swarm wallets
while [[ $(grep -Rwl "$PRE$ZUID" ~/.zen/g1sms_wallets_swarm/.*/_uidna) ]]; do ZUID=$(./diceware.sh 1 | xargs); done
# Check if already existing among all swarm wallets G1SSB or G1SMS
while [[ $(grep -Rwl "$PRE$ZUID" ~/.zen/ipfs_swarm/.*/*/_uidna) ]]; do ZUID=$(./diceware.sh 1 | xargs); done
NODE_UIDNA="$PRE$ZUID"
NODE_PIN=$(./diceware.sh | xargs)
NODE_G1PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NODE_UIDNA" -password="$NODE_PIN")
if [[ ! $NODE_G1PUBKEY ]]; then log "PROBLEME CREATION DU WALLET G1 POUR $NODE_UIDNA = $IPFSNODEID"; exit; fi
log "__SUB:initkeys.sh: NODE G1WALLET CESIUM: $NODE_UIDNA / $NODE_PIN CREATED..."
# WRITE NODE_UIDNA
echo "$NODE_UIDNA" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna" ################# _uidna
############ SYSTEM MODIFY hosts & hostname ################
[[ -f ~/.zen/secret.astroport.key ]] && echo "NODE_UIDNA=$NODE_UIDNA" >> ~/.zen/secret.astroport.key
source ~/.zen/secret.astroport.key
# WRITE NODE_UIDNA
echo "$NODE_UIDNA" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ####### _uidna
echo $IPFSNODEID > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ipfs.id ####### _ipfs.id
echo $NANODATE > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_nanodate ####### _nanodate
############ If sudo without password activated (Raspbian)
# SYSTEM MODIFY hosts & hostname ###########################
# WRITE NODE uidna NAME TO /etc/hosts & .Qm*/_uidna file
echo "127.0.0.101 $NODE_UIDNA" >> "/etc/hosts"
echo $NODE_UIDNA > "/etc/hostname"
[[ $USER == "pi" ]] && sudo echo "127.0.0.101 $NODE_UIDNA" >> /etc/hosts
[[ $USER == "pi" ]] && sudo echo "$NODE_UIDNA" > /etc/hostname
############################################################
# BACKUP AUTHFILE FOR FOR SWARM USE (TODO: Refine Swarm, Node access): GIVES SMARM WITHDRAW ACTION
./natools.py encrypt -p $SWARM_G1PUBKEY -i "./authfile" -o "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_authfile.swarm.crypt"
# TODO rewrite AUTO BACKUP / RESTORE
# tools/natools.py encrypt -p $SWARM_G1PUBKEY -i "./authfile" -o "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_authfile.swarm.crypt"
echo $NODE_G1PUBKEY > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pub" ################# _pub
echo $IPFSNODEID > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ipfsid" ################# _ipfsid
log "__SUB:initkeys.sh: [ADMIN] G1sms+ CREATE G1WALLET FOR: $IPFSNODEID: _pub = $NODE_G1PUBKEY "
# BACKUP $IPFSNODEID config ################# _ipfsconfig.swarm.crypt : GIVES SMARM NODE RESTORE ACTION
./natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/config" -o "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ipfsconfig.swarm.crypt"
log "__SUB:initkeys.sh: [ADMIN] BACKUP IPFS NODE CONFIG to ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ipfsconfig.swarm.crypt"
# Cyper & Empty PIN
echo "${NODE_PIN}" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin" ################# _pin / _pin.node.crypt / _pin.gpg
./natools.py encrypt -p $NODE_G1PUBKEY -i "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin" -o "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin.node.crypt"
echo "${GPGPASS}" | gpg -q --output "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin"
echo "" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin"
echo "314" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1cents" ################# _g1cents
echo $NANODATE > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_nanodate" ################# _nanodate
# SILKAJ INIT G1 NODE WALLET
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$SWARM_G1AUTHFILE" --amount=3.24 --output=$NODE_G1PUBKEY --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $NODE_UIDNA $IPFSNODEID" -y)
TX_OUT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$NODE_UIDNA" -password="$NODE_PIN" --amount=0.1 --output=$SWARM_G1PUBKEY --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $NODE_UIDNA $IPFSNODEID:ACK" -y)
# SILKAJ INIT G1 NODE WALLET TODO REWRITE silkaj call
# TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$SWARM_G1AUTHFILE" --amount=3.24 --output=$NODE_G1PUBKEY --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $NODE_UIDNA $IPFSNODEID" -y)
# TX_OUT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$NODE_UIDNA" -password="$NODE_PIN" --amount=0.1 --output=$SWARM_G1PUBKEY --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $NODE_UIDNA $IPFSNODEID:ACK" -y)
log "__SUB:initkeys.sh: [ADMIN] NODE G1sms+ $NODE_UIDNA : ls ~/.zen/ipfs/.$IPFSNODEID"
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "[ADMIN] G1sms+ NODE $NODE_UIDNA ($IPFSNODEID)" 1>&2
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "$NODE_G1PUBKEY" 1>&2
# CREATE preoni FILES
mv ./authfile ./g1sms.preoni.priv.key
echo $NODE_G1PUBKEY > ./g1sms.preoni.pub.key
fi
source ~/.zen/secret.astroport.key
NODE_UIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna")
## INIT NODE G1 PUB & PRIV KEY
NODE_G1PUBKEY=$(cat "${GPATH}/g1sms.preoni.pub.key")
NODE_G1PUBKEY=$ZENG1
NODE_G1AUTHFILE="${GPATH}/g1sms.preoni.priv.key"
##########################################################
@ -113,8 +90,9 @@ if [[ -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_nanodate ]]; then
timediff=$( echo "${NANODATE} - ${last}" | bc -l )
# NODE TIME SYNC 600 milliards de nanosecondes = 600 s = 10 mn
if [[ $timediff -gt 600000000000 ]]; then
# RUN & LOG ntpdate
log "__SUB:ntpdate pool.ntp.org: $timediff $(ntpdate pool.ntp.org)"
# TODO RUN & LOG ntpdate
#ntpdate pool.ntp.org
#log "__SUB:ntpdate pool.ntp.org: $timediff $(ntpdate pool.ntp.org)"
export NANODATE=$(date -u +%s%N)
fi
echo $NANODATE > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_nanodate
@ -134,15 +112,7 @@ fi
## IS THERE USB PRINTER CONNECTED?
if [[ -e "/dev/usb/lp0" ]]; then
log "G1CORE: IMPRESSION G1Tag ACTIF .............."
echo $ADRESSE > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_where"
fi
## IS THERE SERIAL QR CODE READER CONNECTED?
if [[ -e "/dev/ttyACM0" ]]; then
log "G1CORE: SCAN G1Tag ACTIF .............."
export G1TX="YES"
echo "/dev/ttyACM0" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_scan"
else
if [ -f "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_scan" ]; then rm -f "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_scan"; fi
PRINT=true
# echo $ADRESSE > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_where"
fi

View File

@ -4,7 +4,7 @@
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# TODO: Before June 2020: Get "./billets/$bpath/note.authfile.GPGPASS.gpg" for automatic Payback
# TODO: Before June 2020: Get "./billets/$bpath/note.authfile.IPFSPrivKey.gpg" for automatic Payback
# Search for old G1Billets for final CHK : Forget & Transfer G1 ?
source ./init.sh
source ./functions.sh

View File

@ -1,5 +1,22 @@
#!/usr/bin/env python3
"""
CopyLeft 2020 Pascal Engélibert <tuxmain@zettascript.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import os, sys, duniterpy.key, libnacl.sign
def getargv(arg:str, default:str="", n:int=1, args:list=sys.argv) -> str:
@ -15,29 +32,37 @@ def read_data(data_path, b=True):
else:
return sys.stdin.read()
else:
if b:
return open(os.path.expanduser(data_path), "rb").read()
else:
return open(os.path.expanduser(data_path), "r").read()
return open(os.path.expanduser(data_path), "rb" if b else "r").read()
def write_data(data, result_path):
(sys.stdout if result_path == "-" else open(os.path.expanduser(result_path), "wb")).write(data)
if result_path == "-":
sys.stdout.write(data.decode())
else:
open(os.path.expanduser(result_path), "wb").write(data)
def encrypt(data, pubkey):
return duniterpy.key.PublicKey(pubkey).encrypt_seal(data)
def decrypt(data, privkey):
return duniterpy.key.SigningKey.from_seedhex(privkey).decrypt_seal(data)
return privkey.decrypt_seal(data)
def sign(data, privkey):
return duniterpy.key.SigningKey.from_seedhex(privkey).sign(data)
return privkey.sign(data)
def verify(data, pubkey):
try:
sys.stderr.write("Signature OK!\n")
return libnacl.sign.Verifier(duniterpy.key.PublicKey(pubkey).hex_pk()).verify(data)
except ValueError:
sys.stderr.write("Bad signature!\n")
exit(1)
def get_privkey(privkey_path, pubsec):
if pubsec:
return duniterpy.key.SigningKey.from_pubsec_file(privkey_path)
else:
return duniterpy.key.SigningKey.from_seedhex(read_data(privkey_path, False))
def show_help():
print("""Usage:
python3 natools.py <command> [options]
@ -51,6 +76,7 @@ Commands:
Options:
-i <path> Input file path (default: -)
-k <path> Privkey file path (default: authfile.key)
--pubsec Use pub/sec format for -p
-p <str> Pubkey (base58)
-o <path> Output file path (default: -)
@ -65,6 +91,7 @@ if __name__ == "__main__":
data_path = getargv("-i", "-")
privkey_path = getargv("-k", "authfile.key")
pubsec = "--pubsec" in sys.argv
pubkey = getargv("-p")
result_path = getargv("-o", "-")
@ -72,14 +99,14 @@ if __name__ == "__main__":
if sys.argv[1] == "encrypt":
write_data(encrypt(read_data(data_path), pubkey), result_path)
elif sys.argv[1] == "decrypt":
write_data(decrypt(read_data(data_path), read_data(privkey_path, False)), result_path)
write_data(decrypt(read_data(data_path), get_privkey(privkey_path, pubsec)), result_path)
elif sys.argv[1] == "sign":
write_data(sign(read_data(data_path), read_data(privkey_path, False)), result_path)
write_data(sign(read_data(data_path), get_privkey(privkey_path, pubsec)), result_path)
elif sys.argv[1] == "verify":
write_data(verify(read_data(data_path), pubkey), result_path)
else:
show_help()
except Exception as e:
sys.stderr.write("Error: ", e, "\n")
sys.stderr.write("Error: {}\n".format(e))
show_help()
exit(1)

View File

@ -89,9 +89,9 @@ then
TRANSAC=$(bc -l <<< "scale=2; $VIR / $NBbillets")
BILLETPUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NUMBER" -password="$SECRET")
# COPY authfile for Usage in 6 month...
log "__SUB:sms_BILLET.sh: authfile KEY : ./billets/$bpath/note.authfile.GPGPASS.gpg"
log "__SUB:sms_BILLET.sh: authfile KEY : ./billets/$bpath/note.authfile.IPFSPrivKey.gpg"
mkdir -p "./billets/$bpath"
echo "${GPGPASS}" | gpg -q --output "./billets/$bpath/note.authfile.GPGPASS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./authfile"
echo "${IPFSPrivKey}" | gpg -q --output "./billets/$bpath/note.authfile.IPFSPrivKey.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./authfile"
./natools.py encrypt -p $NODE_G1PUBKEY -i "./authfile" -o "./billets/$bpath/note.authfile.$NODE_UIDNA.crypt"
rm -f "./authfile"

View File

@ -27,7 +27,7 @@ UNIT=${accounting[2]}
# SEARCH FOR VIREMENT
if [[ -f ~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg ]]; then
echo "FOUND $file decrypting with Node key"
echo "${GPGPASS}" | gpg -d -q --output "/tmp/VIREMENTS.$PHONE" --yes --pinentry-mode loopback --passphrase-fd 0 "$file"
echo "${IPFSPrivKey}" | gpg -d -q --output "/tmp/VIREMENTS.$PHONE" --yes --pinentry-mode loopback --passphrase-fd 0 "$file"
declare -a LIST
num=0
cat /tmp/VIREMENTS.$PHONE | while read LIST; do

View File

@ -15,7 +15,7 @@ TODAY=$(date '+%Y%m%d')
if [[ -f "~/.zen/g1sms_wallets/$PHONE/VIREMENTS" ]]; then
# CHECK IF ALL DONE.
log "__SUB:sms_DESTROY.sh: FOUND "~/.zen/g1sms_wallets/$PHONE/VIREMENTS" decrypting with Node key"
echo "${GPGPASS}" | gpg -d -q --output "/tmp/VIREMENTS.$PHONE" --yes --pinentry-mode loopback --passphrase-fd 0 "~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg"
echo "${IPFSPrivKey}" | gpg -d -q --output "/tmp/VIREMENTS.$PHONE" --yes --pinentry-mode loopback --passphrase-fd 0 "~/.zen/g1sms_wallets/$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"
@ -56,11 +56,6 @@ sms_SEND "$PHONE" "$mess"
rm -Rf ~/.zen/g1sms_wallets/$PHONE;
rm -Rf ~/.zen/g1sms_wallets_swarm/$PHONE;
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)
move_g1cents "$PHONE" "$NODEPUB" "$cents"
I=$(ipfs_node_wallets_add)
log "__SUB:sms_DESTROY.sh: WALLET DESTROYED : $PHONE / $UIDNA / $MEMBER : ${c_green}OK$c_"
fi
else

View File

@ -99,9 +99,6 @@ if [[ "$PAY" == "" || "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then
# new=$(./checknodes.sh "BAN")
sms_ERROR "$PHONE" "Il est survenu un problème lors de votre virement: $PAY / Silkaj: $new";
exit
else
cents=$(echo $(bc -l <<< "scale=0; $ML * 100") | cut -d '.' -f 1)
move_g1cents "$PHONE" "$NODE_G1PUBKEY" "$cents"
fi
#############################################
@ -167,23 +164,23 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
echo "${ZEN}" > "$TAGAMOUNT"
# Création de la clef ${R} IPNS qui permet de publier des changements sur le TAG!
if [[ ! -f "/home/$YOU/.ipfs/keystore/${RR}" ]]; then
if [[ ! -f "~/.ipfs/keystore/${RR}" ]]; then
su $YOU -c "ipfs key gen -t rsa -s 2048 ${RR}"
fi
# GIVE QRCODE BJ ACCESS TO G1TAG
# Enregistrement de la clef de publication IPNS du wallet ${R} cryptée par B
echo "${BB}" | gpg -q --output "$TAGPUBLISH_B_GPG" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "/home/$YOU/.ipfs/keystore/${RR}"
echo "${BB}" | gpg -q --output "$TAGPUBLISH_B_GPG" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "~/.ipfs/keystore/${RR}"
# GIVE PHONE CREATOR G1WALLET ACCESS TO ZEN TAG
# Enregistrement de la clef de publication chiffrée par $PUBKEY la clef publique du portefeuille G1 createur.
./natools.py encrypt -p $PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_PHONE_CRYPT"
./natools.py encrypt -p $PUBKEY -i "~/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_PHONE_CRYPT"
# GIVE NODE_UIDNA ACCESS TO ZEN TAG
./natools.py encrypt -p $NODE_G1PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_NODE_CRYPT"
./natools.py encrypt -p $NODE_G1PUBKEY -i "~/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_NODE_CRYPT"
# GIVE SWARM ACCESS TO ZEN TAG
./natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_SWARM_CRYPT"
./natools.py encrypt -p $SWARM_G1PUBKEY -i "~/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_SWARM_CRYPT"
###########################################################
# TAG IPFS STORAGE & G1Tag IPNS PUBLISHING

View File

@ -36,11 +36,12 @@ fi
# Add COUNTRY code to PHONEDEST + PHONEDEST INIT
PHONEDEST="$COUNTRY${PHONEDEST:1:10}"
HPHONE=$(echo -n $PHONEDEST | sha256sum | cut -d ' ' -f 1)
# CHECK if PHONEDEST have an account in IPFS G1sms+ SWARM
if [[ -f "~/.zen/g1sms_wallets_swarm/$PHONEDEST/$PHONEDEST.pub" ]]
if [[ -f ~/.zen/ipfs_swarm/.Qm*/G1SMS/$HPHONE/_pub ]]
then
PUBKEYDEST=$(cat "~/.zen/g1sms_wallets_swarm/$PHONEDEST/$PHONEDEST.pub")
UNITDEST=$(cat "~/.zen/g1sms_wallets_swarm/$PHONEDEST/$PHONEDEST.unit")
PUBKEYDEST=$(cat ~/.zen/ipfs_swarm/.Qm*/G1SMS/$HPHONE/_pub)
UNITDEST=$(cat ~/.zen/ipfs_swarm/.Qm*/G1SMS/$HPHONE/_unit)
else
# NO, then create NEW Wallet
sms_INIT_ACCOUNT "$PHONEDEST"
@ -55,10 +56,6 @@ if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then
sms_ERROR "$phone" "Problème de payement avec silkaj (changement de serveur $new): $PAY";
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj $new : $PAY"
exit
else
# OK: Sync g1cents TODO check move_g1cents function and generalize on all silkaj transactions
cents=$(echo $(bc -l <<< "scale=0; $VIR * 100") | cut -d '.' -f 1)
move_g1cents "$phone" "$PUBKEYDEST" "$cents"
fi
sleep 2
@ -70,10 +67,6 @@ if [[ "$(echo $COM | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then
sms_ERROR "$phone" "Problème de payement avec silkaj (changement de serveur $new): $COM";
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj $new : $COM"
exit
else
# OK: Sync g1cents
cents=$(echo $(bc -l <<< "scale=0; $PERCENT * 100") | cut -d '.' -f 1)
move_g1cents "$phone" "$NODE_G1PUBKEY" "$cents"
fi
# LOG ACCOUNT HISTORY EVENTS

View File

@ -112,16 +112,13 @@ if [[ "$DESTRIB" != "" ]]; then
sms_ERROR "$PHONE" "Problème de payement avec silkaj (changement de serveur $new): $PAY";
log "__SUB:sms_REC.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit
else
cents=$(echo $(bc -l <<< "scale=0; $VIR * 100") | cut -d '.' -f 1)
move_g1cents "$PHONE" "$DESTRIB" "$cents"
fi
log "__SUB:sms_REC.sh: UPDATE ~/.zen/g1sms_wallets/$PHONE/VIREMENTS with FUTURE PAYEMENTS? $PAY"
########### MAKE ~/.zen/g1sms_wallets/$PHONE/VIREMENTS for NEXT ONES
if [[ -f "~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg" ]]; then
# DECYPHER FILE FOR CHANGE
echo "${GPGPASS}" | gpg -d -q --output "~/.zen/g1sms_wallets/$PHONE/VIREMENTS" --yes --pinentry-mode loopback --passphrase-fd 0 "~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg"
echo "${IPFSPrivKey}" | gpg -d -q --output "~/.zen/g1sms_wallets/$PHONE/VIREMENTS" --yes --pinentry-mode loopback --passphrase-fd 0 "~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg"
fi
# WRITE NEW LINES INTO AN ARRAY FILE: VIREMENTS
boucle=$((TIME - 1))
@ -135,7 +132,7 @@ if [[ "$DESTRIB" != "" ]]; then
done
# CYPHER FILE
echo "${GPGPASS}" | gpg -q --output "~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "~/.zen/g1sms_wallets/$PHONE/VIREMENTS"
echo "${IPFSPrivKey}" | gpg -q --output "~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "~/.zen/g1sms_wallets/$PHONE/VIREMENTS"
# EMPTY CLEAR FILE
log "__SUB:sms_REC.sh: $(cat ~/.zen/g1sms_wallets/$PHONE/VIREMENTS)"
echo "" > ~/.zen/g1sms_wallets/$PHONE/VIREMENTS

View File

@ -30,8 +30,6 @@ if [[ $unit == "U" || $unit == "" ]]; then
fi
echo "$unit" > "$UNITFILE"
log "G1sms wallet new $unit... IPFS SWARM publishing..."
ipfs_node_wallets_add
mess="[G1sms+]
Unité de votre portefeuille: $unit"

View File

@ -87,8 +87,6 @@ $PAY"
if [[ "$DESTPHONE" != "" ]]; then
sms_SEND "$DESTPHONE" "Bonjour $DESTMEM. Vous venez de recevoir un virement de $AMOUNT $UNIT ($VIR G1) de la part de $member portefeuille $UIDNA"
fi
cents=$(echo $(bc -l <<< "scale=0; $VIR * 100") | cut -d '.' -f 1)
move_g1cents "$PHONE" "$DESTRIB" "$cents"
else
new=$(./checknodes.sh "BAN")
sms_SEND "$ADMINPHONE" "ADMIN! Problème de payement avec silkaj (changement de serveur $new): $PAY";

View File

@ -26,7 +26,7 @@ if [[ "$askeduidna" == "" ]]; then #SELF
uidna=$(cat $nodeuidnafile)
fi
else
nodeuidnafile=$(grep -Rwl "$askeduidna" ~/.zen/g1sms_wallets_swarm/.*/*.uidna)
nodeuidnafile=$(grep -Rwl "$askeduidna" ~/.zen/ipfs_swarm/.*/G1*/_uidna)
uidna=$(cat $nodeuidnafile)
fi
@ -35,7 +35,6 @@ if [[ -f $nodeuidnafile && "$uidna" != "" ]]; then
echo $uidna > ~/.zen/g1sms_wallets/$PHONE/uidna.G1TAGNODE
echo $ipfsnodeid > ~/.zen/g1sms_wallets/$PHONE/ipfsid.G1TAGNODE
log "__SUB:sms_WHERE.sh: Distributeur de G1Tag $uidna : $ipfsnodeid "
I=$(ipfs_node_wallets_add)
log_history $PHONE "G1TagNode, $uidna, $ipfsnodeid"
else
log "__SUB:sms_WHERE.sh: ERROR Distributeur de G1Tag $askeduidna inconnu ???"

View File

@ -100,7 +100,7 @@ fi
#############################################
############## EXTRACT $JSOURCERR PUBLISH KEY
if [[ -f "$KEYFILE" ]]; then
./natools.py decrypt -k "$KEYFILE" -i "$JSOURCEPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JSOURCERR"
./natools.py decrypt -k "$KEYFILE" -i "$JSOURCEPUBLISHKEY" -o "~/.ipfs/keystore/$JSOURCERR"
else
echo "__SUB:tag_LOAD_passenger.sh: KO. La clef $KEYFILE fournie pour ce G1Tag $JSOURCERR est inexistante. Procurez-vous un portefeuille monnaie libre sur https://g1sms.fr"
exit
@ -140,7 +140,7 @@ echo "$I" > "./TAG/${JSOURCERR}/TAG_chain"
I=$(su $YOU -c "ipfs add -qr ./TAG/${JSOURCERR} | tail -n 1")
# IPNS $JSOURCERR PUBLISH
J=$(su $YOU -c "ipfs name publish -k ${JSOURCERR} --quieter /ipfs/${I}")
# TODO rm "/home/$YOU/.ipfs/keystore/$JSOURCERR"
# TODO rm "~/.ipfs/keystore/$JSOURCERR"
# WRITE FILE REC INDEX IN NODE G1TAG REF.
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/TAG/

View File

@ -66,8 +66,8 @@ if [[ $FINALSOURCE -lt 0 ]]; then echo "__SUB:tag_OP.sh: KO. La valeur de ce G1T
#############################################
############## EXTRACT $JSOURCERR PUBLISH KEY
if [[ -f $KEYFILE && ! -f "/home/$YOU/.ipfs/keystore/$JSOURCERR" ]]; then
./natools.py decrypt -k "$KEYFILE" -i "$JSOURCEPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JSOURCERR"
if [[ -f $KEYFILE && ! -f "~/.ipfs/keystore/$JSOURCERR" ]]; then
./natools.py decrypt -k "$KEYFILE" -i "$JSOURCEPUBLISHKEY" -o "~/.ipfs/keystore/$JSOURCERR"
else
if [[ ! -f $KEYFILE ]]; then
echo "__SUB:tag_OP.sh: KO. La clef de dévérouillage pour $JSOURCERR est inexistante. Contact: https://g1sms.fr"
@ -85,10 +85,10 @@ su $YOU -c "ipfs get --output=./TAG/${JDESTRR}/ /ipns/$JDEST"
JDESTPUBLISHKEY="./TAG/${JDESTRR}/TAG_publishkey.swarm.crypt"
JDESTVALUE=$(cat ./TAG/${JDESTRR}/TAG_amount);
FINALDEST=$(echo "${JDESTVALUE} + ${VALUE}" | bc -l)
# EXTRACT $JSOURCERR PUBLISH KEY to "/home/$YOU/.ipfs/keystore/JSOURCE"
# EXTRACT $JSOURCERR PUBLISH KEY to "~/.ipfs/keystore/JSOURCE"
# EXTRACT PUBLISH KEY
if [[ -f $KEYFILE && ! -f "/home/$YOU/.ipfs/keystore/$JDESTRR" ]]; then
./natools.py decrypt -k "$KEYFILE" -i "$JDESTPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JDESTRR"
if [[ -f $KEYFILE && ! -f "~/.ipfs/keystore/$JDESTRR" ]]; then
./natools.py decrypt -k "$KEYFILE" -i "$JDESTPUBLISHKEY" -o "~/.ipfs/keystore/$JDESTRR"
else
if [[ ! -f $KEYFILE ]]; then
echo "__SUB:tag_OP.sh: KO. La clef de dévérouillage pour $JDESTRR est inexistante. Contact: https://g1sms.fr"
@ -96,7 +96,7 @@ else
fi
######################################################################################################
if [[ -f "/home/$YOU/.ipfs/keystore/$JDESTRR" && -f "/home/$YOU/.ipfs/keystore/$JSOURCERR" ]]; then
if [[ -f "~/.ipfs/keystore/$JDESTRR" && -f "~/.ipfs/keystore/$JSOURCERR" ]]; then
# IF PUBLISH key for BOTH G1TAG exists
#############################################
############## SOURCE OPERATION
@ -124,7 +124,7 @@ I=$(su $YOU -c "ipfs add -qr ./TAG/${JSOURCERR} | tail -n 1")
J=$(su $YOU -c "ipfs name publish -k ${JSOURCERR} --quieter /ipfs/${I}")
# CLEAN IPFS keystore
if [[ "${SOURCENODEID}" != "${IPFSNODEID}" ]]; then
rm -f "/home/$YOU/.ipfs/keystore/$JSOURCERR"
rm -f "~/.ipfs/keystore/$JSOURCERR"
fi
echo "__SUB:tag_OP.sh: G1Tag $JSOURCERR value ($FINALSOURCE) :: su $YOU -c \"ipfs cat /ipns/$JSOURCE/TAG_amount\""
@ -152,7 +152,7 @@ if [[ "$JSOURCE" != "$JDEST" ]]; then
# IPNS $JDESTRR PUBLISH
J=$(su $YOU -c "ipfs name publish -k ${JDESTRR} --quieter /ipfs/${I}")
if [[ "${DESTNODEID}" != "${IPFSNODEID}" ]]; then
rm -f "/home/$YOU/.ipfs/keystore/$JDESTRR"
rm -f "~/.ipfs/keystore/$JDESTRR"
fi
echo "__SUB:tag_OP.sh: G1Tag $JDESTRR value ($FINALDEST) :: su $YOU -c \"ipfs cat /ipns/$JDEST/TAG_amount\""
fi

View File

@ -76,7 +76,7 @@ cat /dev/ttyACM0 | while read line; do
if [[ "$CURRENCY" == "zen" ]]; then CUR="zène"; else CUR=$CURRENCY; fi # Correction du défaut de prononciation.
PASSENGER=$(su $YOU -c "ipfs cat /ipns/$J/TAG_passenger");
# DIG PUBLISHING KEY
if [[ -f /home/$YOU/.ipfs/keystore/$RR ]]; then
if [[ -f ~/.ipfs/keystore/$RR ]]; then
log "__SUB:tag_READ.sh: Clef de publication IPFS $RR déjà présente"
else
rm /tmp/TAG_publishkey.B.gpg
@ -88,7 +88,7 @@ cat /dev/ttyACM0 | while read line; do
log "__SUB:tag_READ.sh: ERROR! gpg -d --output /tmp/ipns.key --pinentry-mode=loopback --passphrase $BB /tmp/TAG_publishkey.B.gpg"
continue
fi
mv /tmp/ipns.key /home/$YOU/.ipfs/keystore/$RR
mv /tmp/ipns.key ~/.ipfs/keystore/$RR
log "__SUB:tag_READ.sh: Récupération de la clef de publication $RR"
./parle.sh "Récupération clef de publication du G1 Tag ${FID}"
fi
@ -141,7 +141,7 @@ cat /dev/ttyACM0 | while read line; do
###############################################################
# APRES G1 CASHBACK : G1 Tag BJ WRITE => ENCAISSEMENT
if [[ "${cmd}" == "BJ" && "$CASHBACK" != "" && -f /home/$YOU/.ipfs/keystore/${RR} ]]; then
if [[ "${cmd}" == "BJ" && "$CASHBACK" != "" && -f ~/.ipfs/keystore/${RR} ]]; then
./parle.sh "Encaissement du G1 Tag"
log "__SUB:tag_READ.sh: G1 tag de $BVALUE G1 ! /ipns/$J Virement vers $CASHBACK? "
@ -196,7 +196,7 @@ cat /dev/ttyACM0 | while read line; do
# CLEAN IPFS keystore: remove NOT created NODE keys
SOURCENODEID=$(cat "./TAG/${RR}/TAG_nodeid")
if [[ "${SOURCENODEID}" != "${IPFSNODEID}" ]]; then
rm -f /home/$YOU/.ipfs/keystore/${RR}
rm -f ~/.ipfs/keystore/${RR}
fi
fi
else

View File

@ -93,7 +93,7 @@ cat /dev/ttyACM0 | while read line; do
PASSENGER=$(su $YOU -c "ipfs cat /ipns/$J/TAG_passenger");
# DIG PUBLISHING KEY
if [[ -f /home/$YOU/.ipfs/keystore/$RR ]]; then
if [[ -f ~/.ipfs/keystore/$RR ]]; then
log "__SUB:tag_READ_X.sh: Clef de publication IPFS $RR déjà présente"
else
rm /tmp/TAG_publishkey.B.gpg
@ -105,7 +105,7 @@ cat /dev/ttyACM0 | while read line; do
./tools/4LETTER.scroll.py ">> BAD GPG KEY <<"
continue
fi
mv /tmp/ipns.key /home/$YOU/.ipfs/keystore/$RR
mv /tmp/ipns.key ~/.ipfs/keystore/$RR
log "__SUB:tag_READ_X.sh: Récupération de la clef de publication $RR"
fi
if [[ "$PASSENGER" != "" ]]; then
@ -161,7 +161,7 @@ cat /dev/ttyACM0 | while read line; do
###############################################################
# APRES G1 CASHBACK : G1 Tag BJ WRITE => ENCAISSEMENT
if [[ "${cmd}" == "BJ" && "$CASHBACK" != "" && -f /home/$YOU/.ipfs/keystore/${RR} ]]; then
if [[ "${cmd}" == "BJ" && "$CASHBACK" != "" && -f ~/.ipfs/keystore/${RR} ]]; then
./tools/4LETTER.scroll.py "ZEN -> G1"
log "__SUB:tag_READ_X.sh: G1 tag de $BVALUE G1 ! /ipns/$J Virement vers $CASHBACK? "
@ -221,7 +221,7 @@ cat /dev/ttyACM0 | while read line; do
# CLEAN IPFS keystore: remove NOT created NODE keys
SOURCENODEID=$(cat "./TAG/${RR}/TAG_nodeid")
if [[ "${SOURCENODEID}" != "${IPFSNODEID}" ]]; then
rm -f /home/$YOU/.ipfs/keystore/${RR}
rm -f ~/.ipfs/keystore/${RR}
fi
fi
else

View File

@ -107,7 +107,7 @@ cat /dev/ttyACM0 | while read line; do
PASSENGER=$(su $YOU -c "ipfs cat /ipns/$J/TAG_passenger");
# DIG PUBLISHING KEY
if [[ -f /home/$YOU/.ipfs/keystore/$RR ]]; then
if [[ -f ~/.ipfs/keystore/$RR ]]; then
log "__SUB:tag_READ_X.sh: Clef de publication IPFS $RR déjà présente"
else
rm /tmp/TAG_publishkey.B.gpg
@ -119,7 +119,7 @@ cat /dev/ttyACM0 | while read line; do
./tools/4LETTER.scroll.py ">> BAD GPG KEY <<"
continue
fi
mv /tmp/ipns.key /home/$YOU/.ipfs/keystore/$RR
mv /tmp/ipns.key ~/.ipfs/keystore/$RR
log "__SUB:tag_READ_X.sh: Récupération de la clef de publication $RR"
fi
if [[ "$PASSENGER" != "" ]]; then
@ -175,7 +175,7 @@ cat /dev/ttyACM0 | while read line; do
###############################################################
# APRES G1 CASHBACK : G1 Tag BJ WRITE => ENCAISSEMENT
if [[ "${cmd}" == "BJ" && "$CASHBACK" != "" && -f /home/$YOU/.ipfs/keystore/${RR} ]]; then
if [[ "${cmd}" == "BJ" && "$CASHBACK" != "" && -f ~/.ipfs/keystore/${RR} ]]; then
./tools/4LETTER.scroll.py "ZEN -> G1"
log "__SUB:tag_READ_X.sh: G1 tag de $BVALUE G1 ! /ipns/$J Virement vers $CASHBACK? "
@ -235,7 +235,7 @@ cat /dev/ttyACM0 | while read line; do
# CLEAN IPFS keystore: remove NOT created NODE keys
SOURCENODEID=$(cat "./TAG/${RR}/TAG_nodeid")
if [[ "${SOURCENODEID}" != "${IPFSNODEID}" ]]; then
rm -f /home/$YOU/.ipfs/keystore/${RR}
rm -f ~/.ipfs/keystore/${RR}
fi
fi
else