diff --git a/README.md b/README.md index fde237514765b1f717694483cb3f2347e66ea1e9..97634a14347b614b2e7eb073aedd998ec773d8a5 100644 --- a/README.md +++ b/README.md @@ -68,17 +68,27 @@ Traduire et changer ce code dans init.sh pour un autre pays!! * Mettre vos clefs Provider de service G1SMS dans les fichiers g1sms.priv.key et g1sms.pub.key -# 1 DU = 100 LOVE -# 1 LOVE = 1 CentiDU = 1/DUFACTOR G1 +# 1 DU = 100 LOVE = DUFACTOR G1 !TODO * https://cesium.madeinzion.org/api/#/v1/payment/SonqoZEfZXHDBxi4KxdqVKZVygxVFTtpo9ugyDDQ6w3?amount=10 * Backup Sync System & key files -* Add minimum time between Payements (for Blockchain sync) -* Check Hidden Source Phone Number -* Set maximum wallet LOVE amount and automatic transfer to other/member wallet -* Close account & Full transfer to another (phone steal or number change) -* Register as Cesium+ service provider -* Synchronise phone accounts with multiple G1SMS servers. + +New commands: +- N UID: register member wallet with current phone wallet +- MAX 999: Set maximum wallet ammout (unit) => over sent daily/weekly toi member wallet +- ALIAS xxx cmd: create (xxx) alias for personalised command (cmd) +- LOOP cmd: run command on each payments +- CLOSE Transfer / close command +- + Scenario with multiple interactions +- Make Smartphone / OldPhone + +1 Add minimum time between Payements (for Blockchain sync) +2 Check Hidden Source Phone Number +3 Set maximum wallet LOVE amount and automatic transfer to other/member wallet +4 Close account & Full transfer to another (phone steal or number change) +5 Register as Cesium+ service provider +6 Synchronise phone accounts with multiple G1SMS servers + * ... diff --git a/cron/accounts.sh b/cron/accounts.sh index 8195b376bc45ffd2bbf2b889571b2ef538ecd69a..f4852efecb88178eb597bc7cbd8afb4a2a62f3de 100755 --- a/cron/accounts.sh +++ b/cron/accounts.sh @@ -16,9 +16,14 @@ NB=0 for f in $(ls ./wallets/ -t); do PHONE="$f" PIN=$(cat /root/G1SMS/wallets/$PHONE/$PHONE.pin|xargs) - PUBKEY=$(cat /root/G1SMS/wallets/$PHONE/$PHONE.pub|xargs) + WUID="" + if [ -f "/root/G1SMS/wallets/$PHONE/$PHONE.uid" ]; then + WUID=$(cat "/root/G1SMS/wallets/$PHONE/$PHONE.uid"|xargs) + fi + PUBKEY=$(cat "/root/G1SMS/wallets/$PHONE/$PHONE.pub"|xargs) AMOUNTG1=$(./silkaj/silkaj amount --auth-scrypt -salt="$PHONE" -password="$PIN") - echo $PHONE / $PUBKEY + echo "$PHONE / $PUBKEY" + echo "-> $WUID ?" echo "Solde ($PHONE) : $AMOUNTG1 G1" if [[ "$AMOUNTG1" == "0.0" ]]; then echo "EMPTY!!!"; fi diff --git a/fake_silkaj.sh b/fake_silkaj.sh index 99c0835e654e11583a368c9896875f69470200e0..c670ef6c2cc413584b0638431763908d00398ea0 100755 --- a/fake_silkaj.sh +++ b/fake_silkaj.sh @@ -4,6 +4,9 @@ case "$1" in amount) echo 1000 ;; + id) + echo "→ DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech ↔ Fred" + ;; transaction) echo "OK" ;; diff --git a/shell/functions.sh b/shell/functions.sh index a1e200f9da2e6e5a2beca11d2672b8bc6bdab9f3..591893d9e4211ac44cd3ea08f545873084dfafef 100755 --- a/shell/functions.sh +++ b/shell/functions.sh @@ -55,16 +55,36 @@ log "history ($1=phone, $2=message)" } +function sms_uid2key (){ + UIDFILE="./wallets/$PHONE/$PHONE.uid" + if [ -f "$UIDFILE" ]; then + UIDPUBKEY=$(cat "$UIDFILE") + else + if [ "$1" != "" ]; then + if [[ "$UIDPUBKEY" == "" && "$1" != "" ]]; then + UIDPUBKEY=$(./silkaj/silkaj id "$1" | grep -w "$1" | awk '{print $2}') + if [ "$UIDPUBKEY" != "" ]; then + log "NEWUID:$1:$UIDPUBKEY" + INIT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount=0.1 --output=$UIDPUBKEY --comment="THIRD_PARTY_MANAGER:G1SMS:$MASTERPUB" -y) + echo "$UIDPUBKEY" > "$UIDFILE" + fi + fi + fi + fi +} + #######################################" function sms_INIT_ACCOUNT () { log "sms_INIT_ACCOUNT ($1=phone, $2=NOSMS)" PHONE="$1" UNKNOWN=0 - PINFILE="./wallets/$PHONE/$PHONE.pin" - PUBKEYFILE="./wallets/$PHONE/$PHONE.pub" - UNITFILE="./wallets/$PHONE/$PHONE.unit" - HISTFILE="./wallets/$PHONE/$PHONE.hist" - + # Initiate PHONE settings files and values + PINFILE="./wallets/$PHONE/$PHONE.pin" # Contains phone wallet diceware password + PUBKEYFILE="./wallets/$PHONE/$PHONE.pub" # Contains phone wallet public key (RIB) + UNITFILE="./wallets/$PHONE/$PHONE.unit" # Contains phone wallet prefered unit (LOVE,G1,DU) + HISTFILE="./wallets/$PHONE/$PHONE.hist" # Contains phone wallet history (see log_history function) + UIDFILE="./wallets/$PHONE/$PHONE.uid" # Contains phone wallet related member UID (n) + # (NO PIN) FirstAccount Create wallet if [ ! -f "$PINFILE" ]; then if [[ $2 == "NOSMS" ]]; then UNKNOWN="unknown"; return; fi diff --git a/shell/sms_NEW.sh b/shell/sms_NEW.sh index 7a8c49463178589830024f682d00643989d66492..f13fc74d1780c0c14188f584abefeba4e9a3907a 100755 --- a/shell/sms_NEW.sh +++ b/shell/sms_NEW.sh @@ -6,21 +6,26 @@ ################################################################################ source /root/G1SMS/shell/init.sh source /root/G1SMS/shell/functions.sh -log "X sms_NEW.sh ($1=phone)" +log "X sms_NEW.sh ($1=phone, $2=uid)" -PHONE=$1 +PHONE="$1" +MEMBERUID="$2" # Initialise PHONE, PIN, PUBKEY, UNIT, HIST sms_INIT_ACCOUNT $PHONE +if [ "$MEMBERUID" != "" ]; then + sms_uid2key "$MEMBERUID" +fi +mess="[G1SMS] (https://qo-op.com) +$MEMBERUID Porte-monnaie Libre ouvert. +Id: $PHONE +Code: $PIN -mess="[G1SMS] ($UNIT) -$PHONE -$PIN - -$PUBKEY - -https://qo-op.com" +Clef Publique (RIB) +" +sms_SEND "$PHONE" "$mess" +mess="$PUBKEY" sms_SEND "$PHONE" "$mess" exit diff --git a/shell/sms_PAY.sh b/shell/sms_PAY.sh index 171b4ea8de7a1e88c9b4e8aaa64486a1beec59a5..2af7fabc0102243b7e30d34d650b317bd006b720 100755 --- a/shell/sms_PAY.sh +++ b/shell/sms_PAY.sh @@ -108,7 +108,7 @@ else Solde: $AMOUNTLOVE LOVE ($AMOUNTG1 G1 = $AMOUNTDU DU) INSUFFISANT pour virer $amount $UNIT -Rechargez votre compte..." +Rechargez https://cesium.madeinzion.org/api/#/v1/payment/$PUBKEY?amount=100" sms_ERROR "$phone" "$text" fi diff --git a/silkaj/src/__pycache__/wot.cpython-35.pyc b/silkaj/src/__pycache__/wot.cpython-35.pyc index 371cdeca66d7052921eefc068982f9c536032825..6d77b33d444e6616fdaca57f1328a32cd2773244 100644 Binary files a/silkaj/src/__pycache__/wot.cpython-35.pyc and b/silkaj/src/__pycache__/wot.cpython-35.pyc differ diff --git a/silkaj/src/wot.py b/silkaj/src/wot.py index f432f67c937524107dd35ec8194969cba478fc37..eda31872e9d0ecb68a41c969d5dad09bdc22f07b 100644 --- a/silkaj/src/wot.py +++ b/silkaj/src/wot.py @@ -60,13 +60,14 @@ def date_approximation(block_id, time_first_block, avgentime): def id_pubkey_correspondence(ep, id_pubkey): if check_public_key(id_pubkey, False): - print("{} public key corresponds to identity: {}".format(id_pubkey, get_uid_from_pubkey(ep, id_pubkey))) +# print("{} public key corresponds to identity: {}".format(id_pubkey, get_uid_from_pubkey(ep, id_pubkey))) + print("") else: pubkeys = get_pubkeys_from_id(ep, id_pubkey) if pubkeys == NO_MATCHING_ID: print(NO_MATCHING_ID) else: - print("Public keys found matching '{}':\n".format(id_pubkey)) +# G1SMS:: print("Public keys found matching '{}':\n".format(id_pubkey)) for pubkey in pubkeys: print("→", pubkey["pubkey"], end=" ") try: diff --git a/sms_received.sh b/sms_received.sh index 6648e2bcc46f2ab4783ff967e0b78dfed2e5d8ce..60b81d2ea4aaf13f49252ad524e2e10382b3397c 100755 --- a/sms_received.sh +++ b/sms_received.sh @@ -20,6 +20,7 @@ log "SMS received $PHONE $TEXT" # No Reply to MySelf (or enjoy SMS LOOP of the death) if [ "$PHONE" == "$MASTERPHONE" ]; then exit; fi +if [ "$PHONE" == "Orange Info" ]; then exit; fi # Extract Received Command (if new update sms_AIDE.sh) CMD=$(echo "$TEXT" | cut -d ' ' -f 1) @@ -31,11 +32,16 @@ case "$CMD" in ./shell/sms_AIDE.sh "$PHONE" & ;; N|D) - ./shell/sms_NEW.sh "$PHONE" & + MEMBERUID=$(echo "$TEXT" | cut -d ' ' -f 2) + ./shell/sms_NEW.sh "$PHONE" "$MEMBERUID" & ;; P) DEST=$(echo "$TEXT" | cut -d ' ' -f 2) LOVE=$(echo "$TEXT" | cut -d ' ' -f 3) + # PI EasterEgg. Any 3.14 amount is G1 Unit + if [ "$LOVE" == "3.14" ]; then + LOVE=$(bc -l <<< "scale=0; $LOVE * 100 / $DUFACTOR") + fi checkdest=$(echo "$DEST" | grep -E "^\-?[0-9]+$") # Test if number checklove=$(echo "$LOVE" | grep -E "^\-?[0-9]+$") # Test number if [[ ${#DEST} == 10 && "$checkdest" != '' && "$checklove" != '' ]]; then @@ -55,7 +61,7 @@ case "$CMD" in UNIT=$(echo "$TEXT" | cut -d ' ' -f 2) ./shell/sms_SETUNIT.sh "$PHONE" "$UNIT" & ;; - Delivered|Pending) + Delivered|Pending|Failed) # If delivered/pending notification come back (gammu/phone config) exit ;;