Commit d0f742e0 authored by zicmama's avatar zicmama

RML12 Hackathon.#1 Add UID pubkey -> link member / phone wallets

parent ff4ebbfa
......@@ -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
* ...
......@@ -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
......
......@@ -4,6 +4,9 @@ case "$1" in
amount)
echo 1000
;;
id)
echo "→ DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech ↔ Fred"
;;
transaction)
echo "OK"
;;
......
......@@ -55,15 +55,35 @@ 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
......
......@@ -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
......@@ -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
......
......@@ -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:
......
......@@ -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
;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment