G1sms/shell/sms_NEW.sh

58 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.2
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# CREATE NEW G1 ./wallets/PHONE/sha256_ID ACCOUNT
source ./shell/init.sh
source ./shell/functions.sh
log "${c_yellow}X sms_NEW.sh ($1=phone, $2=uid)$c_"
PHONE="$1"
MEMBERUID="$2"
# Initialise PHONE, PIN, PUBKEY, UNIT
sms_INIT_ACCOUNT "$PHONE"
if [[ "$MEMBERUID" != "" && "$MEMBERUID" != "N" && "$MEMBERUID" != "D" && "$MEMBERUID" != "NOUV" ]]; then
# UID RECEIVED in SMS
VIRDEST=$MEMBERUID
# GET ASSOCIATED MEMBER OR UIDNA G1 PUB KEY
MEMRIB=$(sms_uid2pubkey "$MEMBERUID" "$PHONE" "$PIN")
# No related wallet found
if [[ $MEMRIB == "" ]]; then exit; fi
MEMBER="$MEMBERUID"
fi
# TODO Replace "NOSMS" mode with .profile READ, or similar...
sms_INIT_ACCOUNT "$PHONE" "NOSMS"
# Check account amount
countvalues=($(check_account))
log "$(declare -p countvalues)"
AMOUNTG1=${countvalues[0]}
AMOUNT=${countvalues[1]}
UNIT=${countvalues[2]}
mess="[G1sms+] Portefeuille G1
$UIDNA
$PIN
---
Solde: $AMOUNT $UNIT
https://cesium.app"
sms_SEND "$PHONE" "$mess"
sleep 2
sms_SEND "$PHONE" "* Clef Publique G1 (RIB) ="
sleep 2
sms_SEND "$PHONE" "$PUBKEY"
sleep 2
[[ $MEMBER || $MAIL ]] && sms_SEND "$PHONE" "Compte relié: $MEMBER $MAIL
$MEMRIB"
# Add contact to database
add_contact $PHONE $MEMBERUID && log "${c_green}Contact has been added to database$c_" || log "${c_red}Contact can't be added to database$c_"
log "${c_yellow}END sms_NEW.sh$c_"
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit