init
After Width: | Height: | Size: 32 KiB |
|
@ -0,0 +1,10 @@
|
||||||
|
import RPi.GPIO as GPIO
|
||||||
|
import time
|
||||||
|
GPIO.setmode(GPIO.BOARD)
|
||||||
|
GPIO.setup(7, GPIO.OUT)
|
||||||
|
while True:
|
||||||
|
GPIO.output(7, GPIO.LOW)
|
||||||
|
time.sleep(4)
|
||||||
|
GPIO.output(7, GPIO.HIGH)
|
||||||
|
break
|
||||||
|
GPIO.cleanup()
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [ ! -e /sys/class/gpio/gpio4 ]; then
|
||||||
|
echo "File exists."
|
||||||
|
echo "4" > /sys/class/gpio/export
|
||||||
|
fi
|
||||||
|
echo "out" > /sys/class/gpio/gpio4/direction
|
||||||
|
echo "0" > /sys/class/gpio/gpio4/value
|
||||||
|
sleep 2
|
||||||
|
echo "1" > /sys/class/gpio/gpio4/value
|
|
@ -0,0 +1,88 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Clean /tmp/ytdl.list
|
||||||
|
#echo > /tmp/ytdl.list
|
||||||
|
|
||||||
|
function replace_accents (){
|
||||||
|
INPUT="$1"
|
||||||
|
declare -a acc
|
||||||
|
declare -a noa
|
||||||
|
acc=('$' 'è' 'ê' 'é' 'À' 'Á' 'Â' 'Ã' 'Ä' 'Å' 'Æ' 'Ç' 'È' 'É' 'Ê' 'Ë' 'Ì' 'Í' 'Î' 'Ï' 'Ð' 'Ñ' 'Ò' 'Ó' 'Ô' 'Õ' 'Ö' 'Ø' 'Ù' 'Ú' 'Û' 'Ü' 'Ý' 'ß' 'à' 'á' 'â' 'ã' 'ä' 'å' 'æ' 'ç' 'è' 'é' 'ê' 'ë' 'ì' 'í' 'î' 'ï' 'ñ' 'ò' 'ó' 'ô' 'õ' 'ö' 'ø' 'ù' 'ú' 'û' 'ü' 'ý' 'ÿ' 'Ā' 'ā' 'Ă' 'ă' 'Ą' 'ą' 'Ć' 'ć' 'Ĉ' 'ĉ' 'Ċ' 'ċ' 'Č' 'č' 'Ď' 'ď' 'Đ' 'đ' 'Ē' 'ē' 'Ĕ' 'ĕ' 'Ė' 'ė' 'Ę' 'ę' 'Ě' 'ě' 'Ĝ' 'ĝ' 'Ğ' 'ğ' 'Ġ' 'ġ' 'Ģ' 'ģ' 'Ĥ' 'ĥ' 'Ħ' 'ħ' 'Ĩ' 'ĩ' 'Ī' 'ī' 'Ĭ' 'ĭ' 'Į' 'į' 'İ' 'ı' 'IJ' 'ij' 'Ĵ' 'ĵ' 'Ķ' 'ķ' 'Ĺ' 'ĺ' 'Ļ' 'ļ' 'Ľ' 'ľ' 'Ŀ' 'ŀ' 'Ł' 'ł' 'Ń' 'ń' 'Ņ' 'ņ' 'Ň' 'ň' 'ʼn' 'Ō' 'ō' 'Ŏ' 'ŏ' 'Ő' 'ő' 'Œ' 'œ' 'Ŕ' 'ŕ' 'Ŗ' 'ŗ' 'Ř' 'ř' 'Ś' 'ś' 'Ŝ' 'ŝ' 'Ş' 'ş' 'Š' 'š' 'Ţ' 'ţ' 'Ť' 'ť' 'Ŧ' 'ŧ' 'Ũ' 'ũ' 'Ū' 'ū' 'Ŭ' 'ŭ' 'Ů' 'ů' 'Ű' 'ű' 'Ų' 'ų' 'Ŵ' 'ŵ' 'Ŷ' 'ŷ' 'Ÿ' 'Ź' 'ź' 'Ż' 'ż' 'Ž' 'ž' 'ſ' 'ƒ' 'Ơ' 'ơ' 'Ư' 'ư' 'Ǎ' 'ǎ' 'Ǐ' 'ǐ' 'Ǒ' 'ǒ' 'Ǔ' 'ǔ' 'Ǖ' 'ǖ' 'Ǘ' 'ǘ' 'Ǚ' 'ǚ' 'Ǜ' 'ǜ' 'Ǻ' 'ǻ' 'Ǽ' 'ǽ' 'Ǿ' 'ǿ');
|
||||||
|
noa=('S' 'e' 'e' 'e' 'A' 'A' 'A' 'A' 'A' 'A' 'AE' 'C' 'E' 'E' 'E' 'E' 'I' 'I' 'I' 'I' 'D' 'N' 'O' 'O' 'O' 'O' 'O' 'O' 'U' 'U' 'U' 'U' 'Y' 's' 'a' 'a' 'a' 'a' 'a' 'a' 'ae' 'c' 'e' 'e' 'e' 'e' 'i' 'i' 'i' 'i' 'n' 'o' 'o' 'o' 'o' 'o' 'o' 'u' 'u' 'u' 'u' 'y' 'y' 'A' 'a' 'A' 'a' 'A' 'a' 'C' 'c' 'C' 'c' 'C' 'c' 'C' 'c' 'D' 'd' 'D' 'd' 'E' 'e' 'E' 'e' 'E' 'e' 'E' 'e' 'E' 'e' 'G' 'g' 'G' 'g' 'G' 'g' 'G' 'g' 'H' 'h' 'H' 'h' 'I' 'i' 'I' 'i' 'I' 'i' 'I' 'i' 'I' 'i' 'IJ' 'ij' 'J' 'j' 'K' 'k' 'L' 'l' 'L' 'l' 'L' 'l' 'L' 'l' 'l' 'l' 'N' 'n' 'N' 'n' 'N' 'n' 'n' 'O' 'o' 'O' 'o' 'O' 'o' 'OE' 'oe' 'R' 'r' 'R' 'r' 'R' 'r' 'S' 's' 'S' 's' 'S' 's' 'S' 's' 'T' 't' 'T' 't' 'T' 't' 'U' 'u' 'U' 'u' 'U' 'u' 'U' 'u' 'U' 'u' 'U' 'u' 'W' 'w' 'Y' 'y' 'Y' 'Z' 'z' 'Z' 'z' 'Z' 'z' 's' 'f' 'O' 'o' 'U' 'u' 'A' 'a' 'I' 'i' 'O' 'o' 'U' 'u' 'U' 'u' 'U' 'u' 'U' 'u' 'U' 'u' 'A' 'a' 'AE' 'ae' 'O' 'o');
|
||||||
|
|
||||||
|
OUTPUT=""
|
||||||
|
i=0
|
||||||
|
length=${#INPUT}
|
||||||
|
while [[ $i -lt $length ]]; do
|
||||||
|
char=${INPUT:$i:1};
|
||||||
|
#echo $i:$char
|
||||||
|
j=0
|
||||||
|
for letter in "${acc[@]}"
|
||||||
|
do
|
||||||
|
if [[ "$letter" == "$char" ]]; then
|
||||||
|
char="${noa[$j]}"
|
||||||
|
fi
|
||||||
|
((j++))
|
||||||
|
done
|
||||||
|
((i++))
|
||||||
|
OUTPUT=$OUTPUT$char
|
||||||
|
done
|
||||||
|
echo $OUTPUT
|
||||||
|
}
|
||||||
|
|
||||||
|
# SCAN NEW LINE IN NEW RECORD LIST AND RUN youtube-dl search and copy
|
||||||
|
tail -fn 1 /tmp/ytdl.list | while read -r line
|
||||||
|
do
|
||||||
|
#################################################
|
||||||
|
radio=$(echo $line | cut -d "|" -f 1)
|
||||||
|
artist=$(echo $line | cut -d "|" -f 2)
|
||||||
|
song=$(echo $line | cut -d "|" -f 3)
|
||||||
|
echo "######## $radio ########" >> /tmp/youtube-dl.log 2>&1
|
||||||
|
echo $(date) >> /tmp/youtube-dl.log 2>&1
|
||||||
|
echo ${line} >> /tmp/youtube-dl.log 2>&1
|
||||||
|
|
||||||
|
#################################################
|
||||||
|
# YOUTUBE-DL SEARCH & COPY : "radio|artist|song"
|
||||||
|
if [[ "$artist" != "" && "$song" != "" && "$radio" != "" && "$radio" != "$song" && "$radio" != "undefined" && "$artist" != "$song" ]]; then
|
||||||
|
mkdir -p "/home/pi/music/${artist}/${song}"
|
||||||
|
~/parle.sh "Démarrage Enregistrement $radio."
|
||||||
|
~/parle.sh "$artist" "en-US"
|
||||||
|
~/parle.sh "$song" "en-US"
|
||||||
|
echo "Copy youtube-dl: $artist | $song ($radio)" >> /tmp/youtube-dl.log 2>&1
|
||||||
|
# Clean search string
|
||||||
|
mysearch=$(replace_accents "$artist $song")
|
||||||
|
if [[ "$mysearch" == "" ]]; then ~/parle.sh "Aucune recherche reçue!"; continue; fi
|
||||||
|
# Search & Download bestaudio from 1st video result (ogg / opus / m4a): MEDIUM CPU
|
||||||
|
# OPTION: --embed-thumbnail --metadata-from-title "%(artist)s - %(title)s" --add-metadata
|
||||||
|
youtube-dl --default-search ytsearch1: --download-archive /home/pi/.ytdl.list --continue --no-overwrites --metadata-from-title "$artist - %(title)s" --add-metadata --embed-thumbnail --ignore-errors -f m4a --extract-audio -o "/home/pi/music/${artist}/${song}/%(id)s.%(title)s.%(uploader_id)s.%(ext)s" "$mysearch" >> /tmp/youtube-dl.log 2>&1
|
||||||
|
# TODO: CHOOSE --metadata-from-title "$artist - %(title)s" or --metadata-from-title %(title)s"
|
||||||
|
# Update mpd playlist
|
||||||
|
curl -b "currenthost=Default;player_backend=mpd" http://localhost/albums.php?rebuild=yes > /dev/null
|
||||||
|
~/parle.sh "Enregistrement $radio terminé!"
|
||||||
|
######################################################
|
||||||
|
#### COPY LINK : "CopyLaRadio||https://link2media.url"
|
||||||
|
elif [[ "$radio" != "" && "$artist" == "" && "$song" != "" ]]; then
|
||||||
|
# LINK COPY
|
||||||
|
~/parle.sh "Copie du lien!"
|
||||||
|
echo "Copy LINK: $song" >> /tmp/youtube-dl.log 2>&1
|
||||||
|
mkdir -p /home/pi/download/
|
||||||
|
youtube-dl --download-archive /home/pi/.ytdl.list --continue --no-overwrites --embed-thumbnail --metadata-from-title "%(artist)s - %(title)s" --add-metadata -o "/home/pi/download/%(title)s.%(ext)s" "$song" >> /tmp/youtube-dl.log 2>&1
|
||||||
|
~/parle.sh "Enregistrement du lien terminé!"
|
||||||
|
######################################################
|
||||||
|
#### COPY LINK : "radio||"
|
||||||
|
elif [[ "$radio" != "" && "$artist" == "" && "$song" == "" ]]; then
|
||||||
|
# EXTERNAL PARSER: ADD SCRAPERS IN ./libradio
|
||||||
|
~/parle.sh "Recherche RADIO ${radio}"
|
||||||
|
echo "External search: ${radio}" >> /tmp/youtube-dl.log 2>&1
|
||||||
|
if [[ -f /home/pi/G1sms+/_CopyLaRadio/libradio/${radio}.php ]]; then
|
||||||
|
~/parle.sh "Module existant"
|
||||||
|
php "/home/pi/G1sms+/_CopyLaRadio/libradio/${radio}.php"
|
||||||
|
else
|
||||||
|
~/parle.sh "Aucun module de décodage pour cette radio."
|
||||||
|
fi
|
||||||
|
#### NOTHING GOOD
|
||||||
|
else
|
||||||
|
~/parle.sh "Rien à copier"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
################################################################################
|
||||||
|
# FROM CopyLaRadio MODULE_TEMPLATE_0.1
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Date: 2019 04 01
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
*/
|
||||||
|
// VARS INIT
|
||||||
|
$obj=$title=$artist=$emission=$ERR=$ontheair="";
|
||||||
|
///////////////////////////
|
||||||
|
// SET TO 1 DURING DEVLT
|
||||||
|
$debug=0;
|
||||||
|
///////////////////////////
|
||||||
|
// MODULE RADIO PARAMETERS
|
||||||
|
///////////////////////////
|
||||||
|
$RADIO = "FIP Electro";
|
||||||
|
$referer = "https://www.fip.fr/";
|
||||||
|
$radiourl = 'https://www.fip.fr/latest/api/graphql?operationName=Now&variables=%7B%22bannerPreset%22%3A%221400x1400%22%2C%22stationId%22%3A74%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%229551487ee4a6810ec4afa35e70dd1c204fa84db3519d39eb3176e5a3a8b0e482%22%7D%7D';
|
||||||
|
|
||||||
|
// TWEEK CLIENT & REFERER
|
||||||
|
ini_set('user_agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0');
|
||||||
|
$ctx = stream_context_create(array(
|
||||||
|
'http' => array(
|
||||||
|
'header'=>array("Referer: ".$referer.PHP_EOL),
|
||||||
|
'timeout' => 5
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
///////////////////////////
|
||||||
|
// LOAD RADIO PAGE INTO PARSER
|
||||||
|
$ontheair = file_get_contents($radiourl); // JSON CONTENT
|
||||||
|
$ontheair = utf8_encode($ontheair);
|
||||||
|
$obj = json_decode($ontheair, true);
|
||||||
|
|
||||||
|
|
||||||
|
// GET TRACK INFO: ADAPT WITH DATA STRUCTURE
|
||||||
|
// ADPAPT HERE
|
||||||
|
$current = $obj['data']['now']['playing_item'];
|
||||||
|
// GET TRACK INFO
|
||||||
|
if ( $current ) {
|
||||||
|
// ADPAPT HERE
|
||||||
|
$artist = ucwords(strtolower($current['title']));
|
||||||
|
$title = ucwords(strtolower($current['subtitle']));
|
||||||
|
|
||||||
|
if ( $debug != 0 ) $ERR .= "\nTITRE = ".print_r($title, true);
|
||||||
|
if ( $debug != 0 ) $ERR .= "\nARTISTE = ".print_r($artist, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
///////////////////////////
|
||||||
|
// PREPARE COPY COMMAND
|
||||||
|
$cmd = $RADIO.'|'.$artist.'|'.$title;
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// DEBUG OR PROD
|
||||||
|
if($debug == 1) {
|
||||||
|
print_r($obj);
|
||||||
|
print_r($cmd);
|
||||||
|
} else {
|
||||||
|
if( $artist != "" && $title != "" ) {
|
||||||
|
// TODO Clean strings?!
|
||||||
|
if (! exec('grep '.escapeshellarg($cmd).' /tmp/ytdl.list')) {
|
||||||
|
file_put_contents("/tmp/youtube-dl.log", "ARTIST: ".$artist.". SONG: ".$title, FILE_APPEND);
|
||||||
|
file_put_contents("/tmp/ytdl.list","$cmd\n", FILE_APPEND);
|
||||||
|
} else {
|
||||||
|
file_put_contents("/tmp/youtube-dl.log", "ALREADY THERE!", FILE_APPEND);
|
||||||
|
file_put_contents("/tmp/ytdl.list","||".PHP_EOL, FILE_APPEND);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file_put_contents("/tmp/youtube-dl.log", "NO TRACK. TRY PODCAST!", FILE_APPEND);
|
||||||
|
file_put_contents("/tmp/ytdl.list","||".PHP_EOL, FILE_APPEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
|
@ -0,0 +1 @@
|
||||||
|
radionova.php
|
|
@ -0,0 +1 @@
|
||||||
|
FIP autour de llectro.php
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
################################################################################
|
||||||
|
# FROM CopyLaRadio MODULE_TEMPLATE_0.1
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Date: 2019 04 01
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
*/
|
||||||
|
// VARS INIT
|
||||||
|
$obj=$title=$artist=$emission=$ERR=$ontheair="";
|
||||||
|
///////////////////////////
|
||||||
|
// SET TO 1 DURING DEVLT
|
||||||
|
$debug=0;
|
||||||
|
///////////////////////////
|
||||||
|
// MODULE RADIO PARAMETERS
|
||||||
|
///////////////////////////
|
||||||
|
$RADIO = "RADIO NOVA";
|
||||||
|
$referer = "http://www.nova.fr/";
|
||||||
|
$radiourl = 'http://www.nova.fr/radio/19577/player';
|
||||||
|
|
||||||
|
// TWEEK CLIENT & REFERER
|
||||||
|
ini_set('user_agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0');
|
||||||
|
$ctx = stream_context_create(array(
|
||||||
|
'http' => array(
|
||||||
|
'header'=>array("Referer: ".$referer.PHP_EOL),
|
||||||
|
'timeout' => 5
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
///////////////////////////
|
||||||
|
// LOAD RADIO PAGE INTO PARSER
|
||||||
|
$ontheair = file_get_contents($radiourl); // JSON CONTENT
|
||||||
|
$ontheair = utf8_encode($ontheair);
|
||||||
|
$obj = json_decode($ontheair, true);
|
||||||
|
|
||||||
|
|
||||||
|
// GET TRACK INFO: ADAPT WITH DATA STRUCTURE
|
||||||
|
// ADPAPT HERE
|
||||||
|
if ( $obj['currentTrack'] ) {
|
||||||
|
|
||||||
|
// ADPAPT HERE
|
||||||
|
$title = ucwords(strtolower($obj['currentTrack']['title']));
|
||||||
|
$artist = ucwords(strtolower($obj['currentTrack']['artist']));
|
||||||
|
|
||||||
|
if ( $debug != 0 ) $ERR .= "\nTITRE = ".print_r($title, true);
|
||||||
|
if ( $debug != 0 ) $ERR .= "\nARTISTE = ".print_r($artist, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
///////////////////////////
|
||||||
|
// PREPARE COPY COMMAND
|
||||||
|
$cmd = $RADIO.'|'.$artist.'|'.$title;
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// DEBUG OR PROD
|
||||||
|
if($debug == 1) {
|
||||||
|
print_r($obj);
|
||||||
|
print_r($cmd);
|
||||||
|
} else {
|
||||||
|
if( $artist != "" && $title != "" ) {
|
||||||
|
// TODO Clean strings?!
|
||||||
|
if (! exec('grep '.escapeshellarg($cmd).' /tmp/ytdl.list')) {
|
||||||
|
file_put_contents("/tmp/youtube-dl.log", "ARTIST: ".$artist.". SONG: ".$title, FILE_APPEND);
|
||||||
|
file_put_contents("/tmp/ytdl.list","$cmd\n", FILE_APPEND);
|
||||||
|
} else {
|
||||||
|
file_put_contents("/tmp/youtube-dl.log", "ALREADY THERE!", FILE_APPEND);
|
||||||
|
file_put_contents("/tmp/ytdl.list","||".PHP_EOL, FILE_APPEND);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file_put_contents("/tmp/youtube-dl.log", "NO TRACK. TRY PODCAST!", FILE_APPEND);
|
||||||
|
file_put_contents("/tmp/ytdl.list","||".PHP_EOL, FILE_APPEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
f=$(echo "$1" | sed 's/ //g' )
|
||||||
|
echo "parle.sh: $1 | $2 = $f" >> /tmp/youtube-dl.log 2>&1
|
||||||
|
if [[ "$2" == "" ]]; then
|
||||||
|
lang="fr-FR"
|
||||||
|
else
|
||||||
|
lang="en-US"
|
||||||
|
fi
|
||||||
|
if [[ ! -f "/tmp/$lang_${f}.wav" ]]; then
|
||||||
|
pico2wave -l $lang -w /tmp/$lang_${f}.wav "$1"
|
||||||
|
fi
|
||||||
|
aplay -q /tmp/$lang_${f}.wav
|
|
@ -0,0 +1,212 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# BUTTONS GPIO NUMBERS FOR PHAT BEAT
|
||||||
|
# https://pinout.xyz/pinout/phat_beat#
|
||||||
|
# ADD TO /etc/local for autostart
|
||||||
|
#
|
||||||
|
ONOFF=12
|
||||||
|
VOLUP=16
|
||||||
|
VOLDO=26
|
||||||
|
BCK=13
|
||||||
|
PLAY=6
|
||||||
|
FWD=5
|
||||||
|
|
||||||
|
# ADD YOUR DEFAULT RADIO STREAM / PLAYLIST HERE - TRACK INFORMATION FOR RECORDING ;)
|
||||||
|
PLAYLIST="/home/pi/playlists/default.m3u"
|
||||||
|
|
||||||
|
function trim() {
|
||||||
|
local var="$*"
|
||||||
|
# remove slashes
|
||||||
|
var=$(echo "$var" | sed 's/\// /g')
|
||||||
|
var=${var//[^a-zA-Z0-9_\. ]/}
|
||||||
|
# remove leading whitespace characters
|
||||||
|
var="${var#"${var%%[![:space:]]*}"}"
|
||||||
|
# remove trailing whitespace characters
|
||||||
|
var="${var%"${var##*[![:space:]]}"}"
|
||||||
|
|
||||||
|
echo -n "$var"
|
||||||
|
}
|
||||||
|
|
||||||
|
function button() {
|
||||||
|
pin=$1
|
||||||
|
gpio -g mode $pin in # make sure pin is configured as an input
|
||||||
|
gpio -g mode $pin up # enable pull-up resistor
|
||||||
|
boucle=0
|
||||||
|
|
||||||
|
while :; do
|
||||||
|
gpio -g wfi $pin falling # wait for a button action
|
||||||
|
sleep 0.2
|
||||||
|
echo $pin
|
||||||
|
while [[ $(gpio -g read $pin) -eq 0 ]]
|
||||||
|
do
|
||||||
|
aplay bip.wav
|
||||||
|
sleep 0.5 # COUNT 1/2 SECOND PRESSED
|
||||||
|
boucle=$(bc -l <<< "$boucle + 1")
|
||||||
|
done
|
||||||
|
if [[ $boucle -gt 0 ]]; then
|
||||||
|
echo "LP-$pin-$boucle"
|
||||||
|
fi
|
||||||
|
boucle=0
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
boucle=0
|
||||||
|
|
||||||
|
# --- main loop ---
|
||||||
|
while :; do
|
||||||
|
read numbut
|
||||||
|
|
||||||
|
# WHAT IS ON AIR
|
||||||
|
watch="$(mpc | head -1):"
|
||||||
|
|
||||||
|
# EXTRACT ($radio :) $artist - $song
|
||||||
|
radio=$(echo "$watch" | cut -d ":" -f 1 | xargs)
|
||||||
|
if [[ "$radio" != "$watch" && $radio != "volume" && $radio != "http" ]]; then RADIO="$radio"; else radio="$watch"; RADIO=""; fi
|
||||||
|
play=$(echo "$watch" | cut -d ":" -f 2)
|
||||||
|
artist=$(echo "$play" | cut -d "-" -f 1)
|
||||||
|
artist=$(trim "$artist")
|
||||||
|
song=$(echo "$play" | cut -d "-" -f 2)
|
||||||
|
song=$(trim "$song")
|
||||||
|
if [[ "$song" == "" ]]; then
|
||||||
|
song=$(echo "$play" | cut -d " " -f 2)
|
||||||
|
song=$(trim "$song")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: ADAPT BEHAVIOUR TO EACH RADIO STREAM
|
||||||
|
# NOVA RADIO PATCH
|
||||||
|
if [[ "$radio" == "Nova zz" ]]; then
|
||||||
|
artist=""
|
||||||
|
song=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "(CLICK $numbut) $RADIO: $artist / $song"
|
||||||
|
|
||||||
|
case "$numbut" in
|
||||||
|
$ONOFF)
|
||||||
|
echo "REC"
|
||||||
|
# BUTTON QUICK RELEASE
|
||||||
|
if [[ $(gpio -g read $ONOFF) -eq 1 ]]; then
|
||||||
|
# RECORD STREAMING SONG::GENERIC
|
||||||
|
if [[ "$RADIO" != "" && "$artist" != "" && "$song" != "" && "$artist" != "$song" ]]; then
|
||||||
|
what=$(grep "$RADIO|$artist|$song" /tmp/ytdl.list)
|
||||||
|
if [[ "$what" == "" ]]; then
|
||||||
|
~/parle.sh "Enregistrement ajouté."
|
||||||
|
echo "$RADIO|$artist|$song" >> /tmp/ytdl.list
|
||||||
|
else
|
||||||
|
~/parle.sh "Enregistrement déjà existant!"
|
||||||
|
fi
|
||||||
|
elif [[ "$artist" == "$song" ]]; then
|
||||||
|
~/parle.sh "Enregistrement $radio"
|
||||||
|
# USE COPY & MODULE FIFO
|
||||||
|
echo "$radio||" >> /tmp/ytdl.list # TODO REMOVE
|
||||||
|
else
|
||||||
|
~/parle.sh "Podcast ou Fichier local. Enregistrement inopérant."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
LP-$ONOFF-*)
|
||||||
|
# LONG PRESS TRACK IDENTIFICATION
|
||||||
|
playing=$(mpc | head -1 | cut -d ":" -f 1 | cut -d "/" -f 1 | xargs)
|
||||||
|
playing=$(trim "$playing")
|
||||||
|
~/parle.sh "$playing"
|
||||||
|
if [[ "$RADIO" != "" && "$artist" != "" && "$song" != "" && "$artist" != "$song" ]]; then
|
||||||
|
~/parle.sh "$artist - $song"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
$PLAY)
|
||||||
|
echo "PLAY"
|
||||||
|
if [[ $(gpio -g read $PLAY) -eq 1 ]]; then
|
||||||
|
mpc toggle
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
LP-$PLAY-*)
|
||||||
|
sec=$(echo "$numbut" | cut -d "-" -f 3)
|
||||||
|
case "$sec" in
|
||||||
|
1)
|
||||||
|
# 1SEC
|
||||||
|
# Check if USB drive connected
|
||||||
|
if [[ -b /dev/sda1 ]]; then
|
||||||
|
~/parle.sh "Synchronisation musique sur clé U S B. Veuillez patienter"
|
||||||
|
sudo mount /dev/sda1 /mnt
|
||||||
|
sudo mkdir -p /mnt/CopyLaRadio
|
||||||
|
sudo rsync -rtgoDv /home/pi/music/ /mnt/CopyLaRadio
|
||||||
|
sudo umount /dev/sda1
|
||||||
|
~/parle.sh "Transfert terminé. Vous pouvez débrancher votre clé..."
|
||||||
|
else
|
||||||
|
# STOP MUSIC
|
||||||
|
~/parle.sh "STOP"
|
||||||
|
mpc stop
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
# 2SEC = CHANGE MODE SHUFFLE LOCAL / DEFAULT PLAYLIST
|
||||||
|
if [[ "$RADIO" != "" && "$mode" == "" ]]; then
|
||||||
|
mode="LOCAL"
|
||||||
|
~/parle.sh "Lecture musique locale"
|
||||||
|
mpc clear
|
||||||
|
mpc listall | mpc add
|
||||||
|
mpc shuffle
|
||||||
|
~/parle.sh "Aléatoire"
|
||||||
|
mpc play
|
||||||
|
else
|
||||||
|
mode=""
|
||||||
|
mpc clear
|
||||||
|
mpc load default
|
||||||
|
~/parle.sh "Lecture liste par défaut"
|
||||||
|
mpc play
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
# 3 SEC = HALT SYSTEM
|
||||||
|
~/parle.sh "Arrêt RAIQUE MACHINE"
|
||||||
|
sudo halt
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# > 3 SEC = REBOOT SYSTEM
|
||||||
|
~/parle.sh "Redémarrage RAIQUE MACHINE"
|
||||||
|
sudo reboot
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
$BCK)
|
||||||
|
echo "BCK"
|
||||||
|
mpc -q prev
|
||||||
|
;;
|
||||||
|
$FWD)
|
||||||
|
echo "FWD"
|
||||||
|
mpc -q next
|
||||||
|
;;
|
||||||
|
$VOLUP)
|
||||||
|
echo "VOLUP"
|
||||||
|
if [[ $(gpio -g read $VOLUP) -eq 1 ]]; then
|
||||||
|
mpc -q volume +10
|
||||||
|
vol=$(mpc volume | cut -f 2 -d ":")
|
||||||
|
vol=$(trim "$vol")
|
||||||
|
if [ "$vol" == "100%" ]; then ~/parle.sh "VOLUME MAXIMUM"; fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
LP-$VOLUP-*)
|
||||||
|
sec=$(echo "$numbut" | cut -d "-" -f 3)
|
||||||
|
sec=+$(bc -l <<< "$sec * 10")
|
||||||
|
mpc -q volume $sec
|
||||||
|
;;
|
||||||
|
$VOLDO)
|
||||||
|
echo "VOLDO"
|
||||||
|
if [[ $(gpio -g read $VOLDO) -eq 1 ]]; then
|
||||||
|
mpc -q volume -10
|
||||||
|
vol=$(mpc volume | cut -f 2 -d ":")
|
||||||
|
vol=$(trim "$vol")
|
||||||
|
if [ "$vol" == "0%" ]; then ~/parle.sh "VOLUME MINIMUM"; fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
LP-$VOLDO-*)
|
||||||
|
sec=$(echo "$numbut" | cut -d "-" -f 3)
|
||||||
|
sec=-$(bc -l <<< "$sec * 10")
|
||||||
|
mpc -q volume $sec
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $numbut
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
done < <( button $ONOFF & button $VOLUP & button $VOLDO & button $BCK & button $PLAY & button $FWD & ) # buttons on GPIOs to monitor
|
||||||
|
|
|
@ -0,0 +1,164 @@
|
||||||
|
Create BASIC IPNS _official IPFS HASH _chain (with iterative backup to _nanodate time, _zen / _g1 values + _external UID references): backup.sh
|
||||||
|
Ajout de paramètres à la capsule IPNS/IPFS. _id et du backup autosigné de la clef de publication ipfs _publishkey.gpg
|
||||||
|
Hop +1
|
||||||
|
GO
|
||||||
|
HOP
|
||||||
|
update.sh
|
||||||
|
Add init.sh
|
||||||
|
RUN ./install.sh then ./shell/cron/update.sh
|
||||||
|
base64 "/home/$YOU/.ipfs/keystore/SWARM_CODE_MASTER" for IPNS key
|
||||||
|
fn_exists()
|
||||||
|
ET LA CA PROPAGE
|
||||||
|
/ipns/QmZHTne3bjtMgaXWRqSbdKchJbgq2NaAeVSzFUN7ceYpif/install.sh
|
||||||
|
again
|
||||||
|
oui
|
||||||
|
|
||||||
|
_publishkey.pgp SWARM_CODE_MASTER
|
||||||
|
HELLO
|
||||||
|
DEBUG DAY
|
||||||
|
MORE DEBUG. VIR RECURRENT IS ALMOST WORKING
|
||||||
|
SMS TESTS & DEBUG
|
||||||
|
OK
|
||||||
|
BACKUP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OK
|
||||||
|
2019-10-24: install.sh
|
||||||
|
2019-10-24:
|
||||||
|
2019-10-24:
|
||||||
|
2019-10-24:
|
||||||
|
2019-10-24: install.sh
|
||||||
|
2019-10-24: ipfs cat /ipns/QmZHTne3bjtMgaXWRqSbdKchJbgq2NaAeVSzFUN7ceYpif/CODE/install.sh | bash
|
||||||
|
2019-10-25:
|
||||||
|
2019-10-25: config.sh
|
||||||
|
2019-11-02: BACKUP
|
||||||
|
2019-11-04: Woooo too long to explain. G1Tag remake
|
||||||
|
2019-11-04: encore
|
||||||
|
2019-11-04: tag_READ.sh
|
||||||
|
2019-11-04: YOU fix
|
||||||
|
2019-11-04: cleaning
|
||||||
|
2019-11-04:
|
||||||
|
2019-11-04: gpg -d --output /tmp/ipns.key --passphrase $B /tmp/TAG_publishkey.B.gpg
|
||||||
|
2019-11-04: --pinentry-mode=loopback
|
||||||
|
2019-11-04: parle
|
||||||
|
2019-11-04: .
|
||||||
|
2019-11-04: 01
|
||||||
|
2019-11-04:
|
||||||
|
2019-11-04:
|
||||||
|
2019-11-04: tag READ
|
||||||
|
2019-11-04: echo
|
||||||
|
2019-11-04: tag actions
|
||||||
|
2019-11-04:
|
||||||
|
2019-11-04: tag_READ
|
||||||
|
2019-11-04: LOVE
|
||||||
|
2019-11-04: YOU=$(ps auxf --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
2019-11-04: g1sms.priv.key
|
||||||
|
2019-11-04: next
|
||||||
|
2019-11-04:
|
||||||
|
2019-11-04:
|
||||||
|
2019-11-04: tag
|
||||||
|
2019-11-04:
|
||||||
|
2019-11-05: hummmm
|
||||||
|
2019-11-05: backup
|
||||||
|
2019-11-05:
|
||||||
|
2019-11-05: CASHBACK
|
||||||
|
2019-11-05: checkonenode
|
||||||
|
2019-11-05: G1tag read
|
||||||
|
2019-11-05: NN
|
||||||
|
2019-11-05:
|
||||||
|
2019-11-06: time for a backup
|
||||||
|
2019-11-06: bad start
|
||||||
|
2019-11-06: YOU=$(ps auxf --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
2019-11-06: DU
|
||||||
|
2019-11-06: Update _DU value
|
||||||
|
2019-11-06:
|
||||||
|
2019-11-06: SMSNODE
|
||||||
|
2019-11-06:
|
||||||
|
2019-11-06: toucassé
|
||||||
|
2019-11-06: bug init.sh
|
||||||
|
2019-11-06: config.sh
|
||||||
|
2019-11-06:
|
||||||
|
2019-11-06:
|
||||||
|
2019-11-06: echo ipfs_swarm_wallets_refresh
|
||||||
|
2019-11-06: sms_INIT_ACCOUNT migration old G1sms wallets params
|
||||||
|
2019-11-06: HISTORY files modification
|
||||||
|
2019-11-06:
|
||||||
|
2019-11-07: yeah
|
||||||
|
2019-11-08: oula
|
||||||
|
2019-11-08: correct
|
||||||
|
2019-11-08: hop
|
||||||
|
2019-11-08: bugs
|
||||||
|
2019-11-08: ouep
|
||||||
|
2019-11-14: After Crash and restore on better SDcard
|
||||||
|
2019-11-15:
|
||||||
|
2019-11-15: waiwai
|
||||||
|
2019-11-15: TASK s
|
||||||
|
2019-11-15:
|
||||||
|
2019-11-15:
|
||||||
|
2019-11-15: sais plius
|
||||||
|
2019-11-16: remote G1DAB MINUTE PRINT
|
||||||
|
2019-11-16: tag READ OP
|
||||||
|
2019-11-16: /
|
||||||
|
2019-11-16: tag_OP.sh
|
||||||
|
2019-11-16: tag READ
|
||||||
|
2019-11-16:
|
||||||
|
2019-11-16: tag_READ.sh and tag_OP.sh OK. Need sudo pip3 install duniterpy for natools.py to work
|
||||||
|
2019-11-16: TASK bug
|
||||||
|
2019-11-17: value
|
||||||
|
2019-11-17: clean PRINT
|
||||||
|
2019-11-19:
|
||||||
|
2019-11-19:
|
||||||
|
2019-11-19:
|
||||||
|
2019-11-19:
|
||||||
|
2019-11-19: self
|
||||||
|
2019-11-19: PASSENGER
|
||||||
|
2019-11-19:
|
||||||
|
2019-11-19: PRINT clean
|
||||||
|
2019-11-19: email
|
||||||
|
2019-11-19: mail
|
||||||
|
2019-11-19: emial
|
||||||
|
2019-11-19: upgrades
|
||||||
|
2019-11-19: ameliorations
|
||||||
|
2019-11-19: qr code
|
||||||
|
2019-11-19: install.sh su £YOU ips
|
||||||
|
2019-11-20: gpg -d --output /tmp/ipns.key --pinentry-mode=loopback --passphrase $BB /tmp/TAG_publishkey.B.gpg
|
||||||
|
2019-11-20:
|
||||||
|
2019-11-20: FID
|
||||||
|
2019-11-20: tag READ problem
|
||||||
|
2019-11-20: hop
|
||||||
|
2019-11-20: read line
|
||||||
|
2019-11-20: cat /dev/ttyACM0
|
||||||
|
2019-11-20: tag read
|
||||||
|
2019-11-20: TAG_passenger
|
||||||
|
2019-11-22: REC TIME - 1
|
||||||
|
2019-11-22: VIR recurrents check and removal
|
||||||
|
2019-11-23: LOAD passenger
|
||||||
|
2019-11-23: chmod 755 shell/*.sh
|
||||||
|
2019-11-23:
|
||||||
|
2019-11-23:
|
||||||
|
2019-11-23: fi
|
||||||
|
2019-11-23: bug
|
||||||
|
2019-11-23: REC Tag ready?
|
||||||
|
2019-11-23:
|
||||||
|
2019-11-23: yep
|
||||||
|
2019-11-23:
|
||||||
|
2019-11-24: rompr
|
||||||
|
2019-11-24: chown www-data prefs/ albumart/
|
||||||
|
2019-11-24: 777 for rompr variables
|
||||||
|
2019-11-24: echo "" > www/rompr-1.32.zip
|
||||||
|
2019-11-24:
|
||||||
|
2019-11-24: Rompr patch [REC]
|
||||||
|
2019-11-24: infobar2.js
|
||||||
|
2019-11-24: FID=$(echo $ID | awk '{print toupper($1)}')
|
||||||
|
2019-11-24: fip electro
|
||||||
|
2019-11-24: FIP
|
||||||
|
2019-11-24: Nova
|
||||||
|
2019-11-25: Nova zz
|
||||||
|
2019-11-25: NODE = $IPFSNODEID
|
||||||
|
2019-11-25: for id in ./wallets_swarm/.Qm*/ instead of ipfs swarm peers
|
||||||
|
2019-11-25:
|
||||||
|
2019-11-26: clean
|
||||||
|
2019-11-27: sms
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
now=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
|
echo "Ce script configure votre noeud G1sms+ (effacez ./shell/init.sh avant de le lancer)"
|
||||||
|
IPFS=$(ps auxf --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1);
|
||||||
|
|
||||||
|
if [[ -f ./shell/init.sh.template && ! -f ./shell/init.sh ]]; then
|
||||||
|
echo "Quel est l'utilisateur du système IPFS (détecté: $IPFS)?"
|
||||||
|
read YOU
|
||||||
|
if [[ "$YOU" == "" ]]; then YOU=$IPFS; fi
|
||||||
|
|
||||||
|
echo "Votre PSEUDO? (celui de votre Compte membre Duniter)"
|
||||||
|
read ADMINPSEUDO
|
||||||
|
if [[ "$ADMINPSEUDO" == "" ]]; then echo "IMPOSSIBLE DE CONTINUER"; exit; fi
|
||||||
|
|
||||||
|
echo "Le Numéro de téléphone SMS Admin? (Support de ce noeud) (ex +33611223344)"
|
||||||
|
read ADMINPHONE
|
||||||
|
if [[ "$ADMINPHONE" == "" ]]; then echo "IMPOSSIBLE DE CONTINUER"; exit; fi
|
||||||
|
|
||||||
|
echo "Le numéro de la carte SIM, du module SMS? (ex +33611223344)"
|
||||||
|
read MASTERPHONE
|
||||||
|
|
||||||
|
echo "L'adresse où se trouve votre G1Node pour indiquer où venir chercher ses G1Tag (ex: au G1FabLab de Toulouse)"
|
||||||
|
read ADRESSE
|
||||||
|
|
||||||
|
sed -i s/pi/$YOU/g ./shell/init.sh.template
|
||||||
|
sed -i s/+33660780131/$MASTERPHONE/g ./shell/init.sh.template
|
||||||
|
sed -i s/au\ G1FabLab\ de\ Toulouse/$ADRESSE/g ./shell/init.sh.template
|
||||||
|
sed -i s/+33647683646/$ADMINPHONE/g ./shell/init.sh.template
|
||||||
|
sed -i s/Fred/$ADMINPSEUDO/g ./shell/init.sh.template
|
||||||
|
|
||||||
|
cat ./shell/init.sh.template
|
||||||
|
|
||||||
|
echo "LES PARAMETRES SONT BONS? Appliquer? ENTER ou CTRL-C ?"
|
||||||
|
read
|
||||||
|
cp ./shell/init.sh.template ./shell/init.sh
|
||||||
|
fi
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
From: support@qo-op.com
|
||||||
|
To: EMAIL
|
||||||
|
Subject: SUBJECT
|
||||||
|
MESSAGE
|
|
@ -0,0 +1 @@
|
||||||
|
8qs69HriAdytcCLzvQGJ15XBwpjAVFx8JoVM2ahue1y7
|
|
@ -0,0 +1,83 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# LE Freaking LOL Hackathon de Noël https://framadate.org/sviOUlP6JLyWq5D2XLEdcKY9/admin
|
||||||
|
#
|
||||||
|
now=$(date -u +%Y-%m-%d)
|
||||||
|
|
||||||
|
echo "Bonjour $USER, je vous souhaite bon jour ($now)"
|
||||||
|
echo "Ce script va installer / mettre à jour votre noeud G1sms dans /home/$USER/G1sms+"
|
||||||
|
echo "ATTENTION! Vous devez avoir installé la couche ipfs & mpd au préalable!!! ./install_ipfs_layer.sh"
|
||||||
|
IPFS=$(ps auxf --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1);
|
||||||
|
echo "Quel est l'utilisateur du système IPFS (détecté: $IPFS)?"
|
||||||
|
read YOU
|
||||||
|
if [[ "$YOU" == "" ]]; then YOU=$IPFS; fi
|
||||||
|
|
||||||
|
cd /home/$USER
|
||||||
|
echo "Déplacement dans /home/$USER/"
|
||||||
|
echo "... Téléchargement de la dernière version du CODE G1sms+ (ipfs = $YOU)"
|
||||||
|
|
||||||
|
# CODE is there?? Get it from ipns
|
||||||
|
ipfs get --output=./ /ipns/QmZHTne3bjtMgaXWRqSbdKchJbgq2NaAeVSzFUN7ceYpif
|
||||||
|
|
||||||
|
if [ ! -d ./G1sms+ ]; then
|
||||||
|
|
||||||
|
echo "RECHERCHE ET INSTALLATION DU CODE : G1sms+.latest.tgz "
|
||||||
|
if [[ -f "./CODE/G1sms+.latest.tgz" ]]; then
|
||||||
|
tar xzf ./CODE/G1sms+.latest.tgz
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "VOULEZ VOUS CONFIGURER VOTRE NODE G1sms+ ? ^C"
|
||||||
|
echo "Les paramètres se trouvent dans /home/$YOU/G1sms+/shell/init.sh"
|
||||||
|
read
|
||||||
|
|
||||||
|
echo "Votre PSEUDO? Celui de votre compte membre Duniter. (defaut: Fred)"
|
||||||
|
read ADMINPSEUDO
|
||||||
|
if [[ "$ADMINPSEUDO" == "" ]]; then ADMINPSEUDO="Fred"; fi
|
||||||
|
|
||||||
|
echo "Le Numéro de téléphone SMS Admin? Votre numéro de portable (defaut: +33647683646)"
|
||||||
|
read ADMINPHONE
|
||||||
|
if [[ "$ADMINPHONE" == "" ]]; then ADMINPHONE="+33647683646"; fi
|
||||||
|
|
||||||
|
echo "Le numéro de la carte SIM, du module SMS. AUCUNE liaison SMS? Laissez vide (défaut: +33611223344)"
|
||||||
|
read MASTERPHONE
|
||||||
|
if [[ "$MASTERPHONE" == "" ]]; then MASTERPHONE="+33611223344"; fi
|
||||||
|
|
||||||
|
# TODO ASK for GeoPoint
|
||||||
|
echo "L'adresse où se trouve votre G1Node pour indiquer où venir chercher les G1Tag imprimés (ex: au G1FabLab de Toulouse)"
|
||||||
|
read ADRESSE
|
||||||
|
z
|
||||||
|
cp /home/$YOU/G1sms+/shell/init.sh.template /home/$YOU/G1sms+/shell/init.sh
|
||||||
|
sed -i s/pi/$YOU/g /home/$YOU/G1sms+/shell/init.sh
|
||||||
|
sed -i s/+33660780131/$MASTERPHONE/g /home/$YOU/G1sms+/shell/init.sh
|
||||||
|
sed -i s/au\ G1FabLab\ de\ Toulouse/$ADRESSE/g /home/$YOU/G1sms+/shell/init.sh
|
||||||
|
sed -i s/+33647683646/$ADMINPHONE/g /home/$YOU/G1sms+/shell/init.sh
|
||||||
|
sed -i s/Fred/$ADMINPSEUDO/g /home/$YOU/G1sms+/shell/init.sh
|
||||||
|
|
||||||
|
echo "========================================="
|
||||||
|
echo "VERIFIEZ QUE LES PARAMETRES SONT BONS... "
|
||||||
|
echo "========================================="
|
||||||
|
cat /home/$YOU/G1sms+/shell/init.sh
|
||||||
|
echo "========================================="
|
||||||
|
echo "CONFIG: vi /home/$YOU/G1sms+/shell/init.sh "
|
||||||
|
echo "========================================="
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "VOUS AVEZ UNE VERSION de G1sms+ DEJA INSTALLEE. MISE A JOUR..."
|
||||||
|
tar xzf CODE/G1sms+.latest.tgz
|
||||||
|
|
||||||
|
cd G1sms+
|
||||||
|
# TODO
|
||||||
|
# sudo chown -R $YOU ./TAG
|
||||||
|
# sudo chown -R $YOU ./wallets
|
||||||
|
echo "PREPARE rompr access from nginx"
|
||||||
|
mkdir -p ./www/rompr/prefs
|
||||||
|
mkdir -p ./www/rompr/albumarts
|
||||||
|
chmod 777 ./www/rompr/prefs
|
||||||
|
chmod 777 ./www/rompr/albumarts
|
||||||
|
|
||||||
|
echo "Version installée ($now):: IPFS chain :: $(cat ./_chain)"
|
||||||
|
fi
|
|
@ -0,0 +1,179 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
###########################################################################################
|
||||||
|
#######################################
|
||||||
|
# INSTALL IPFS on G1sms+ Pi NODES
|
||||||
|
#######################################
|
||||||
|
echo "DEFAULT INSTALL SCRIPT. VALIDATED ON RASPBERRYPI, SHOULD BE ADAPTED IF NOT ARM ARCH SYSTEM.
|
||||||
|
You are going to download and install ipfs daemon environement for running G1sms+ NODE.
|
||||||
|
TODO: TEST TEST TEST TEST + MANAGE DIFFERENT ARCH
|
||||||
|
Ready?"
|
||||||
|
read
|
||||||
|
|
||||||
|
if [[ "$USER" == "root" ]]; then echo "Better run by 'pi', please create non-root user and become that user before launching ipfs install..."; exit;
|
||||||
|
else echo "$USER, let's go!";
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "GET ipfs-update"
|
||||||
|
cd /usr/src/
|
||||||
|
sudo wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-arm.tar.gz
|
||||||
|
|
||||||
|
echo "INSTALL ipfs-update"
|
||||||
|
sudo tar xvzf ipfs-update_v1.5.2_linux-arm.tar.gz
|
||||||
|
cd ipfs-update
|
||||||
|
sudo ./install.sh
|
||||||
|
|
||||||
|
echo "INSTALL latest ipfs"
|
||||||
|
sudo ipfs-update install latest
|
||||||
|
|
||||||
|
echo "CREATE SYSTEMD ipfs SERVICE"
|
||||||
|
sudo cat > /etc/systemd/system/ipfs.service << EOF
|
||||||
|
[Unit]
|
||||||
|
Description=IPFS daemon
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=$USER
|
||||||
|
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --enable-gc
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable ipfs
|
||||||
|
|
||||||
|
################
|
||||||
|
# BECOME $USER
|
||||||
|
# INIT ipfs
|
||||||
|
ipfs init -p lowpower
|
||||||
|
|
||||||
|
# ACTIVATE CONFIG OPTIONS
|
||||||
|
# PUBSUB
|
||||||
|
ipfs config Pubsub.Router gossipsub
|
||||||
|
# MAXSTORAGE
|
||||||
|
ipfs config Datastore.StorageMax 12GB
|
||||||
|
## PORT FORWARD (SSH)
|
||||||
|
ipfs config --json Experimental.Libp2pStreamMounting true
|
||||||
|
|
||||||
|
######### UPDATE BOOTSTRAP LIST ###########
|
||||||
|
ipfs bootstrap rm --all
|
||||||
|
### fred@onelove.madeinzion.org ###
|
||||||
|
# ID: QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
||||||
|
ipfs bootstrap add /ip6/fe80::207:cbff:fe0b:75bb/tcp/4001/ipfs/QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
||||||
|
ipfs bootstrap add /ip4/51.15.2.211/tcp/4001/ipfs/QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
||||||
|
### ADD NEW SWARM LEADERS SERVER HERE ###
|
||||||
|
|
||||||
|
# ALLOW REMOTE SSH CONNECTION FROM rec OR onelove (For swarm.key & keystore exchange )
|
||||||
|
# ADD SSH ADMIN/SUPPORT USERS $(cat .ssh/id_rsa.pub)
|
||||||
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCs6oXRmPukaX7u2tDcFF1cecsDSEA30YyUqDaXSrw+yWQ8G79ktZ7BN0bPYBgfxO59FU8l5Jg1SPPG9kj81jfoCwGJpYdbczmMuP/iqw3aNoGv66swxwxzrqzbHrFFCXgn+6B2spDjn87tFB8JvQQTb2Kc4/sAZ9E6eY61pFiNpqbQehXdqSV5UemV9dkSQrnmJTl1PjUQ474AKQwFPzpdKHD/3VvqQS4i7ZLVeXS65euOP/YY8Bx9HvhsmhJ3h78OOK+D6GFfyv010xXBoG6kCSYR8LYMCEexpPGYV+Mduf/tUHjHP4GuWZAhd+wLRl0uPy6Tv7wHFfLyN01m/9vl fred@rec" >> ~/.ssh/authorized_keys
|
||||||
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFthQ3FggJlz/+ZglZJjVJzYs6ehx/iB7f89KY396K+7ai4ETqFhq6ANVp9xeQ4dLU26w0bFBELcnh9rn5QDSrXjsIptoWXErkSdZOeXqofnLtJEOhZO/I328y0C1vQRwtMMXKLLnqPe14h+zJenc7KJbL5cvB3Hd7nfQ+Q0uEnIsKb0f5wcKagySHIFdmY/FqaGz5g4MXGq7nlX/31hvfTFhF0g+k3mhvTTVQ368Op9qZZIozYhBoojWWvK5mwAovxdS9QT1hKrFXHfjov/aKQxLAy0a0oxFvHKoYN/l4ffGibFMAmedljTxf1VSDBv/k/RN53UU6RufW3qqBjY0b fred@onelove" >> ~/.ssh/authorized_keys
|
||||||
|
|
||||||
|
# START ipfs
|
||||||
|
sudo systemctl start ipfs
|
||||||
|
|
||||||
|
##################################
|
||||||
|
## INSTALL TOOLS
|
||||||
|
######## YOUTUBE-DL ##########
|
||||||
|
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
|
||||||
|
sudo chmod a+rx /usr/local/bin/youtube-dl
|
||||||
|
sudo apt install libid3-tools mpd mpc lame -y
|
||||||
|
|
||||||
|
## CONFIG MPD
|
||||||
|
sudo cat > /etc/mpd.conf << EOF
|
||||||
|
music_directory "/home/$USER/music"
|
||||||
|
playlist_directory "/home/$USER/playlists"
|
||||||
|
user "$USER"
|
||||||
|
bind_to_address "any"
|
||||||
|
auto_update "yes"
|
||||||
|
zeroconf_enabled "yes"
|
||||||
|
zeroconf_name "CopyLaRadio Music Recorder"
|
||||||
|
|
||||||
|
filesystem_charset "UTF-8"
|
||||||
|
id3v1_encoding "UTF-8"
|
||||||
|
###############################
|
||||||
|
|
||||||
|
audio_output {
|
||||||
|
type "pulse"
|
||||||
|
name "My Pulse Output"
|
||||||
|
server "127.0.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
audio_output {
|
||||||
|
type "httpd"
|
||||||
|
name "CopyLaRadio HTTP Stream"
|
||||||
|
encoder "lame"
|
||||||
|
port "8000"
|
||||||
|
quality "5.0"
|
||||||
|
# bitrate "128"
|
||||||
|
format "44100:16:1"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo chown -R $USER /var/lib/mpd/ /var/run/mpd /run/mpd /var/log/mpd
|
||||||
|
sudo service mpd restart
|
||||||
|
|
||||||
|
sudo apt-get install nginx php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm sqlite -y
|
||||||
|
sudo apt-get install lame sox libsox-fmt-mp3 eyed3 python-chardet libav-tools imagemagick curl -y
|
||||||
|
sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc libid3-tools espeak mpg321 fuse libttspico-utils atomicparsley -y
|
||||||
|
|
||||||
|
# CONFIG NGINX
|
||||||
|
sudo cat > /etc/nginx/sites-available/default << EOF
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
root /home/$USER/G1sms+/www/rompr;
|
||||||
|
index index.html index.htm index.nginx-debian.html;
|
||||||
|
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
location /g1tag {
|
||||||
|
proxy_pass http://127.0.0.1:81;
|
||||||
|
proxy_set_header Host \$host;
|
||||||
|
proxy_set_header X-Forwarded-For \$remote_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /code/ {
|
||||||
|
proxy_pass http://127.0.0.1:8080/ipns/QmZHTne3bjtMgaXWRqSbdKchJbgq2NaAeVSzFUN7ceYpif/;
|
||||||
|
proxy_set_header Host \$host;
|
||||||
|
proxy_set_header X-Real-IP \$remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /ipfs {
|
||||||
|
proxy_pass http://127.0.0.1:8080;
|
||||||
|
proxy_set_header Host \$host;
|
||||||
|
proxy_set_header X-Forwarded-For \$remote_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /ipns {
|
||||||
|
proxy_pass http://127.0.0.1:8080;
|
||||||
|
proxy_set_header Host \$host;
|
||||||
|
proxy_set_header X-Forwarded-For \$remote_addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo systemctl restart nginx
|
||||||
|
|
||||||
|
#################################
|
||||||
|
## Get _CopyLaRadio distrib
|
||||||
|
# ipfs get Qm.... > /tmp/copylaradio.zip
|
||||||
|
|
||||||
|
# Add CopyLaRadio to system PATH
|
||||||
|
#export PATH=$PATH:/home/$USER/_CopyLaRadio
|
||||||
|
# etc....
|
||||||
|
|
||||||
|
# INSTALL ROMPR WebSite LINKs
|
||||||
|
#sudo ln -s /home/$USER/_CopyLaRadio/www/rompr /var/www/rompr
|
||||||
|
#sudo chmod 777 /home/$USER/_CopyLaRadio/www/rompr/albumart
|
||||||
|
#sudo chmod 777 /home/$USER/_CopyLaRadio/www/rompr/prefs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# This script modify rc.local to start G1sms+ G1Tag, G1Tx and _CopyLaRadio scripts
|
||||||
|
######################################################################
|
||||||
|
# INJECT it self
|
||||||
|
######################################################################
|
||||||
|
inserted=$(grep -Rw "rc.local.sh" /etc/rc.local)
|
||||||
|
if [[ ! $inserted ]]; then
|
||||||
|
sed -i s/exit\ 0//g /etc/rc.local
|
||||||
|
echo "include /home/pi/G1sms+/rc.local.sh" >> /etc/rc.local
|
||||||
|
echo "exit 0" >> /etc/rc.local
|
||||||
|
fi
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
# mpd Runs like pi and some rights are bad!!
|
||||||
|
chown -R pi /var/run/mpd
|
||||||
|
chown -R pi /run/mpd
|
||||||
|
# RESET LOG
|
||||||
|
echo "" > /var/log/mpd/mpd.log
|
||||||
|
|
||||||
|
# CREATE EXCHANGE FILEs for pi & www-data
|
||||||
|
touch /tmp/ytdl.list
|
||||||
|
chmod 664 /tmp/ytdl.list
|
||||||
|
chown pi:www-data /tmp/ytdl.list
|
||||||
|
|
||||||
|
touch /tmp/youtube-dl.log
|
||||||
|
chmod 664 /tmp/youtube-dl.log
|
||||||
|
chown pi:www-data /tmp/youtube-dl.log
|
||||||
|
|
||||||
|
# LAUNCH BUTTONS WATCH
|
||||||
|
su pi -c "/home/pi/G1sms+/_CopyLaRadio/watch.sh &"
|
||||||
|
# LAUNCH COPY SCRIPT
|
||||||
|
su pi -c "/home/pi/G1sms+/_CopyLaRadio/copy.sh &"
|
||||||
|
|
||||||
|
# Print the IP address
|
||||||
|
_IP=$(hostname -I | cut -d " " -f 1) || true
|
||||||
|
if [ "$_IP" ]; then
|
||||||
|
printf "IP address is %s\n" "$_IP"
|
||||||
|
/home/pi/G1sms+/shell/parle.sh "Adresse IP: $_IP"
|
||||||
|
youtube-dl -U
|
||||||
|
/home/pi/G1sms+/shell/parle.sh "Mise à jour de Youtube DL. Terminé!"
|
||||||
|
#IPFS
|
||||||
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
if [[ "$YOU" != "" && "$YOU" != "root" ]]; then
|
||||||
|
/home/pi/G1sms+/shell/parle.sh "IPFS OK. Système de fichier interplanétaire activé."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
/home/pi/G1sms+/shell/parle.sh "Connexion Internet Impossible!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# LANCEMENT G1Tag READ
|
||||||
|
if [[ -e "/dev/ttyACM0" ]]; then
|
||||||
|
cd /home/pi/G1sms+ && ./shell/tag_READ.sh &
|
||||||
|
/home/pi/G1sms+/shell/parle.sh "Lecteur G1 tag"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -d "/home/pi/G1sms+/www/rompr" ]]; then
|
||||||
|
/home/pi/G1sms+/shell/parle.sh "Jukebox interplanétaire accessible"
|
||||||
|
fi
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
clear
|
||||||
|
echo "------------------------------------------------------------------------------"
|
||||||
|
if [ "$1" == "" ]; then
|
||||||
|
echo " Nothing to search for!"
|
||||||
|
else
|
||||||
|
echo " Searching for "$1" recursively. Please Wait..."
|
||||||
|
echo "------------------------------------------------------------------------------"
|
||||||
|
grep -h -r --exclude=B00 -H --colour=always "$1" ./
|
||||||
|
fi
|
||||||
|
echo "------------------------------------------------------------------------------"
|
||||||
|
if [ "$2" != "" ]; then
|
||||||
|
echo " To replace \"$1\" whith \"$2\", please run"
|
||||||
|
echo " grep -rl '$1' ./ | xargs sed -i 's/$1/$2/g'"
|
||||||
|
fi
|
||||||
|
|
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 253 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 14 KiB |
|
@ -0,0 +1 @@
|
||||||
|
duniter.moul.re:443
|
|
@ -0,0 +1,151 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Authors: @jytou (https://git.duniter.org/jytou)
|
||||||
|
# Modified by Fred (support@qo-op.com) to modifiy silkaj constant with best server
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# Checks the current block number of nodes.txt (is run in parallel) and output random (from last synchronized) node
|
||||||
|
# pip3 install duniterpy
|
||||||
|
# pip3 install silkaj --user
|
||||||
|
|
||||||
|
checkonenode()
|
||||||
|
{
|
||||||
|
# Timeout in seconds for https nodes
|
||||||
|
httpsTimeout=1
|
||||||
|
# Timeout in seconds for http nodes
|
||||||
|
httpTimeout=1
|
||||||
|
|
||||||
|
node=$1
|
||||||
|
watched=$2
|
||||||
|
outfile=$3
|
||||||
|
# Curl: -m timeout, -k ignore SSL certificate errors
|
||||||
|
cur=`echo "$( { curl -m $httpsTimeout -k https://$node/blockchain/current; } 2>&1 )"`
|
||||||
|
n=$node
|
||||||
|
if [[ "$cur" != *issuersFrameVar* ]]
|
||||||
|
then
|
||||||
|
# It failed in https, maybe try http?
|
||||||
|
cur=`echo "$( { curl -m $httpTimeout http://$node/blockchain/current; } 2>&1 )"`
|
||||||
|
if [[ "$cur" == *issuersFrameVar* ]]
|
||||||
|
then
|
||||||
|
# Indicate that the node is http
|
||||||
|
n="$n-(http)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ "$cur" != *issuersFrameVar* ]]
|
||||||
|
then
|
||||||
|
# The node didn't respond on time
|
||||||
|
cur="ERROR"
|
||||||
|
else
|
||||||
|
# The node did respond - grab the block number and hash of the block as key
|
||||||
|
cur="`echo "$cur"|grep '^ "number": '|awk '{print $2}'|awk -F, '{print $1}'`-`echo "$cur"|grep '^ "hash": '|awk '{print $2}'|awk '{print substr($1,2,13)}'`"
|
||||||
|
fi
|
||||||
|
if [[ $watched =~ .*#$node#.* ]]
|
||||||
|
then
|
||||||
|
# The node is a watched node, add some bold
|
||||||
|
n="\e[1m$n\e[0m"
|
||||||
|
fi
|
||||||
|
# Put the result into the file
|
||||||
|
echo "$cur $n">$outfile
|
||||||
|
# Notify that we're done here
|
||||||
|
touch $outfile.done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Temp dir where results are stored
|
||||||
|
DIR=/tmp/gnodewatch
|
||||||
|
export DIR
|
||||||
|
mkdir -p $DIR/chains
|
||||||
|
###########
|
||||||
|
# BANNISH DUNITER NODE?
|
||||||
|
# TODO: silkaj evolution!! Better CLI integration to make!
|
||||||
|
# Duniter Node is too slow or behave badly, remove it from nodes.txt list
|
||||||
|
BAN=$1
|
||||||
|
if [[ "$BAN" == "BAN" ]]; then
|
||||||
|
# Get actual Duniter node used by silkaj
|
||||||
|
SERVER=$(cat ./silkaj/src/constants.py | grep G1_DEFAULT_ENDPOINT | awk '{print $3}' | sed s/\"\,//g | sed s/\"//g)
|
||||||
|
echo $SERVER:443 >> ./shell/bad.nodes.txt
|
||||||
|
echo "$SERVER:443 IS NOW in ./shell/bad.nodes.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
### nodes.txt EMPTYNESS CARE
|
||||||
|
NBgood=$(cat ./shell/good.nodes.txt | wc -l)
|
||||||
|
NBbad=$(cat ./shell/bad.nodes.txt | wc -l)
|
||||||
|
if [[ $NBgood -le $NBbad ]]; then
|
||||||
|
echo "" > ./shell/good.nodes.txt
|
||||||
|
echo "" > ./shell/bad.nodes.txt
|
||||||
|
# TODO: Each decentralized App must have a source for its confidence to be UP and running and publishing latest code for our concensus behaviour!
|
||||||
|
echo "___ REFRESH ./shell/nodes.txt from g1.duniter.org:443 ___"
|
||||||
|
curl -s https://g1.duniter.org/network/peers | jq '.peers[] | .endpoints' | grep BMAS | awk '{print $2,$3}' | sed s/\"//g | sed s/\,//g | sed s/\ /:/g > "./shell/nodes.txt"
|
||||||
|
echo $(cat "./shell/nodes.txt")
|
||||||
|
fi
|
||||||
|
###########
|
||||||
|
# CONTINUE
|
||||||
|
|
||||||
|
# Grab the nodes we are actively watching - they will be in bold in the final output
|
||||||
|
watched=`grep -v "#" ./shell/nodes.txt|egrep "\!$"|awk '{print "#" $1 "#"}'`
|
||||||
|
# All nodes we are watching
|
||||||
|
nodes=`grep -v "#" ./shell/nodes.txt|awk '{print $1}'`
|
||||||
|
# The index to generate separate file names
|
||||||
|
index=0
|
||||||
|
# Wipe out the output directory
|
||||||
|
rm $DIR/*out $DIR/*done $DIR/chains/* $DIR/NODE.* 2>/dev/null
|
||||||
|
|
||||||
|
# Query all nodes in parallel
|
||||||
|
for node in $nodes
|
||||||
|
do
|
||||||
|
checkonenode $node "$watched" $DIR/$index.out &
|
||||||
|
((index++))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Wait a little for the first files to be created
|
||||||
|
sleep 1s
|
||||||
|
# Wait for all the threads to report they are done
|
||||||
|
while [ `ls $DIR/*done|wc -l` -lt $index ]
|
||||||
|
do
|
||||||
|
sleep 1s
|
||||||
|
done
|
||||||
|
|
||||||
|
# Grab all results
|
||||||
|
curs=`cat $DIR/*out|sort`
|
||||||
|
# Extract all forks, excluding all errors
|
||||||
|
chains="`echo "$curs"|grep -v ERROR|awk '{print $1}'|sort -r|uniq`"
|
||||||
|
|
||||||
|
# Count the number of chains and output most recent consensus to "good.nodes.txt"
|
||||||
|
nb=0
|
||||||
|
for chain in $chains
|
||||||
|
do
|
||||||
|
echo "$curs" | egrep "^$chain " | awk '{print $2}' >> $DIR/chains/$nb;
|
||||||
|
((nb++))
|
||||||
|
done
|
||||||
|
|
||||||
|
longchain=$(ls -S /tmp/gnodewatch/chains/ | head -n 1)
|
||||||
|
cp /tmp/gnodewatch/chains/$longchain "./shell/good.nodes.txt"
|
||||||
|
|
||||||
|
#####################################################################################
|
||||||
|
# ASK peers to all good.nodes.txt
|
||||||
|
#for node in $(cat ./shell/good.nodes.txt); do
|
||||||
|
# NANODATE=$(date +%s%N);
|
||||||
|
# DUN="https://$(echo $node| cut -d ":" -f 1)";
|
||||||
|
# curl -s -o $DIR/NODE.$NANODATE.$node ${DUN}/network/peers;
|
||||||
|
#done
|
||||||
|
|
||||||
|
# REFRESH from all known peers NEW nodes.txt
|
||||||
|
#cat /tmp/gnodewatch/NODE.* | jq '.peers[] | .endpoints' | grep BMAS | awk '{print $2,$3}' | sed s/\"//g | sed s/\,//g | sed s/\ /:/g | sort | uniq > "./shell/nodes.txt"
|
||||||
|
#####################################################################################
|
||||||
|
|
||||||
|
# Output Random actual best node
|
||||||
|
# Compare with ./shell/bad.nodes.txt
|
||||||
|
while [[ "$BAD" == "$DUNITER" ]]; do
|
||||||
|
DUNITER=$(shuf "./shell/good.nodes.txt" | head -n 1)
|
||||||
|
BAD=$(grep -Rw "$DUNITER" ./shell/bad.nodes.txt)
|
||||||
|
done
|
||||||
|
################# MODIFY silkaj constants.py
|
||||||
|
silkaj=$(echo $DUNITER | cut -d ":" -f 1)
|
||||||
|
if [[ "$silkaj" != "" && "$silkaj" != "https" ]]; then
|
||||||
|
#echo "PUT $silkaj SILKAJ PARAM"
|
||||||
|
cat ./silkaj/src/constants.default.py | sed s/duniter.moul.re/$silkaj/g > ./silkaj/src/constants.py
|
||||||
|
else
|
||||||
|
echo "RESTORE DEFAULT SILKAJ PARAM"
|
||||||
|
cp -f ./silkaj/src/constants.default.py ./silkaj/src/constants.py
|
||||||
|
fi
|
||||||
|
echo $DUNITER
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
# BACKUP G1sms+ current Devlt code and push it with MASTERKEYFILE encryption to IPFS
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
now=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
|
echo "COMMENTAIRES?"
|
||||||
|
read COMMENT
|
||||||
|
|
||||||
|
# CREATE CURRENT NODE "SWARM_CODE_MASTER" ipns key
|
||||||
|
if [[ ! -f "/home/$YOU/.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 "
|
||||||
|
echo "Utilisez le script ./G1sms+/install.sh pour installer ou mettre à jour votre noeud"
|
||||||
|
exit
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Backup $ROOT
|
||||||
|
dir=$(pwd | awk 'BEGIN { FS = "/" } ; {print $4}')
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# Create BASIC IPNS _official IPFS HASH _chain
|
||||||
|
# with iterative update _chain, _nanodate, _zen, _g1cents values
|
||||||
|
# + _external UID references & _comments lines
|
||||||
|
###########################################################################################
|
||||||
|
echo "PLEASE WAIT.... INITIALIZING G1 Object ipfs chain files:"
|
||||||
|
echo "GIT" > "./$dir/_type"
|
||||||
|
hop=$(cat "./$dir/_chain")
|
||||||
|
LASTDU=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1); curl -s ${DUNITER}/blockchain/block/${LASTDU} | jq '.dividend' > "./$dir/_DU";
|
||||||
|
echo "Valeur courante du DU=$(cat ./$dir/_DU) ZEN - CHAIN: $hop"
|
||||||
|
read
|
||||||
|
|
||||||
|
if [[ ! -f "./$dir/_id" ]]; then echo "SWARM_CODE_MASTER" > "./$dir/_id"; fi
|
||||||
|
if [[ ! -f "./$dir/_zen" ]]; then echo 0 > "./$dir/_zen"; fi
|
||||||
|
if [[ ! -f "./$dir/_g1cents" ]]; then echo 0 > "./$dir/_g1cents"; fi
|
||||||
|
if [[ ! -f "./$dir/_external" ]]; then echo "" > "./$dir/_external"; fi # Used to link to External UniqID
|
||||||
|
echo $(date +%s%N) > "./$dir/_nanodate"
|
||||||
|
|
||||||
|
echo "$now: $COMMENT" >> "./$dir/_comments"
|
||||||
|
|
||||||
|
# TAR ALL ARCHIVE FILES
|
||||||
|
tar -cvzf G1sms+_backup_$now.tar.gz --exclude 'init.sh' --exclude 'constants.py' --exclude 'TAG' --exclude 'history*' --exclude 'trash' --exclude 'print' --exclude 'wallets' --exclude 'wallets_swarm' --exclude 'g1sms.priv.key' ./$dir
|
||||||
|
|
||||||
|
mkdir -p /tmp/CODE/
|
||||||
|
mv G1sms+_backup_$now.tar.gz /tmp/CODE/G1sms+.latest.tgz
|
||||||
|
cp ./$dir/install*.sh /tmp/CODE/
|
||||||
|
|
||||||
|
# PUBLISH IT
|
||||||
|
hash=$(su $YOU -c "ipfs add -rq /tmp/CODE/ -w | tail -n 1")
|
||||||
|
|
||||||
|
echo $hash > "./$dir/_chain"
|
||||||
|
publish=$(su $YOU -c "ipfs name publish -k SWARM_CODE_MASTER --quieter /ipfs/${hash}")
|
||||||
|
echo $publish > "./$dir/_official"
|
||||||
|
|
||||||
|
rm -Rf /tmp/CODE
|
||||||
|
|
||||||
|
echo "_CHAIN: NEW /ipfs/$hash // $hop PUBLISHED with \"SWARM_CODE_MASTER\" key
|
||||||
|
ipfs get --output=./ /ipns/$publish"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
# BACKUP G1sms+ current Devlt code and push it with MASTERKEYFILE encryption to IPFS
|
||||||
|
################################################################################
|
||||||
|
## GET LATEST DEV $ROOT
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
now=$(date +%Y-%m-%d)
|
||||||
|
dir=$(pwd | awk 'BEGIN { FS = "/" } ; {print $4}')
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
publish=$(cat "./$dir/_official")
|
||||||
|
maillon=$(cat "./$dir/_chain")
|
||||||
|
if [[ "$publish" == "" ]]; then lev="ipfs"; hash="$maillon"; else lev="ipns"; hash="$publish"; fi
|
||||||
|
|
||||||
|
su $YOU -c "ipfs get --output=./ /$lev/$hash"
|
||||||
|
|
||||||
|
if [[ -f "./CODE/G1sms+.latest.tgz" ]]; then
|
||||||
|
echo "TODAY CODE FOUND... UNTAR in ls ./TODAY"
|
||||||
|
mkdir -p ./TODAY
|
||||||
|
cd TODAY
|
||||||
|
tar xvzf ../CODE/G1sms+.latest.tgz
|
||||||
|
# KEEP LOCAL NODE init.sh
|
||||||
|
if [[ ! -f "./$dir/shell/init.sh" ]]; then echo "backup restore problem..."; exit; fi
|
||||||
|
echo "REMOVE DEFAULT INIT..."
|
||||||
|
rm -f ./$dir/shell/init.sh
|
||||||
|
|
||||||
|
echo "DIFFERENCES ENTRE LES 2 VERSIONS:"
|
||||||
|
diff ./$dir/ ../$dir/
|
||||||
|
|
||||||
|
echo "VOULEZ VOUS METTRE A JOUR? Saisissez OUI"
|
||||||
|
read QUOI
|
||||||
|
if [[ "$QUOI" == "OUI" ]]; then sudo cp -Rf . ..; else echo "ANNULATION UPDATE"; exit; fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# TODO: SMS Alerte quand une annonce GCHANGE est proche du GeoPoint du téléphone/membre
|
||||||
|
#
|
||||||
|
# EXTRAIT LES DERNIERES ANNNONCES
|
||||||
|
# TODO Requête ES sur la distance directement !!!! @kimamila or http://www.elasticsearchtutorial.com/spatial-search-tutorial.html help?
|
||||||
|
|
||||||
|
CESIUM="https://g1.data.le-sou.org"
|
||||||
|
echo "Entrez PubKey"; read DESTRIB;
|
||||||
|
curl -sk ${CESIUM}/user/profile/${DESTRIB} -o /tmp/profile.json
|
||||||
|
LON=$(cat /tmp/profile.json | jq '._source.geoPoint.lon')
|
||||||
|
LAT=$(cat /tmp/profile.json | jq '._source.geoPoint.lat')
|
||||||
|
|
||||||
|
if [[ "$LON" != "null" ]]; then
|
||||||
|
curl -sk -XPOST 'https://data.gchange.fr/market/record/_search?pretty&_source=title' -d '
|
||||||
|
{
|
||||||
|
"size": 100,
|
||||||
|
"query": {
|
||||||
|
"bool": {
|
||||||
|
"filter": [{
|
||||||
|
"geo_distance": {
|
||||||
|
"distance": "100km",
|
||||||
|
"geoPoint": {
|
||||||
|
"lat": '$LAT',
|
||||||
|
"lon": '$LON'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' | jq
|
||||||
|
else
|
||||||
|
echo "Aucune coordonnées geoPoint pour $DESTRIB"
|
||||||
|
fi
|
||||||
|
|
||||||
|
TOTAL=$(curl -s https://data.gchange.fr/market/record/_search | jq .hits.total)
|
||||||
|
echo "TOTAL ANNONCES GCHANGE: $TOTAL"
|
||||||
|
chunk=0
|
||||||
|
while [[ $chunk -lt $TOTAL ]]; do
|
||||||
|
for res in $(curl -s https://data.gchange.fr/market/record/_search?from=$chunk | jq .hits.hits[]._id | sed s/\"//g ) do;
|
||||||
|
echo $res;
|
||||||
|
# curl -s --create-dirs -o ./gchange/$ID.json -s https://data.gchange.fr/market/record/$ID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,thumbnail._content_type,picturesCount,type,stock,fees,feesCurrency,geoPoint
|
||||||
|
done
|
||||||
|
chunk=$((chunk+10))
|
||||||
|
done
|
|
@ -0,0 +1,109 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# CE FICHIER cron_MINUTE.sh EST EXECUTE TOUTES LES MINUTES
|
||||||
|
# IL CONSTITUE LE BATEMENT DE COEUR DU SYSTEME
|
||||||
|
################################################################################
|
||||||
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||||
|
CHEMIN="/home/$YOU/G1sms+"
|
||||||
|
cd $CHEMIN
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
|
||||||
|
timebar=$(date +%H%M)
|
||||||
|
|
||||||
|
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system. sudo -s ?"; exit; fi
|
||||||
|
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
|
||||||
|
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
# Refresh All peers SWARM Wallets.
|
||||||
|
##################################################################
|
||||||
|
ipfs_swarm_wallets_refresh "SIMPLE"
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# PRINT G1Tag
|
||||||
|
# CREATE and REMOVE rr.bin -> done.rr
|
||||||
|
if [[ -d "./wallets_swarm/.$IPFSNODEID/PRINT/" ]]; then
|
||||||
|
log "__SUB:cron_MINUTE.sh: SEARCH NEW PRINT FOR ME .$IPFSNODEID"
|
||||||
|
mkdir -p ./wallets/.$IPFSNODEID/PRINT/
|
||||||
|
|
||||||
|
for qrrtag in ./wallets_swarm/.$IPFSNODEID/PRINT/*.bin; do
|
||||||
|
rr=$(echo $qrrtag | cut -d '/' -f 5 | cut -d '.' -f 1)
|
||||||
|
if [[ ! -f "./wallets/.$IPFSNODEID/PRINT/done.$rr" ]]; then
|
||||||
|
log "__SUB:cron_MINUTE.sh: PRINT G1Tag $rr - START: $(date)"
|
||||||
|
./shell/natools.py decrypt -k "$MASTERKEYFILE" -i "${qrrtag}" -o "/tmp/G1Tag.png"
|
||||||
|
log "__SUB:cron_MINUTE.sh: natools.py decrypt - $(date)"
|
||||||
|
brother_ql_create --model QL-700 "/tmp/G1Tag.png" --label-size 62 > "/tmp/G1Tag.bin"
|
||||||
|
log "__SUB:cron_MINUTE.sh: brother_ql_create - $(date)"
|
||||||
|
brother_ql_print "/tmp/G1Tag.bin" /dev/usb/lp0
|
||||||
|
log "__SUB:cron_MINUTE.sh: brother_ql_print - $(date)"
|
||||||
|
# INFORM PRINT DONE
|
||||||
|
echo "OK" > ./wallets/.$IPFSNODEID/PRINT/done.$rr
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
else
|
||||||
|
lqrrtag=$(echo "${qrrtag}" | sed s/_swarm//g )
|
||||||
|
log "__SUB:cron_MINUTE.sh: REMOVE OLD DONE PRINT ${lqrrtag} + ./wallets/.$IPFSNODEID/PRINT/done.$rr"
|
||||||
|
rm -f "./wallets/.$IPFSNODEID/PRINT/done.$rr"
|
||||||
|
rm -f "${lqrrtag}"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
log "__SUB:cron_MINUTE.sh: REMOVE OLD PRINT MARKED AS DONE"
|
||||||
|
for scan in ./wallets_swarm/.Qm*/PRINT/done.*; do
|
||||||
|
lscan=$(echo $scan | sed s/_swarm//g )
|
||||||
|
lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 )
|
||||||
|
lrr=$(echo $scan | cut -d '/' -f 5 | cut -d '.' -f 2 )
|
||||||
|
log "__SUB:cron_MINUTE.sh: REMOVE ./wallets/.$lid/PRINT/$lrr.bin OLD PRINT ${lscan} SENT to $lid ($lrr.bin)"
|
||||||
|
rm -f ./wallets/.$lid/PRINT/$lrr.bin
|
||||||
|
rm -f "${lscan}"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
done
|
||||||
|
|
||||||
|
rm "/tmp/G1Tag.bin"
|
||||||
|
rm "/tmp/G1Tag.png"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
if [[ "$timebar" == "0300" ]]; then
|
||||||
|
##################################################################
|
||||||
|
##################################################################
|
||||||
|
# Refresh G1Tag created by this NODE
|
||||||
|
# PROTECT from null HASH
|
||||||
|
for tag in ./wallets/.$IPFSNODEID/TAG/*; do
|
||||||
|
tagj=$(echo $tag | cut -d '/' -f 5)
|
||||||
|
log "__SUB:cron_MINUTE.sh: WORKING ON ${tagj}"
|
||||||
|
RR=$(su $YOU -c "ipfs cat /ipns/${tagj}/TAG_id | sed s/\ //g");
|
||||||
|
if [[ ! $RR && "${tagj}" != "" ]]; then echo "G1 Tag Destroyed"; echo "TODO: rm -Rf ./wallets/.$IPFSNODEID/TAG/${tagj} ???"; continue; fi
|
||||||
|
|
||||||
|
# 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
|
||||||
|
./shell/natools.py decrypt -k "$MASTERKEYFILE" -i /home/$YOU/.ipfs/keystore/${RR}.crypt -o /home/$YOU/.ipfs/keystore/$RR
|
||||||
|
|
||||||
|
log "__SUB:cron_MINUTE.sh: G1Tag PUBLISHKEY decrypted and loaded in /home/$YOU/.ipfs/keystore/${RR}"
|
||||||
|
|
||||||
|
# RE-SYNC LOCAL & SWARM G1TAG (TODO Check G1Tag chain validity)
|
||||||
|
rm -f ./TAG/${RR}/*
|
||||||
|
su $YOU -c "ipfs get --output=./TAG/${RR} /ipns/${tagj}"
|
||||||
|
|
||||||
|
# PUBLISH VERIFIED G1Tag VERSION
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
||||||
|
# RECORD TAG_chain And HASH again
|
||||||
|
echo "$I" > "./TAG/${JDESTRR}/TAG_chain"
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
||||||
|
# IPNS $JDESTRR PUBLISH
|
||||||
|
J=$(su $YOU -c "ipfs name publish -k ${RR} --quieter /ipfs/${I}")
|
||||||
|
|
||||||
|
done
|
||||||
|
##################################################################
|
||||||
|
fi
|
||||||
|
##################################################################
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# Effectue les payements récurrents et enlève le vérrou (DESTROY)
|
||||||
|
# TAKES CARE OF DOING RECURRENT PAYEMENTS EVERY DAY FOR ITS $PHONE G1Wallets
|
||||||
|
# TODO: Add SMS Alert if G1sms Wallet is low...
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "__SUB:cron_VIR.reccurent.sh: START"
|
||||||
|
|
||||||
|
rm -f /tmp/VIR*
|
||||||
|
echo "" > /tmp/VIR
|
||||||
|
|
||||||
|
TODAY=$(date '+%Y%m%d')
|
||||||
|
log "__SUB:cron_VIR.reccurent.sh: Searching payements to do for $TODAY"
|
||||||
|
for file in ./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"
|
||||||
|
cat /tmp/VIREMENTS | sort >> /tmp/VIR$TODAY
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
############################################
|
||||||
|
if [[ -f /tmp/VIR$TODAY ]]; then
|
||||||
|
############################################
|
||||||
|
while read line
|
||||||
|
do virement=(${line});
|
||||||
|
if [[ ${virement[0]} == ${TODAY} ]]; then
|
||||||
|
log "__SUB:cron_VIR.reccurent.sh: PAYING !!! ${line}"
|
||||||
|
PHONE=${virement[2]}
|
||||||
|
VIR=${virement[3]}
|
||||||
|
DESTRIB=${virement[4]}
|
||||||
|
DESTUID=${virement[5]}
|
||||||
|
REF=${virement[6]}
|
||||||
|
NB=${virement[7]}
|
||||||
|
|
||||||
|
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)
|
||||||
|
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";
|
||||||
|
else
|
||||||
|
new=$(./shell/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"
|
||||||
|
fi
|
||||||
|
log "__SUB:cron_VIR.reccurent.sh: $TODAY VIR DONE.... Rotation Silkaj : $new "
|
||||||
|
else
|
||||||
|
virement=""
|
||||||
|
echo "$(declare -p virement)"
|
||||||
|
fi
|
||||||
|
done < /tmp/VIR$TODAY
|
||||||
|
|
||||||
|
# CHECK FOR LAST VIREMENTS AND CLEAN IT?
|
||||||
|
for virfile in "./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 "./wallets/$phone/VIREMENTS.gpg"
|
||||||
|
nv=0; tot=0;
|
||||||
|
while read ligne
|
||||||
|
do virs=(${ligne});
|
||||||
|
if [[ ${virs[0]} -gt ${TODAY} ]]; then
|
||||||
|
# Some other payments are to be done in the future
|
||||||
|
((nv++))
|
||||||
|
tot=$((tot + {virs[3]}))
|
||||||
|
fi
|
||||||
|
done < /tmp/$phone.VIREMENTS
|
||||||
|
|
||||||
|
# NO FUTURE PAYMENTS. REMOVE VIREMENTS files
|
||||||
|
if [[ $nv -eq 0 ]]; then
|
||||||
|
log "__SUB:cron_VIR.reccurent.sh: Plus AUCUN payement récurrent !!"
|
||||||
|
sms_SEND "$phone" "Plus AUCUN payement récurrent"
|
||||||
|
rm -f "./wallets/$phone/VIREMENTS.gpg"
|
||||||
|
rm -f "./wallets/$phone/VIREMENTS"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
else
|
||||||
|
log "__SUB:cron_VIR.reccurent.sh: Encore $nv payements récurrents à réaliser pour $tot G1"
|
||||||
|
# TODO Verify Wallet Amount is not too low... To send alert (sms, email)
|
||||||
|
# cts=$(echo $(bc -l <<< "scale=0; $tot * 100") | cut -d '.' -f 1)
|
||||||
|
sms_SEND "$phone" "Encore $nv payements récurrents à réaliser pour $tot G1. Approvisionnez votre solde en conséqence..."
|
||||||
|
fi
|
||||||
|
rm -f "/tmp/$phone.VIREMENTS"
|
||||||
|
done
|
||||||
|
############################################
|
||||||
|
fi
|
||||||
|
############################################
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
MOTS=$(echo "$1" | grep -E "^\-?[0-9]+$")
|
||||||
|
# Default to 6 words passphrase
|
||||||
|
if [[ "$MOTS" == "" ]]; then MOTS=6; fi
|
||||||
|
WORDCOUNT=${1-$MOTS}
|
||||||
|
# Download the wordlist
|
||||||
|
# wget -nc -O ~/.diceware-wordlist http://world.std.com/%7Ereinhold/diceware.wordlist.asc 2> /dev/null
|
||||||
|
# print a list of the diceware words
|
||||||
|
cat ./shell/diceware-wordlist.txt |
|
||||||
|
awk '/[1-6][1-6][1-6][1-6][1-6]/{ print $2 }' |
|
||||||
|
# randomize the list order
|
||||||
|
shuf --random-source=/dev/urandom |
|
||||||
|
# pick the first n words
|
||||||
|
head -n ${WORDCOUNT} |
|
||||||
|
# pretty print
|
||||||
|
tr '\n' ' '
|
||||||
|
echo
|
|
@ -0,0 +1,615 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
# G1SMS COMMUN FUNCTIONS
|
||||||
|
|
||||||
|
# TODO: REWRITE AND MAKE FULL IPFS get wallet value through IPNS links
|
||||||
|
# ipfs cat /ipns/QmUrUdfz5hWJ6354D3N6DT64tbs5CLEndSYYiqrj9Wa4Ax/+33647683646/+33647683646.uidna
|
||||||
|
###################################################################################################################################
|
||||||
|
|
||||||
|
###################################################################################################################################
|
||||||
|
function sms_SEND () {
|
||||||
|
# sms_SEND ($1=phone, $2=message)
|
||||||
|
local dest="$1"
|
||||||
|
local mess="$2"
|
||||||
|
if [[ ${#dest} -eq 10 || ${#dest} -eq 12 ]]; then
|
||||||
|
if [[ -d ./wallets/$dest ]]; then
|
||||||
|
# TEST IF $dest IS ON CURRENT NODE
|
||||||
|
gammu-smsd-inject -l TEXT "$dest" -text "$mess" 1>&2
|
||||||
|
else
|
||||||
|
# Send SMS through $dest NODE (TODO: send it like PRINT, TASK, ...)
|
||||||
|
DESTNODEID=$(cat ./wallets_swarm/$dest/MASTERPHONE.ipfsid)
|
||||||
|
log "$dest is managed by NODE: $DESTNODEID)"
|
||||||
|
mkdir "./wallets/.$DESTNODEID/SMS"
|
||||||
|
echo $mess > "./wallets/.$DESTNODEID/SMS/$dest.sms2send"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log ">>>>>>>>>>SMS ERROR BAD DESTINATION $dest"
|
||||||
|
fi
|
||||||
|
log ">>>>>>>>>> SENDING SMS $mess TO $dest ($DESTNODEID)"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
function sms_ERROR () {
|
||||||
|
# sms_ERROR ($1=phone, $2=message)
|
||||||
|
local dest="$1"
|
||||||
|
local mess="[ERREUR]
|
||||||
|
$2"
|
||||||
|
if [[ ${#dest} -eq 10 || ${#dest} -eq 12 ]]; then
|
||||||
|
gammu-smsd-inject TEXT "$dest" -text "$mess" 1>&2
|
||||||
|
else
|
||||||
|
log ">>>>>>>>>>SMS ERROR BAD DESTINATION $dest"
|
||||||
|
fi
|
||||||
|
log ">>>>>>>>>> SENDING SMS $mess TO $dest"
|
||||||
|
# SEND ERROR COPY TO ADMINPHONE
|
||||||
|
if [[ "$CPERROR" == "YES" ]]; then sms_SEND "$ADMINPHONE" "ADMIN! ERROR ($dest): $mess"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
function log_history () {
|
||||||
|
log "__SUB:log_history: history ($1, $2)"
|
||||||
|
PHONE="$1"
|
||||||
|
HISTFILE="./history.$IPFSNODEID.log.csv"
|
||||||
|
|
||||||
|
echo "$(date +%Y%m%d), $(date +%H:%M:%S), $1, $2" >> "$HISTFILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
function security () {
|
||||||
|
|
||||||
|
if [[ "$G1SMS" == "YES" ]]; then # ONLY OF gammu is really sending SMS on that NODE
|
||||||
|
# No Reply to MySelf (or enjoy SMS LOOP of the death) Nobody neither
|
||||||
|
if [[ "$PHONE" == "$MASTERPHONE" || "$PHONE" == "" ]]; then log "__SUB:security: SMS REJECTED !! $PHONE $TEXT"; exit; fi
|
||||||
|
|
||||||
|
# ADAPT TO YOUR PHONE COMPANY / ADVERT ANNOYANCE
|
||||||
|
if [[ "$PHONE" == "Orange Info" ]]; then log "__SUB:security: SMS REJECTED !! $PHONE ADVERT $TEXT"; exit; fi
|
||||||
|
if [[ ${#PHONE} -ne 12 && ${#PHONE} -ne 46 ]]; then log "!! SMS REJECTED !! $PHONE BAD $TEXT"; exit; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ANTI SPAM SMS (1 mn entre chaque commande)
|
||||||
|
find /tmp -cmin +1 -type f -name "sms_received_*" -exec rm -f '{}' \;
|
||||||
|
|
||||||
|
# Do not consider SPAM, Delivered notification
|
||||||
|
if [[ "$CMD" != "DELIVERED" && "$CMD" != "PENDING" ]]; then
|
||||||
|
if [[ -f "/tmp/sms_received_$PHONE" ]]; then
|
||||||
|
# Send response SMS
|
||||||
|
if [[ ! -f "/tmp/sms_SPAM_$PHONE" ]]; then
|
||||||
|
sms_ERROR "$PHONE" "Je ne le dirai pas 2 fois... Laissez moi au moins 1 minute entre chacune de vos commandes SMS! Autrement je n'y répondrai pas. Merci!"
|
||||||
|
echo $(date) > "/tmp/sms_SPAM_$PHONE"
|
||||||
|
fi
|
||||||
|
log "__SUB:security: ################################"
|
||||||
|
log "__SUB:security: $PHONE COMMAND REJECTED: $TEXT"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "$TEXT" > "/tmp/sms_received_$PHONE"
|
||||||
|
# Remove SPAM flag older than one day
|
||||||
|
find /tmp -ctime +1 -type f -name "sms_SPAM_*" -exec rm -f '{}' \;
|
||||||
|
else
|
||||||
|
# THIS IS AN AKNOWLEGEMENT
|
||||||
|
log "__SUB:security: ################################"
|
||||||
|
log "__SUB:security: $PHONE COMMAND REJECTED: $TEXT"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
# Remove SPAM flag older than one day
|
||||||
|
find /tmp -ctime +1 -type f -name "sms_SPAM_*" -exec rm -f '{}' \;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
function ipfs_swarm_wallets_refresh (){
|
||||||
|
|
||||||
|
# Refresh CURRENT NODE wallets STATUS
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
|
||||||
|
# REFRESH SWARM MEMORY
|
||||||
|
mkdir -p "./wallets_swarm"
|
||||||
|
chown -R $YOU "./wallets_swarm"
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: REFRESHING SWARM $PHONE shared memory..."
|
||||||
|
if [[ $PHONE ]]; then rm -Rf ./wallets_swarm/$PHONE; fi
|
||||||
|
|
||||||
|
# GET IPNS published wallets from ALL SWARM NODES / TODO: IF NODES MISSING, check ./wallets_swarm/.QmNODES...
|
||||||
|
#log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID"
|
||||||
|
su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID"
|
||||||
|
count=1
|
||||||
|
#for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
|
||||||
|
for id in ./wallets_swarm/.Qm*/;
|
||||||
|
do
|
||||||
|
count=$((count+1))
|
||||||
|
id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
|
||||||
|
#log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$id"
|
||||||
|
rm -Rf ./wallets_swarm/.$id
|
||||||
|
su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
|
||||||
|
done
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: ./wallets_swarm/ RENEW from $count peers .........OK!!!"
|
||||||
|
|
||||||
|
|
||||||
|
############################################################################"
|
||||||
|
# TREAT move_g1cents Tasks in ./wallets/.$IPFSNODEID
|
||||||
|
# IF NODE find in ./wallets_swarm/.$IPFSNODEID/TASK directory && Have it's G1 Wallet already (for natools crypto)
|
||||||
|
if [[ "$1" != "SIMPLE" && -d ./wallets_swarm/.$IPFSNODEID/TASK && -f "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg" ]]; then
|
||||||
|
############################################################################"
|
||||||
|
for task in $(ls ./wallets_swarm/.$IPFSNODEID/TASK/*.move_g1cents.*); # ./wallets/.$IPFSNODEID/TASK/$NANODATE.move_g1cents.$DESTPHONE.NODEPUB.crypt OR "done.$NANODATE" FILES
|
||||||
|
do
|
||||||
|
FTASK=$( echo $task | cut -d '/' -f 5 ) # "$NANODATE.move_g1cents.$DESTPHONE.NODEPUB.crypt"
|
||||||
|
TNANO=$( echo $FTASK | cut -d '.' -f 1) # $NANODATE
|
||||||
|
TTYPE=$( echo $FTASK | cut -d '.' -f 2) # move_g1cents
|
||||||
|
TDEST=$( echo $FTASK | cut -d '.' -f 3) # $DESTPHONE
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) FOUND TASK $TNANO:$TTYPE:$TDEST "
|
||||||
|
# MAKE LOCAL .$IPFSNODEID directory
|
||||||
|
mkdir -p ./wallets/.$IPFSNODEID/TASK/
|
||||||
|
# TODO: CHECK BETTER NOT DONE YET and $NANODATE > $TNANO (=> detect NODES writing in the future!!)
|
||||||
|
if [[ ! -f "./wallets/.$IPFSNODEID/TASK/done.$TNANO" ]]; then # NOT DONE YET: NEW TASK!
|
||||||
|
tdiff=$(bc -l <<< "$NANODATE - $TNANO")
|
||||||
|
if [[ $tdiff -gt 0 ]]; then
|
||||||
|
# GET BACK MY NODE G1 Wallet authfile from my LOCAL ./wallets
|
||||||
|
echo "${GPGPASS}" | gpg -q -d --output "./NODEG1Wallet.authfile" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg"
|
||||||
|
# DECRYPT and CAT move_g1cents VALUE
|
||||||
|
./shell/natools.py decrypt -k "./NODEG1Wallet.authfile" -i "$task" -o "/tmp/move_g1cents.$TDEST"
|
||||||
|
ZENVAL=$(cat "/tmp/move_g1cents.$TDEST")
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: tdiff=$tdiff .$IPFSNODEID G1 = ./NODEG1Wallet.authfile :decrypt: Found $ZENVAL Zen to ADD"
|
||||||
|
rm -f "./NODEG1Wallet.authfile"
|
||||||
|
if [[ $ZENVAL -gt 0 ]]; then
|
||||||
|
curvalue=$(cat ./wallets/$TDEST/$TDEST.g1cents)
|
||||||
|
newvalue=$(bc -l <<< "$curvalue + $ZENVAL")
|
||||||
|
echo $newvalue > ./wallets/$TDEST/$TDEST.g1cents
|
||||||
|
echo "OK.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) DONE! OPERATION: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/$TDEST/$TDEST.g1cents:: OK"
|
||||||
|
# REFRESH ./wallets and PUBLISH
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
else
|
||||||
|
echo "KO.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) ERROR! BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/$TDEST/$TDEST.g1cents :: KO"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! TASK ERROR: .$IPFSNODEID($FTASK) ERROR! BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/$TDEST/$TDEST.g1cents :: KO"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# TODO: Bad NODE in the Future task !!! Make better BAD Node detection = Swarm Banish?
|
||||||
|
echo "KO.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) ERROR! DATE PROBLEM: $NANODATE < $TNANO :: KO"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! .$IPFSNODEID($FTASK) ERROR! DATE PROBLEM: $NANODATE < $TNANO :: KO"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: REMOVE OLD TASK MARKED AS DONE"
|
||||||
|
for scan in ./wallets_swarm/.Qm*/TASK/done.*; do
|
||||||
|
lscan=$(echo $scan | sed s/_swarm//g )
|
||||||
|
lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 )
|
||||||
|
lnano=$(echo $scan | cut -d '/' -f 5 | cut -d '.' -f 2 )
|
||||||
|
if [[ "$lid" != "$IPFSNODEID" ]]; then
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: CLEANING done OLD TASK ${lscan} SENT to $lid ($lnano.bin)"
|
||||||
|
rm -f ./wallets/.$lid/TASK/$lnano.*
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID :: NO TASK ! "
|
||||||
|
############################################################################"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
function ipfs_node_wallets_add (){
|
||||||
|
##########################
|
||||||
|
##########################
|
||||||
|
IWALLETS=$(su $YOU -c "ipfs add -rHq './wallets' | tail -n 1")
|
||||||
|
|
||||||
|
# CHAIN STATE FOR $IPFSNODEID
|
||||||
|
echo $IWALLETS > ./wallets/.$IPFSNODEID.wallets.chain
|
||||||
|
log "__SUB:ipfs_node_wallets_add: NEW './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"
|
||||||
|
|
||||||
|
echo $IWALLETS
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
function sms_uid2key (){
|
||||||
|
RIBFILE="./wallets/$PHONE/$PHONE.uidrib"
|
||||||
|
NAMEFILE="./wallets/$PHONE/$PHONE.uidname"
|
||||||
|
UIDNAFILE="./wallets/$PHONE/$PHONE.uidna"
|
||||||
|
# New related wallet asked
|
||||||
|
ASKWALLET="$1"
|
||||||
|
#For micro payement
|
||||||
|
PHONE="$2"
|
||||||
|
PIN="$3"
|
||||||
|
if -f "$UIDNAFILE"; then UIDNA=$(cat "$UIDNAFILE"); else UIDNA=""; fi
|
||||||
|
log "__SUB:sms_uid2key: $UIDNA Try to associate $ASKWALLET with $PHONE... SEARCHING..."
|
||||||
|
|
||||||
|
if [[ $UIDNA && "$ASKWALLET" == "$UIDNA" ]]; then
|
||||||
|
log "__SUB:sms_uid2key: "$ASKWALLET" == "$UIDNA" !!"
|
||||||
|
sms_SEND "$PHONE" "[G1sms+] $UIDNA est le nom de votre porte monnaie libre pour $PHONE. Il ne peut également être compte maître!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test if member files exists
|
||||||
|
if [ -f "$NAMEFILE" ]; then
|
||||||
|
UIDNAME=$(cat "$NAMEFILE")
|
||||||
|
log "__SUB:sms_uid2key: ALREADY $UIDNAME related Wallet for $PHONE Wallet change to $ASKWALLET !!"
|
||||||
|
if [["$UIDNAME" != "$ASKWALLET" ]]; then
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! INFO: $PHONE Wallet associé à $UIDNAME change en $ASKWALLET !!"
|
||||||
|
sms_SEND "$PHONE" "[G1sms+] Votre portefeuille maitre va passer de $UIDNAME à $ASKWALLET!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Search fo duplicate
|
||||||
|
DUP=$(grep -Rwl "$ASKWALLET" ./wallets/*/*.uidname | cut -f 3 -d '/')
|
||||||
|
if [[ "$DUP" != "" ]]; 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!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# FIND ASKWALLET into wallets, wallest_swarm OR duniter (silkaj)
|
||||||
|
DESTMEM="$VIRDEST"
|
||||||
|
# SEARCH IN WALLETS
|
||||||
|
LOCAL=$(grep -Rwl "$ASKWALLET" ./wallets/*/*.uidna* | cut -f 3 -d '/')
|
||||||
|
if [[ "$LOCAL" != "" ]]; then
|
||||||
|
# LOCAL G1sms account
|
||||||
|
DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub)
|
||||||
|
DESTPHONE=$LOCAL
|
||||||
|
log "__SUB:sms_uid2key: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)"
|
||||||
|
else
|
||||||
|
# SEARCH IN WALLETS SWARM
|
||||||
|
INSWARM=$(grep -Rwl "$ASKWALLET" ./wallets_swarm/*/*.uidna* | cut -f 3 -d '/')
|
||||||
|
if [[ "$INSWARM" != "" ]]; then
|
||||||
|
REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms)
|
||||||
|
DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.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}')
|
||||||
|
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' > "./wallets/$PHONE/$PHONE.uidgeo.json"
|
||||||
|
log "__SUB:sms_uid2key: GET CESIUM+ geoPoint and AVATAR : $(cat ./wallets/$PHONE/$PHONE.uidgeo.json)"
|
||||||
|
curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.avatar._content' | sed 's/\"//g' | base64 -d > "./wallets/$PHONE/$PHONE.avatar.png"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$DESTRIB" != "" ]; then
|
||||||
|
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)
|
||||||
|
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)"
|
||||||
|
else
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! LOG: $PHONE / $ASKWALLET ABSENT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "__SUB:sms_uid2key: $MEMBER($DESTRIB)"
|
||||||
|
echo "$DESTRIB"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
function sms_INIT_ACCOUNT () {
|
||||||
|
log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
|
PHONE="$1"
|
||||||
|
UNKNOWN=0
|
||||||
|
# TODO Optimize GLOBAL/local variables use, use more function array output ?!
|
||||||
|
# Initiate PHONE settings files and values
|
||||||
|
IPFSNODEIDFILE="./wallets/$PHONE/MASTERPHONE.ipfsid" # Contains G1sms+ NODE IPFS id
|
||||||
|
SMSNODE="./wallets/$PHONE/MASTERPHONE.sms" # Contains G1sms+ SMS phone number
|
||||||
|
PINFILE="./wallets/$PHONE/$PHONE.pin" # Contains phone wallet diceware password
|
||||||
|
GPGPINFILE="./wallets/$PHONE/$PHONE.pin.gpg" # Contains g1smsnode cypher phone wallet diceware password
|
||||||
|
AUTHCRYPTFILE="./wallets/$PHONE/$PHONE.authfile.crypt" # TEST!!! crypt with $PHONE wallet keypair
|
||||||
|
PUBKEYFILE="./wallets/$PHONE/$PHONE.pub" # Contains phone wallet public key (RIB)
|
||||||
|
UNITFILE="./wallets/$PHONE/$PHONE.unit" # Contains phone wallet prefered unit (LOVE,G1,DU)
|
||||||
|
|
||||||
|
RIBFILE="./wallets/$PHONE/$PHONE.uidrib" # Contains phone wallet related UID Pubkey
|
||||||
|
NAMEFILE="./wallets/$PHONE/$PHONE.uidname" # Contains the member UID related to wallet
|
||||||
|
MAILFILE="./wallets/$PHONE/$PHONE.email" # Contains the member EMAIL (Send BILLET)
|
||||||
|
GPGMAILFILE="./wallets/$PHONE/$PHONE.email.gpg" # Contains the member EMAIL (Send BILLET)
|
||||||
|
UIDNAFILE="./wallets/$PHONE/$PHONE.uidna" # Contains the G1sms+ UID Name for recursive VIR
|
||||||
|
GEOFILE="./wallets/$PHONE/$PHONE.uidgeo.json" # Contains the member GeoPoint from member Cesium+ related to wallet
|
||||||
|
|
||||||
|
RECFILE="./wallets/$PHONE/VIREMENTS" # File showing recurrent payements are left to be done with this G1sms Wallet
|
||||||
|
GPGRECFILE="./wallets/$PHONE/VIREMENTS.gpg" # Cypher file with GPGPASS (Node .Identity.PrivKey)
|
||||||
|
G1COUNTFILE="./wallets/$PHONE/$PHONE.g1cents" # Last sms_COUNT.sh call value
|
||||||
|
CHAINFILE="./wallets/$PHONE/$PHONE.chain" # Contains wallet last IPFS hash before ZEN value change
|
||||||
|
|
||||||
|
DABUIDF="./wallets/$PHONE/uidna.G1TAGNODE" # Contains G1Dab Name
|
||||||
|
# GET CURRENT NODE UIDNA (default DABUID)
|
||||||
|
NODEUIDNA=$(cat "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna")
|
||||||
|
######################################################################
|
||||||
|
# (NO PIN) = FIRST ACCOUNT: Create wallet
|
||||||
|
if [ ! -f "$PINFILE" ]; then
|
||||||
|
# NOSMS mode?
|
||||||
|
if [[ $2 == "NOSMS" ]]; then UNKNOWN="unknown"; return; fi
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Create Account Files
|
||||||
|
#######################
|
||||||
|
mkdir -p "./wallets/$PHONE/"
|
||||||
|
PIN=$(./shell/diceware.sh | xargs)
|
||||||
|
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: ./shell/natools.py encrypt -p $PUBKEY -i ""./authfile"" -o ""$AUTHCRYPTFILE"""
|
||||||
|
./shell/natools.py encrypt -p $PUBKEY -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
|
||||||
|
TAIL=${PHONE:8:4}
|
||||||
|
# No UIDNA yet. Create new
|
||||||
|
UIDNA=$(./shell/diceware.sh 1 | xargs)
|
||||||
|
# Check if already existing among all swarm wallets
|
||||||
|
while [[ $(grep -Rwl $UIDNA$TAIL ./wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./shell/diceware.sh 1 | xargs); done
|
||||||
|
echo "$UIDNA$TAIL" > "$UIDNAFILE"
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# ACTIVATE G1SMS WALLET
|
||||||
|
#######################
|
||||||
|
# log "$MASTERKEYFILE $PUBKEY THIRD_PARTY_MANAGER:$MASTERPUB"
|
||||||
|
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$MASTERKEYFILE" --amount=3.15 --output=$PUBKEY --comment="[G1sms+] $UIDNA$TAIL 3RD:$MASTERPUB " -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=$MASTERPUB --comment="[G1sms+] $UIDNA$TAIL 3RD:$MASTERPUB: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"
|
||||||
|
PIN=$(cat "$PINFILE" | xargs)
|
||||||
|
echo "" > "$PINFILE"
|
||||||
|
|
||||||
|
echo "114" > "$G1COUNTFILE"
|
||||||
|
echo "$PUBKEY" > "$PUBKEYFILE"
|
||||||
|
echo "$COIN" > "$UNITFILE"
|
||||||
|
echo "$MASTERPHONE" > "$SMSNODE"
|
||||||
|
log_history "$PHONE" "NEW, $PUBKEY"
|
||||||
|
|
||||||
|
# ADD WALLET TO IPFS
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#################################################
|
||||||
|
# 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=$(./shell/diceware.sh 1 | xargs)
|
||||||
|
# Check if already existing among all swarm wallets
|
||||||
|
while [[ $(grep -Rwl $UIDNA$TAIL ./wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./shell/diceware.sh 1 | xargs); done
|
||||||
|
echo "$UIDNA$TAIL" > "$UIDNAFILE"
|
||||||
|
|
||||||
|
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";
|
||||||
|
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)
|
||||||
|
echo "" > "$PINFILE";
|
||||||
|
fi
|
||||||
|
|
||||||
|
# CYPHER EMAIL FILE
|
||||||
|
if [[ ! -f "$GPGMAILFILE" ]]; then
|
||||||
|
# ------------8<------------------
|
||||||
|
# NO .gpg file, CREATING it (OLD G1sms accounts)
|
||||||
|
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
|
||||||
|
# Already existing gpg DECODING IT
|
||||||
|
echo "${GPGPASS}" | gpg -d -q --output "$MAILFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGMAILFILE"
|
||||||
|
MAIL=$(cat "$MAILFILE");
|
||||||
|
echo "" > "$MAILFILE";
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ------------8<------------------
|
||||||
|
# REMOVE OLD HISTORY FILES
|
||||||
|
rm -f ./wallets/$PHONE/$PHONE.hist
|
||||||
|
# ------------>8------------------
|
||||||
|
|
||||||
|
# PUBLISH GLOBAL VARS FROM ACCOUNT FILES
|
||||||
|
echo $IPFSNODEID > $IPFSNODEIDFILE
|
||||||
|
PUBKEY=$(cat "$PUBKEYFILE" | xargs)
|
||||||
|
UNIT=$(cat "$UNITFILE" | xargs)
|
||||||
|
if [ -f "$G1COUNTFILE" ]; then AMOUNTG1=$(bc <<< "scale=2; $(cat $G1COUNTFILE) / 100"); fi
|
||||||
|
if [ -f "$NAMEFILE" ]; then MEMBER=$(cat "$NAMEFILE"); else MEMBER=""; fi
|
||||||
|
if [ -f "$RIBFILE" ]; then MEMRIB=$(cat "$RIBFILE"); else MEMRIB=""; fi
|
||||||
|
if [ -f "$UIDNAFILE" ]; then UIDNA=$(cat "$UIDNAFILE"); else UIDNA=""; fi
|
||||||
|
if [ -f "$DABUIDF" ]; then DABID=$(cat "$DABUIDF"); else DABID="$NODEUIDNA"; fi
|
||||||
|
|
||||||
|
|
||||||
|
AMOUNTDU=$(bc <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
|
||||||
|
AMOUNTLOVE=$(bc <<< "$AMOUNTG1 * 100 / $DUFACTOR")
|
||||||
|
|
||||||
|
case "$UNIT" in
|
||||||
|
G1)
|
||||||
|
AMOUNT=$AMOUNTG1
|
||||||
|
;;
|
||||||
|
DU)
|
||||||
|
AMOUNT=$AMOUNTDU
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AMOUNT=$AMOUNTLOVE
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
log "__SUB:sms_INIT_ACCOUNT: $AMOUNTG1 = $AMOUNT $UNIT"
|
||||||
|
|
||||||
|
# LOG # TODO REMOVE PIN LOG!!
|
||||||
|
log "#####################"
|
||||||
|
log "PHONE: $PHONE"
|
||||||
|
log "PIN: $PIN"
|
||||||
|
log "PUBKEY: $PUBKEY"
|
||||||
|
log "G1: $AMOUNTG1"
|
||||||
|
log "AMOUNT: $AMOUNT $UNIT"
|
||||||
|
log "UIDNA: $UIDNA"
|
||||||
|
log "MEMBER: $MEMBER"
|
||||||
|
log "MEMRIB: $MEMRIB"
|
||||||
|
log "MAIL: $MAIL"
|
||||||
|
log "DABID: $DABID"
|
||||||
|
log "#####################"
|
||||||
|
|
||||||
|
|
||||||
|
log "__SUB:sms_INIT_ACCOUNT: END"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
function check_account (){
|
||||||
|
log "__SUB:check_account: SILKAJ...... max 15 sec....."
|
||||||
|
AMOUNTG1=$(./shell/timeout.sh -t 15 ./silkaj/silkaj amount "$PUBKEY")
|
||||||
|
AMOUNTDU=$(bc <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
|
||||||
|
AMOUNTLOVE=$(bc <<< "$AMOUNTG1 * 100 / $DUFACTOR")
|
||||||
|
|
||||||
|
case "$UNIT" in
|
||||||
|
G1)
|
||||||
|
AMOUNT=$AMOUNTG1
|
||||||
|
;;
|
||||||
|
DU)
|
||||||
|
AMOUNT=$AMOUNTDU
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
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 "./wallets/$PHONE/$PHONE.n")
|
||||||
|
((NN++))
|
||||||
|
echo "$NN" > "./wallets/$PHONE/$PHONE.n"
|
||||||
|
echo $G1cents > "./wallets/$PHONE/$PHONE.g1cents"
|
||||||
|
# REFRESH NODE IPFS wallets & PUBLISH
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
# Register modification
|
||||||
|
echo "$I" > "./wallets/$PHONE/$PHONE.chain"
|
||||||
|
else
|
||||||
|
# BAN actual Duniter Node in case of silkaj timeout.
|
||||||
|
export NEWDUNITER=$(./shell/checknodes.sh 'BAN')
|
||||||
|
log "__SUB:check_account: !!! SILKAJ IS TOO SLOW !!! => NEW DUNITER SERVER: $NEWDUNITER"
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare -a aaa
|
||||||
|
aaa=( "$AMOUNTG1" "$AMOUNT" "$UNIT" )
|
||||||
|
log "__SUB:check_account: $(declare -p aaa)"
|
||||||
|
echo ${aaa[@]}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
function make_accounting (){
|
||||||
|
# CONVERT AMOUNT UNIT to VIR G1
|
||||||
|
case "$UNIT" in
|
||||||
|
G1)
|
||||||
|
VIR=$AMOUNT;
|
||||||
|
;;
|
||||||
|
DU)
|
||||||
|
VIR=$(bc -l <<< "scale=2; $AMOUNT * $DUFACTOR")
|
||||||
|
;;
|
||||||
|
LOVE)
|
||||||
|
VIR=$(bc -l <<< "scale=2; $AMOUNT * $DUFACTOR / 100")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
VIR=$(bc -l <<< "scale=2; $AMOUNT * $DUFACTOR / 100")
|
||||||
|
;;
|
||||||
|
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=$(./shell/timeout.sh -t 20 ./silkaj/silkaj amount "$PUBKEY")
|
||||||
|
if [[ ! $AMOUNTG1 ]]; then AMOUNTG1=$(bc -l <<< "scale=2; $(cat ./wallets_swarm/$PHONE/$PHONE.g1cents) / 100"); fi
|
||||||
|
if [[ "$AMOUNTG1" == "" ]]; then AMOUNTG1=0; fi
|
||||||
|
# TAX AND MINIMUM WALLET ACCOUNT CALCULATION
|
||||||
|
PERCENT=0$(bc -l <<< "scale=2; $VIR / $SWARMCOMM")
|
||||||
|
MIN=$(bc -l <<< "$AMOUNTG1 - $PERCENT - $LIMIT")
|
||||||
|
CHARGE=$(bc -l <<< "scale=2; $VIR + $PERCENT + $LIMIT")
|
||||||
|
TESTMIN=$( echo "${VIR} < ${MIN}" | bc -l )
|
||||||
|
log "__SUB:make_accounting: TEST $AMOUNT $UNIT :: $VIR + $PERCENT + $LIMIT = $CHARGE < $AMOUNTG1 ? $TESTMIN"
|
||||||
|
|
||||||
|
declare -a myarray
|
||||||
|
myarray=( "$TESTMIN" "$VIR" "$PERCENT" "$CHARGE")
|
||||||
|
log "__SUB:make_accounting: $(declare -p myarray)"
|
||||||
|
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 ./wallets/$phonesrc/$phonesrc.g1cents | cut -d '.' -f 1)
|
||||||
|
newvalue=$(bc -l <<< "$curvalue - $zenvalue")
|
||||||
|
echo $newvalue > ./wallets/$phonesrc/$phonesrc.g1cents
|
||||||
|
log "__SUB:move_g1cents: DEBIT: OK APPLY $curvalue - $zenvalue = $newvalue TO ./wallets/$phonesrc/$phonesrc.g1cents"
|
||||||
|
|
||||||
|
### CHANGE OUTPUT VALUE ####
|
||||||
|
# TEST IF $dest is a wallets_ G1sms PUBKEY?
|
||||||
|
winnerphone=$(grep -Rwl "$pubkeydest" ./wallets_swarm/*/*.pub | cut -d '.' -f 2 | cut -d '/' -f 3)
|
||||||
|
if [[ $winnerphone ]]; then
|
||||||
|
# GET INFORMATON ON MANAGER NODE
|
||||||
|
NODEID=$(cat ./wallets_swarm/$winnerphone/MASTERPHONE.ipfsid)
|
||||||
|
|
||||||
|
if [[ "$NODEID" == "$IPFSNODEID" ]]; then
|
||||||
|
# ACTUAL NODE IS WALLET MANAGING NODE ;)
|
||||||
|
curvalue=$(cat ./wallets/$winnerphone/$winnerphone.g1cents | cut -d '.' -f 1)
|
||||||
|
newvalue=$(bc -l <<< "$curvalue + $zenvalue")
|
||||||
|
echo $newvalue > ./wallets/$winnerphone/$winnerphone.g1cents
|
||||||
|
log "__SUB:move_g1cents: CREDIT: OK APPLY $curvalue + $zenvalue = $newvalue TO ./wallets/$winnerphone/$winnerphone.g1cents"
|
||||||
|
else
|
||||||
|
# MUST ASK MANAGER NODE TO CORRECT g1cents FOR $winnerphone WALLET
|
||||||
|
# WRITE TASK TO .$NODEID CHANNEL
|
||||||
|
mkdir -p ./wallets/.$NODEID/TASK/
|
||||||
|
# USE natools with NODEG1PUB crypt
|
||||||
|
echo "$zenvalue" > "/tmp/move_g1cents.$winnerphone"
|
||||||
|
# GET NODE G1sms Wallet PUBKEY
|
||||||
|
NODEG1PUB=$(cat ./wallets_swarm/.$NODEID/$NODEID.pub)
|
||||||
|
./shell/natools.py encrypt -p $NODEG1PUB -i "/tmp/move_g1cents.$winnerphone" -o "./wallets/.$NODEID/TASK/$NANODATE.move_g1cents.$winnerphone.NODEPUB.crypt"
|
||||||
|
log "__SUB:move_g1cents: CREDIT: WRITE TASK TO ./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)
|
||||||
|
}
|
After Width: | Height: | Size: 33 KiB |
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
from duniterpy.key import SigningKey
|
||||||
|
|
||||||
|
|
||||||
|
def generate_public_key(salt: str, password: str) -> str:
|
||||||
|
"""
|
||||||
|
Return public key from credentials
|
||||||
|
|
||||||
|
:param salt: Salt passphrase, using quotes if space in it
|
||||||
|
:param password: Password
|
||||||
|
"""
|
||||||
|
# Create key object
|
||||||
|
# key = SigningKey(salt, password)
|
||||||
|
key = SigningKey.from_credentials(salt, password)
|
||||||
|
# SigningKey.save_private_key("private.key", "./")
|
||||||
|
return key.pubkey
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
# if bad number of arguments...
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
|
||||||
|
# display command usage
|
||||||
|
print("""
|
||||||
|
Usage:
|
||||||
|
python gen_pubkey.py salt password
|
||||||
|
""")
|
||||||
|
|
||||||
|
# exit with status code error
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
# capture arguments
|
||||||
|
_salt = sys.argv[1]
|
||||||
|
_password = sys.argv[2]
|
||||||
|
|
||||||
|
# display the public key
|
||||||
|
print(generate_public_key(_salt, _password))
|
||||||
|
|
||||||
|
# exit with status code ok
|
||||||
|
exit(0)
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
import getpass
|
||||||
|
import sys
|
||||||
|
import silkaj.money, silkaj.tx, silkaj.auth
|
||||||
|
from duniterpy.key import SigningKey
|
||||||
|
|
||||||
|
# CONFIG #######################################
|
||||||
|
|
||||||
|
# You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT]
|
||||||
|
# or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT]
|
||||||
|
# Here we use the secure BASIC_MERKLED_API (BMAS)
|
||||||
|
BMAS_ENDPOINT = "BMAS g1.duniter.org 443"
|
||||||
|
|
||||||
|
# Version of the transaction document
|
||||||
|
TRANSACTION_VERSION = 10
|
||||||
|
|
||||||
|
################################################
|
||||||
|
|
||||||
|
|
||||||
|
def sendTransaction(sender_keys, receiver_pubkey, amount, comment):
|
||||||
|
sender_amount = silkaj.money.get_amount_from_pubkey(sender_keys.pubkey)[0]
|
||||||
|
assert sender_amount >= amount, "not enough money"
|
||||||
|
silkaj.tx.generate_and_send_transaction(sender_keys.hex_seed().decode(), sender_keys.pubkey, amount, [receiver_pubkey], comment)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
"""
|
||||||
|
Main code
|
||||||
|
"""
|
||||||
|
# if bad number of arguments...
|
||||||
|
if len(sys.argv) != 6:
|
||||||
|
|
||||||
|
# display command usage
|
||||||
|
print("""
|
||||||
|
Usage:
|
||||||
|
./g1_send_transaction.py phone pin dest amount comment
|
||||||
|
""")
|
||||||
|
|
||||||
|
# exit with status code error
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
# capture arguments
|
||||||
|
_salt = sys.argv[1]
|
||||||
|
_password = sys.argv[2]
|
||||||
|
_dest = sys.argv[3]
|
||||||
|
_amount = sys.argv[4]
|
||||||
|
_comment = sys.argv[5]
|
||||||
|
|
||||||
|
# create keys from credentials
|
||||||
|
sender_keys = SigningKey(_salt, _password)
|
||||||
|
pubkey_from = sender_keys.pubkey
|
||||||
|
|
||||||
|
print("txstatus = sendTransaction(sender_keys, _dest, _amount, _comment)")
|
After Width: | Height: | Size: 23 KiB |
|
@ -0,0 +1,5 @@
|
||||||
|
duniter.moul.re:443
|
||||||
|
g1.duniter.fr:443
|
||||||
|
g1.duniter.org:443
|
||||||
|
g1.monnaielibreoccitanie.org:443
|
||||||
|
g1.presles.fr:443
|
|
@ -0,0 +1,79 @@
|
||||||
|
#!/bin/bash
|
||||||
|
##################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: GPL (http://www.google.com/search?q=GPL)
|
||||||
|
##################################################################
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###################################################################################################################################
|
||||||
|
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 "
|
||||||
|
}
|
||||||
|
else
|
||||||
|
export G1SMS="YES"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
export YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
export CHEMIN="/home/$YOU/G1sms+"
|
||||||
|
cd $CHEMIN
|
||||||
|
##################################################################
|
||||||
|
# Activate logging to /tmp/g1sms.log (YES/NO)
|
||||||
|
export DOLOG="YES"
|
||||||
|
export CPERROR="NOYES"
|
||||||
|
##################################################################
|
||||||
|
# Country Node Phone international prefix (TODO Worldwide)
|
||||||
|
export COUNTRY="+33"
|
||||||
|
##################################################################
|
||||||
|
# DU has a G1 value changed every 6 month!
|
||||||
|
# ./_DU Updated by cron_CODE.backup.sh
|
||||||
|
if [[ -f "./_DU" ]]; then export DUFACTOR=$(bc <<< "scale=2; $(cat "./_DU") / 100"); else log "__SUB:init.sh: FAILING TO FIND ./_DU EXIT!!!"; exit; fi
|
||||||
|
##################################################################
|
||||||
|
# Choose Default Unit: G1, DU, LOVE (DU cents), ZEN (G1 cents)
|
||||||
|
export COIN="G1"
|
||||||
|
##################################################################
|
||||||
|
# Limit and commission values
|
||||||
|
export LIMIT=2 # Solde minimum = 2 G1
|
||||||
|
# FIXED COMMISSION SYSTEM
|
||||||
|
export COMMISSION=1 # transaction commission amount (G1)
|
||||||
|
export BILLCOM=20
|
||||||
|
##################################################################
|
||||||
|
# COMMISSION PARTS FROM TX FOR NODE & G1SMS NETWORK
|
||||||
|
# PART COMMISSION SYSTEM
|
||||||
|
export SWARMCOMM=10
|
||||||
|
# TODO: NODE G1sms Wallet can receive rewards from SWARM or WALLETS/FILES
|
||||||
|
export NODECOMM=10
|
||||||
|
##################################################################
|
||||||
|
# SMS SIM Card Phone Number
|
||||||
|
export MASTERPHONE="+33660780131"
|
||||||
|
export ADRESSE="au G1FabLab de Toulouse"
|
||||||
|
export G1DAB="NO"
|
||||||
|
##################################################################
|
||||||
|
# ADMIN COMMAND PHONE ORIGIN
|
||||||
|
export ADMINPHONE="+33647683646"
|
||||||
|
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 pip3 install silkaj"
|
||||||
|
# export SILKAJ="/usr/local/bin/silkaj"
|
||||||
|
source $CHEMIN/shell/init_keys.sh
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
#!/bin/bash
|
||||||
|
##################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: GPL (http://www.google.com/search?q=GPL)
|
||||||
|
##################################################################
|
||||||
|
# CHECK & WARN | CREATE Keys (gpg encrypt, G1wallet, IPNS publish)
|
||||||
|
##################################################################
|
||||||
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
# TODO Make it directory independant. (for now it is tested for pi running ipfs and code in $HOME/G1sms+
|
||||||
|
CHEMIN="/home/$YOU/G1sms+"
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
# G1sms+ Node KEYS (G1wallet, gpg, IPNS)
|
||||||
|
##################################################################
|
||||||
|
export GPGPASS=$(cat "/home/$YOU/.ipfs/config" | jq '.Identity.PrivKey' | sed s/\"//g)
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
# G1sms+ Swarm KEYS
|
||||||
|
##################################################################
|
||||||
|
# G1sms Service - G1Wallet
|
||||||
|
if [[ -f "${CHEMIN}/g1sms.pub.key" && -f "${CHEMIN}/g1sms.priv.key" ]]; then
|
||||||
|
chown root:root ${CHEMIN}/g1sms.priv.key
|
||||||
|
chmod 600 ${CHEMIN}/g1sms.priv.key
|
||||||
|
export MASTERPUB=$(cat "${CHEMIN}/g1sms.pub.key")
|
||||||
|
export MASTERKEYFILE="${CHEMIN}/g1sms.priv.key"
|
||||||
|
else
|
||||||
|
echo "ATTENTION!! Vous devez posséder la clef du G1 Wallet utilisé par le SWARM G1sms!!"
|
||||||
|
./shell/parle.sh "Les clefs du portefeuille essaim G1 SMS sont absente. Au revoir."
|
||||||
|
echo "Fichiers manquants:"
|
||||||
|
echo "${CHEMIN}/g1sms.pub.key"
|
||||||
|
echo "${CHEMIN}/g1sms.priv.key"
|
||||||
|
echo "Contactez nous sur https://g1sms.fr"
|
||||||
|
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "Clef de G1Wallet du SWARM g1sms.priv.key manquante! contactez-nous pour la recevoir https://g1sms.fr" 1>&2
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
# NODE KEYS (SCRIPT CALLED BY ROOT !!! gammu is root)
|
||||||
|
##################################################################
|
||||||
|
export IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||||
|
export NANODATE=$(date -u +%s%N) #1569692075385428020
|
||||||
|
|
||||||
|
# CHECK LAST TIME NODE HAD ACTION
|
||||||
|
if [[ -f ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate ]]; then
|
||||||
|
last=$(cat ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate)
|
||||||
|
timediff=$( echo "${NANODATE} - ${last}" | bc -l )
|
||||||
|
# Get median nanodate before
|
||||||
|
# NODE TIME SYNC 120 milliards de nanosecondes
|
||||||
|
if [[ $timediff -gt 120000000000 ]]; then
|
||||||
|
log "__SUB:ntpdate pool.ntp.org: $timediff $(ntpdate pool.ntp.org)"
|
||||||
|
export NANODATE=$(date -u +%s%N)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $NANODATE > ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate
|
||||||
|
|
||||||
|
#################################################################
|
||||||
|
# CREATE NODE .$IPFSNODEID SPACE (G1Wallet + TASK + NODE DETAILS)
|
||||||
|
#################################################################
|
||||||
|
# Create G1sms Wallet with that NODE G1 wallet as member reference
|
||||||
|
if [[ ! -f "./wallets/.$IPFSNODEID/$IPFSNODEID.pub" ]]; then
|
||||||
|
mkdir -p ./wallets/.$IPFSNODEID/TASK
|
||||||
|
NODEG1WALLET=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$IPFSNODEID" -password="$GPGPASS")
|
||||||
|
echo "${GPGPASS}" | gpg -q --output "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./authfile"
|
||||||
|
./shell/natools.py encrypt -p $NODEG1WALLET -i "./authfile" -o "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.crypt"
|
||||||
|
rm -f ./authfile
|
||||||
|
|
||||||
|
echo $NODEG1WALLET > "./wallets/.$IPFSNODEID/$IPFSNODEID.pub"
|
||||||
|
echo $IPFSNODEID > "./wallets/.$IPFSNODEID/$IPFSNODEID.ipfsid"
|
||||||
|
log "__SUB:initkeys.sh: [ADMIN] G1sms+ CREATE G1WALLET FOR: $IPFSNODEID: pub = $NODEG1WALLET "
|
||||||
|
|
||||||
|
# BACKUP $IPFSNODEID config
|
||||||
|
./shell/natools.py encrypt -p $MASTERPUB -i "/home/$YOU/.ipfs/config" -o "./wallets/.$IPFSNODEID/$IPFSNODEID.ipfsconfig.crypt"
|
||||||
|
log "__SUB:initkeys.sh: [ADMIN] BACKUP $IPFSNODEID NODE CONFIG to ./wallets/.$IPFSNODEID/$IPFSNODEID.ipfsconfig.crypt "
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# GIVE NAME TO WALLET
|
||||||
|
#######################
|
||||||
|
# 4 derniers chiffres du numéro de téléphone
|
||||||
|
TAIL=${MASTERPHONE:8:4}
|
||||||
|
# No UIDNA yet. Create new
|
||||||
|
UIDNA=$(./shell/diceware.sh 1 | xargs)
|
||||||
|
# Check if already existing among all swarm wallets
|
||||||
|
while [[ $(grep -Rwl "$UIDNA$TAIL" ./wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./shell/diceware.sh 1 | xargs); done
|
||||||
|
echo "$UIDNA$TAIL" > "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna"
|
||||||
|
|
||||||
|
# CREATE NODE WALLET LIKE A PHONE (Stored in wallets/.$IPFSNODEID)
|
||||||
|
echo "${GPGPASS}" > "./wallets/.$IPFSNODEID/$IPFSNODEID.pin"
|
||||||
|
echo "${GPGPASS}" | gpg -q --output "./wallets/.$IPFSNODEID/$IPFSNODEID.pin.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./wallets/.$IPFSNODEID/$IPFSNODEID.pin"
|
||||||
|
echo "" > "./wallets/.$IPFSNODEID/$IPFSNODEID.pin"
|
||||||
|
echo "$UIDNA$TAIL" > "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna"
|
||||||
|
echo "314" > "./wallets/.$IPFSNODEID/$IPFSNODEID.g1cents"
|
||||||
|
echo $NODEG1WALLET > "./wallets/.$IPFSNODEID/$IPFSNODEID.pub"
|
||||||
|
|
||||||
|
# SILKAJ INIT G1 NODE WALLET
|
||||||
|
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$MASTERKEYFILE" --amount=3.15 --output=$NODEG1WALLET --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $UIDNA$TAIL $IPFSNODEID" -y)
|
||||||
|
TX_OUT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$IPFSNODEID" -password="$GPGPASS" --amount=0.1 --output=$MASTERPUB --comment="[G1sms+] G1NODE $IPFSNODEID:ACK" -y)
|
||||||
|
log "__SUB:initkeys.sh: [ADMIN] G1sms+ $ADMINPSEUDO-$UIDNA$TAIL OUVERT POUR NODE: ls ./wallet/.$IPFSNODEID"
|
||||||
|
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "[ADMIN] G1sms+ $ADMINPSEUDO-$UIDNA$TAIL OUVERT POUR NODE: ls ./wallets/.$IPFSNODEID" 1>&2
|
||||||
|
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "$NODEG1WALLET" 1>&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
#INFORM ABOUT NODE CAPACITIES
|
||||||
|
export NODEG1PUB=$(cat "./wallets/.$IPFSNODEID/$IPFSNODEID.pub")
|
||||||
|
|
||||||
|
## IS IT A SMS NODE (gammu-smsd is installed)??
|
||||||
|
if [[ $G1SMS ]]; then
|
||||||
|
echo $MASTERPHONE > "./wallets/.$IPFSNODEID/$IPFSNODEID.sms"
|
||||||
|
else
|
||||||
|
if [ -f "./wallets/.$IPFSNODEID/$IPFSNODEID.sms" ]; then rm -f "./wallets/.$IPFSNODEID/$IPFSNODEID.sms"; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
## IS THERE USB PRINTER CONNECTED?
|
||||||
|
if [[ -e "/dev/usb/lp0" ]]; then
|
||||||
|
log "G1CORE: IMPRESSION G1Tag ACTIF .............."
|
||||||
|
echo $ADRESSE > "./wallets/.$IPFSNODEID/$IPFSNODEID.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" > "./wallets/.$IPFSNODEID/$IPFSNODEID.scan"
|
||||||
|
else
|
||||||
|
if [ -f "./wallets/.$IPFSNODEID/$IPFSNODEID.scan" ]; then rm -f "./wallets/.$IPFSNODEID/$IPFSNODEID.scan"; fi
|
||||||
|
fi
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os, sys, duniterpy.key, libnacl.sign
|
||||||
|
|
||||||
|
def getargv(arg:str, default:str="", n:int=1, args:list=sys.argv) -> str:
|
||||||
|
if arg in args and len(args) > args.index(arg)+n:
|
||||||
|
return args[args.index(arg)+n]
|
||||||
|
else:
|
||||||
|
return default
|
||||||
|
|
||||||
|
def read_data(data_path, b=True):
|
||||||
|
if data_path == "-":
|
||||||
|
if b:
|
||||||
|
return sys.stdin.read().encode()
|
||||||
|
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()
|
||||||
|
|
||||||
|
def write_data(data, result_path):
|
||||||
|
(sys.stdout if result_path == "-" 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)
|
||||||
|
|
||||||
|
def sign(data, privkey):
|
||||||
|
return duniterpy.key.SigningKey.from_seedhex(privkey).sign(data)
|
||||||
|
|
||||||
|
def verify(data, pubkey):
|
||||||
|
try:
|
||||||
|
return libnacl.sign.Verifier(duniterpy.key.PublicKey(pubkey).hex_pk()).verify(data)
|
||||||
|
except ValueError:
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
def show_help():
|
||||||
|
print("""Usage:
|
||||||
|
python3 natools.py <command> [options]
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
encrypt Encrypt data
|
||||||
|
decrypt Decrypt data
|
||||||
|
sign Sign data
|
||||||
|
verify Verify data
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-i <path> Input file path (default: -)
|
||||||
|
-k <path> Privkey file path (default: authfile.key)
|
||||||
|
-p <str> Pubkey (base58)
|
||||||
|
-o <path> Output file path (default: -)
|
||||||
|
|
||||||
|
Note: "-" means stdin or stdout.
|
||||||
|
""")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
if "--help" in sys.argv:
|
||||||
|
show_help()
|
||||||
|
exit()
|
||||||
|
|
||||||
|
data_path = getargv("-i", "-")
|
||||||
|
privkey_path = getargv("-k", "authfile.key")
|
||||||
|
pubkey = getargv("-p")
|
||||||
|
result_path = getargv("-o", "-")
|
||||||
|
|
||||||
|
try:
|
||||||
|
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)
|
||||||
|
elif sys.argv[1] == "sign":
|
||||||
|
write_data(sign(read_data(data_path), read_data(privkey_path, False)), 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")
|
||||||
|
show_help()
|
||||||
|
exit(1)
|
|
@ -0,0 +1,9 @@
|
||||||
|
g1.le-sou.org:443
|
||||||
|
follow.the.white-rabbit.net:443
|
||||||
|
duniter.moul.re:443
|
||||||
|
g1.monnaielibreoccitanie.org:443
|
||||||
|
g1.duniter.inso.ovh:443
|
||||||
|
g1.duniter.fr:443
|
||||||
|
g1.presles.fr:443
|
||||||
|
g1.duniter.org:443
|
||||||
|
monit.g1.nordstrom.duniter.org:443
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
f=$(echo "$1" | sed 's/ //g' )
|
||||||
|
echo "parle.sh: $1 | $2 = $f" >> /tmp/parle.log 2>&1
|
||||||
|
if [[ "$2" == "" ]]; then
|
||||||
|
lang="fr-FR"
|
||||||
|
else
|
||||||
|
lang="en-US"
|
||||||
|
fi
|
||||||
|
if [[ ! -f "/tmp/$lang_${f}.wav" ]]; then
|
||||||
|
pico2wave -l $lang -w /tmp/$lang_${f}.wav "$1"
|
||||||
|
fi
|
||||||
|
aplay -q /tmp/$lang_${f}.wav
|
|
@ -0,0 +1,32 @@
|
||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
from duniterpy.api.client import Client
|
||||||
|
|
||||||
|
ES_CORE_ENDPOINT = "ES_CORE_API g1.data.duniter.fr 443"
|
||||||
|
ES_USER_ENDPOINT = "ES_USER_API g1.data.duniter.fr 443"
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
"""
|
||||||
|
Main code (synchronous requests)
|
||||||
|
"""
|
||||||
|
# Create Client from endpoint string in Duniter format
|
||||||
|
client = Client(ES_USER_ENDPOINT)
|
||||||
|
|
||||||
|
# Get entry
|
||||||
|
# pubkey = input("\nEnter a public key to get the user profile: ")
|
||||||
|
# pubkey = "DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech"
|
||||||
|
pubkey = sys.argv[1]
|
||||||
|
|
||||||
|
# Get the profil of a public key (direct REST GET request)
|
||||||
|
# print("\nGET user/profile/{0}/_source:".format(pubkey))
|
||||||
|
# response = await client.get('tx/history/{0}'.format(pubkey.strip(' \n')))
|
||||||
|
response = await client.get('user/profile/{0}/_source'.format(pubkey.strip(' \n')))
|
||||||
|
print(json.dumps(response))
|
||||||
|
|
||||||
|
# Close client aiohttp session
|
||||||
|
await client.close()
|
||||||
|
|
||||||
|
# Latest duniter-python-api is asynchronous and you have to use asyncio, an asyncio loop and a "as" on the data.
|
||||||
|
# ( https://docs.python.org/3/library/asyncio.html )
|
||||||
|
asyncio.get_event_loop().run_until_complete(main())
|
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
##################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: GPL (http://www.google.com/search?q=GPL)
|
||||||
|
##################################################################
|
||||||
|
# Commande SMS: sms_ABO.sh
|
||||||
|
# ABO "$SERVICE" "$YESNO"
|
||||||
|
# Gère les Abonnements aux communications PUSH SMS
|
||||||
|
##################################################################
|
||||||
|
# TODO: Create information Channels and moderate OPT IN/OUT
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "__SUB:sms_ABO.sh: START ($1=SERVICE, $2=YESNO)"
|
||||||
|
SERVICE=$1
|
||||||
|
YESNO=$2
|
||||||
|
PARAMS=$3
|
||||||
|
|
||||||
|
case "$SERVICE" in
|
||||||
|
MARCHE)
|
||||||
|
log "Avertissement G1 marchés"
|
||||||
|
# PARAMS could be "$distance" to Member GeoPoint...
|
||||||
|
;;
|
||||||
|
GCHANGE)
|
||||||
|
log "Création Alerte Annonce GCHANGE"
|
||||||
|
# PARAMS could be "$distance#$keyword" to search gchange.fr near Member GeoPoint...
|
||||||
|
;;
|
||||||
|
INFO)
|
||||||
|
log "Abonnement Newsletter"
|
||||||
|
# PARAMS could be "$distance#$keyword" to search gchange.fr near Member GeoPoint...
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# AIDE : ABO GCHANGE 100#maison...
|
||||||
|
log "Renvoyez AIDE..."
|
||||||
|
sms_SEND "$PHONE" "Cette commande est inactive..."
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -0,0 +1,89 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# Accessible seulement pour ADMINPHONE.
|
||||||
|
# Permet de lancer des paquets de SMS aux membres, wallets, ...
|
||||||
|
# TODO Add OptIN/OUT options (./shell/sms_ABO.sh) + Extand ADMIN functions...
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "__SUB:sms_ADMIN.sh: START ($1=CMD, $2=MESSAGE)"
|
||||||
|
|
||||||
|
CMD="$1"
|
||||||
|
MESSAGE="$2"
|
||||||
|
|
||||||
|
case "$CMD" in
|
||||||
|
|
||||||
|
USR)
|
||||||
|
log "__SUB:sms_ADMIN.sh: Send message to phone Member or Wallet UIDNA"
|
||||||
|
# Get it from first MESSAGE message word...
|
||||||
|
towoo=$(echo $MESSAGE | cut -d ' ' -f 1)
|
||||||
|
|
||||||
|
SEARCH=$(grep -Rwl "$towoo" ./wallets_swarm/*/*.uidna* | tail -n 1 | cut -f 3 -d '/')
|
||||||
|
if [[ "$SEARCH" != "" ]]; then
|
||||||
|
REMOTENODE=$(cat ./wallets_swarm/$SEARCH/MASTERPHONE.sms)
|
||||||
|
DESTRIB=$(cat ./wallets_swarm/$SEARCH/$SEARCH.pub)
|
||||||
|
DESTPHONE=$SEARCH
|
||||||
|
log "__SUB:sms_ADMIN.sh: FOUND $towoo on NODE ($REMOTENODE) G1sms+ wallet: $DESTRIB : $DESTPHONE)"
|
||||||
|
|
||||||
|
if [[ "$DESTPHONE" == "$ADMINPHONE" || "$DESTPHONE" == "$MASTERPHONE" ]]; then continue; fi
|
||||||
|
sms_SEND "$DESTPHONE" "$MESSAGE"
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN OK!! Message: $MESSAGE envoyé à $towoo: $DESTPHONE"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
|
MEM)
|
||||||
|
log "__SUB:sms_ADMIN.sh: Send $MESSAGE message to All NODE members"
|
||||||
|
for f in ./wallets/*/*.uidname; do
|
||||||
|
uid=$(cat $f);
|
||||||
|
num=$(echo $f | cut -d '/' -f3);
|
||||||
|
if [[ "$num" == "$ADMINPHONE" || "$num" == "$MASTERPHONE" ]]; then continue; fi
|
||||||
|
log "__SUB:sms_ADMIN.sh: Send SMS to $num: $uid"
|
||||||
|
sms_SEND "$num" "$uid, $MESSAGE"
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! Message envoyé aux $(cat ./wallets/*/*.uidname | wc -l) membres de ce NODE"
|
||||||
|
;;
|
||||||
|
|
||||||
|
ALL)
|
||||||
|
log "__SUB:sms_ADMIN.sh: Send $MESSAGE message to All NODE G1sms wallets"
|
||||||
|
for f in ./wallets/*; do
|
||||||
|
num=$(echo $f | cut -d '/' -f3);
|
||||||
|
if [[ "$num" == "$ADMINPHONE" || "$num" == "$MASTERPHONE" ]]; then continue; fi
|
||||||
|
log "__SUB:sms_ADMIN.sh: Send SMS to $num"
|
||||||
|
sms_SEND "$num" "$MESSAGE"
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! Message envoyé aux $(ls ./wallets/ | cut -d '/' -f3 | wc -l) possesseur de G1sms Wallets de ce NODE"
|
||||||
|
;;
|
||||||
|
|
||||||
|
SWARM)
|
||||||
|
log "__SUB:sms_ADMIN.sh: Send $MESSAGE message to All SWARM G1sms wallets"
|
||||||
|
for f in ./wallets_swarm/+33*; do
|
||||||
|
num=$(echo $f | cut -d '/' -f3);
|
||||||
|
if [[ "$num" == "$ADMINPHONE" || "$num" == "$MASTERPHONE" ]]; then continue; fi
|
||||||
|
log "__SUB:sms_ADMIN.sh: Send SMS to $num"
|
||||||
|
sms_SEND "$num" "$MESSAGE"
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! Message: $MESSAGE envoyé aux $(ls ./wallets_swarm/ | cut -d '/' -f3 | wc -l) PHONE G1sms Wallets du SWARM"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
log "__SUB:sms_ADMIN.sh: Send back ERRORs message to Admin"
|
||||||
|
if [ -f "/tmp/ERROR.CRON" ]; then
|
||||||
|
text=$(cat "/tmp/ERROR.CRON")
|
||||||
|
rm -f "/tmp/ERROR.CRON"
|
||||||
|
fi
|
||||||
|
sms_SEND "$ADMINPHONE" "USR / MEM / ALL / SWARM
|
||||||
|
$text"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! JOB FINISHED"
|
||||||
|
|
||||||
|
log "__SUB:sms_ADMIN.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "X sms_AIDE.sh ($1=phone)"
|
||||||
|
|
||||||
|
sms_INIT_ACCOUNT "$1" "NOSMS"
|
||||||
|
|
||||||
|
MESS="[Aide]
|
||||||
|
N Id-M (Relier au portefeuille Id-M)
|
||||||
|
U G1/DU/LOVE (UNIT)
|
||||||
|
S (Solde)
|
||||||
|
P 06nnnnnnnn 300 (Envoyer 300 UNIT à 06nnnnnnnn)"
|
||||||
|
# Send response SMS
|
||||||
|
sms_SEND "$1" "$MESS"
|
||||||
|
|
||||||
|
MESS="EMAIL moi@email.tld (Recevoir vos commandes par email)
|
||||||
|
TAG 10 5 (Créer 5 G1Tag de 10 G1)
|
||||||
|
VIR 50 Idw (Virer 50 UNIT vers Idw)"
|
||||||
|
sms_SEND "$1" "$MESS"
|
||||||
|
|
||||||
|
MESS="REC (Pour un payement récurrent)
|
||||||
|
D (Détail de votre compte)
|
||||||
|
A votre service.
|
||||||
|
$ADMINPSEUDO / G1sms+ / $ADMINPHONE
|
||||||
|
https://g1sms.fr"
|
||||||
|
sms_SEND "$1" "$MESS"
|
||||||
|
|
||||||
|
log "END sms_AIDE.sh"
|
||||||
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
|
||||||
|
exit
|
|
@ -0,0 +1,157 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# Create and print 6 G1Billets de nn LOVE
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "X sms_BILLET.sh ($1=phone, $2=VALbillet)"
|
||||||
|
|
||||||
|
phone="$1"
|
||||||
|
VALbillet="$2"
|
||||||
|
# 6 BILLETS DE $VALbillet LOVE PAR SMS !!
|
||||||
|
NBbillets=6
|
||||||
|
|
||||||
|
# Initialise PHONE, PIN, PUBKEY, UNIT, HIST + MEMBER + MEMRIB +...
|
||||||
|
sms_INIT_ACCOUNT "$phone" "NOSMS"
|
||||||
|
|
||||||
|
# FIXED LOVE UNIT (6 month maximum validity)
|
||||||
|
UNIT="LOVE"
|
||||||
|
|
||||||
|
log "MEMBER? $PHONE => $MEMBER"
|
||||||
|
|
||||||
|
if [[ $UNKNOWN == "unknown" || "$MEMBER" == "" ]]; then
|
||||||
|
sms_ERROR "$phone" "Porte-monnaie non identifié.
|
||||||
|
Envoyez N suivi de votre pseudo membre (en respectant Majuscule et minuscule)."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $MAIL == "" ]]; then
|
||||||
|
sms_ERROR "$phone" "Impossible de réaliser votre commande.
|
||||||
|
Envoyez \"EMAIL votre_email\" pour pouvoir recevoir vos billets..."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $VALbillet -lt 10 ]; then
|
||||||
|
sms_ERROR "$phone" "Montant minimum 10 $UNIT !!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $VALbillet -gt 1000 ]; then
|
||||||
|
sms_ERROR "$phone" "Montant maximum: 1000 $UNIT !!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU
|
||||||
|
AMOUNTG1=$(./silkaj/silkaj amount "$PUBKEY")
|
||||||
|
AMOUNTDU=$(bc -l <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
|
||||||
|
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
|
||||||
|
|
||||||
|
# Convert amount to G1 unit
|
||||||
|
amount=$(bc <<< "$NBbillets * $VALbillet")
|
||||||
|
VIR=$(bc -l <<< "scale=2; $amount * $DUFACTOR / 100")
|
||||||
|
|
||||||
|
# Need at least $MIN G1 available! $BILLCOM G1 commission
|
||||||
|
MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT - 21")
|
||||||
|
testmin=$( echo "${VIR} < ${MIN}" | bc -l )
|
||||||
|
log "TEST : $VIR < $MIN ? $testmin"
|
||||||
|
|
||||||
|
# silkaj NODE CHANGE !!!
|
||||||
|
SILKAJNODE=$(./shell/checknodes.sh)
|
||||||
|
log "NEW SILKAJ NODE: $SILKAJNODE"
|
||||||
|
|
||||||
|
if [[ "$testmin" -eq "1" ]]
|
||||||
|
then
|
||||||
|
boucle=0;
|
||||||
|
while [ $boucle -lt $NBbillets ]
|
||||||
|
do
|
||||||
|
# Creation du numéro de billet
|
||||||
|
NUMBER=$(./shell/diceware.sh 4 | xargs)
|
||||||
|
bpath=$(echo $NUMBER | sed 's/ /_/g')
|
||||||
|
|
||||||
|
# Cas d'un billet existant
|
||||||
|
while [ -d "./billets/$bpath" ]
|
||||||
|
do
|
||||||
|
NUMBER=$(./shell/diceware.sh 4 | xargs)
|
||||||
|
bpath=$(echo $NUMBER | sed 's/ /_/g')
|
||||||
|
done
|
||||||
|
|
||||||
|
SECRET=$(./shell/diceware.sh 3 | xargs)
|
||||||
|
SALT=$(./shell/diceware.sh 3 | xargs)
|
||||||
|
|
||||||
|
boucle=$(bc -l <<< "$boucle + 1")
|
||||||
|
|
||||||
|
log "->BILLET:$PHONE:$NUMBER:$VALbillet:$UNIT"
|
||||||
|
# CREATE "NUMBER SECRET SALT" ACCOUNT for G1 transfert
|
||||||
|
TRANSAC=$(bc -l <<< "scale=2; $VIR / $NBbillets")
|
||||||
|
BILLETPUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NUMBER" -password="$SECRET $SALT")
|
||||||
|
log_history $PHONE "BILLET, $TRANSAC, $BILLETPUBKEY"
|
||||||
|
sleep 3
|
||||||
|
# Fill BILLET with TRANSAC amount
|
||||||
|
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$TRANSAC" --output="$BILLETPUBKEY" --comment="THIRD_PARTY_MANAGER:$MASTERPUB:G1SMS:BILLET" -y)
|
||||||
|
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then
|
||||||
|
mkdir -p "./billets/$bpath"
|
||||||
|
# NOTES ARE FILES STORED IN DICEWARE COMPOSED SUBDIR
|
||||||
|
echo "$MEMBER" > "./billets/$bpath/note.creator"
|
||||||
|
echo "$NUMBER" > "./billets/$bpath/note.number"
|
||||||
|
echo "$PHONE" > "./billets/$bpath/note.phone"
|
||||||
|
echo "$SECRET" > "./billets/$bpath/note.secret"
|
||||||
|
echo "$SALT" > "./billets/$bpath/note.salt"
|
||||||
|
echo "$VALbillet" > "./billets/$bpath/note.value"
|
||||||
|
echo "$UNIT" > "./billets/$bpath/note.unit"
|
||||||
|
echo "$BILLETPUBKEY" > "./billets/$bpath/note.pubkey"
|
||||||
|
log "Remplissage: $TRANSAC G1... $BILLETPUBKEY = $PAY"
|
||||||
|
|
||||||
|
# CREATION FICHIER IMAGE BILLET
|
||||||
|
$(./shell/sms_BILLET_MAKE.sh "$NUMBER" "$SECRET" "$VALbillet" "$UNIT" "$DUFACTOR" "$BILLETPUBKEY" "$MEMBER" "$TRANSAC")
|
||||||
|
log "./shell/sms_BILLET_MAKE.sh \"$NUMBER\" \"$SECRET\" \"$VALbillet\" \"$UNIT\" \"$DUFACTOR\" \"$BILLETPUBKEY\" \"$MEMBER\" \"$TRANSAC\""
|
||||||
|
|
||||||
|
# Transaction to create Link BILLET <-> MEMBER RIB => Decrease BILLET value !
|
||||||
|
sleep 2
|
||||||
|
# PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$NUMBER" -password="$SECRET $SALT" --amount="0.05" --output="$MEMRIB" --comment="THIRD_PARTY_MANAGER:$MASTERPUB:G1SMS:BILLET:$VALbillet:$UNIT:$NUMBER" -y)
|
||||||
|
else
|
||||||
|
sms_ERROR "$PHONE" "Un problème est survenu. Contactez $ADMINPSEUDO au $ADMINPHONE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# + G1SMS Commission
|
||||||
|
sleep 2
|
||||||
|
COM=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$BILLCOM" --output="$MASTERPUB" --comment="[G1SMS] G1billet Commission" -y)
|
||||||
|
|
||||||
|
# IMPRIMER LES BILLETS! Brancher votre imprimante et configurer cups avant ;)
|
||||||
|
num=$(date +%Y%m%d)
|
||||||
|
log "PRINT $num $MEMBER"
|
||||||
|
montage ./billets/MEMBERS/$MEMBER/*.jpg -tile 2x3 -geometry 964x459 /tmp/$PHONE_Bills_$bpath.pdf
|
||||||
|
# lp /tmp/$PHONE_Bills_$bpath.pdf
|
||||||
|
cp /tmp/$PHONE_Bills_$bpath.pdf ./billets/MEMBERS/$MEMBER/
|
||||||
|
zip ./_Bill_$MEMBER_$num.zip ./billets/MEMBERS/$MEMBER/*.jpg && rm -f ./billets/MEMBERS/$MEMBER/*.jpg
|
||||||
|
|
||||||
|
# SEND EMAIL
|
||||||
|
# Détruit ce mail et le pdf après impression et fabrication des billets au code caché.
|
||||||
|
# Créer la monnaie implique une grande responsabilité!
|
||||||
|
|
||||||
|
mess="[G1SMS]
|
||||||
|
$NBbillets billet(s) de $VALbillet $UNIT ($TRANSAC G1) créé(s).
|
||||||
|
Contactez $ADMINPSEUDO au $ADMINPHONE pour les recevoir...
|
||||||
|
http://g1sms.fr/g1sms/aide"
|
||||||
|
|
||||||
|
sms_SEND "$phone" "$mess"
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
# Amount too High, solde insuffisant
|
||||||
|
else
|
||||||
|
text="Solde: $AMOUNTLOVE LOVE ($AMOUNTG1 G1 = $AMOUNTDU DU)
|
||||||
|
Insuffisant pour créer $NBbillets billet(s) de $VALbillet $UNIT
|
||||||
|
(= $VIR G1 + Commission $BILLCOM G1)"
|
||||||
|
sms_ERROR "$phone" "$text"
|
||||||
|
|
||||||
|
sms_SEND "$phone" "Rechargez votre porte-monnaie!
|
||||||
|
https://g1.duniter.fr/api/#/v1/payment/$PUBKEY?amount=$VIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "END sms_BILLET.sh"
|
||||||
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
|
||||||
|
exit
|
|
@ -0,0 +1,78 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# If 4 words provided => Check if Billet exists and return BILLET AMOUNT VALUE
|
||||||
|
# If 7 words provided => if Billet exists, transfer AMOUNT to PHONE & destroy BILLET
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "X sms_BILLETCHK.sh $0"
|
||||||
|
|
||||||
|
PHONE="$1"
|
||||||
|
CODE="$2 $3 $4 $5"
|
||||||
|
SEC="$6 $7 $8"
|
||||||
|
|
||||||
|
# Construct billet path
|
||||||
|
bpath=$(echo "$CODE" | sed 's/ /_/g')
|
||||||
|
|
||||||
|
if [ -d "./billets/$bpath" ]
|
||||||
|
then
|
||||||
|
SECRET=$(cat "./billets/$bpath/note.secret")
|
||||||
|
SALT=$(cat "./billets/$bpath/note.salt")
|
||||||
|
VALbillet=$(cat "./billets/$bpath/note.value")
|
||||||
|
UNIT=$(cat "./billets/$bpath/note.unit")
|
||||||
|
BILLETPUBKEY=$(cat "./billets/$bpath/note.pubkey")
|
||||||
|
|
||||||
|
AMOUNTG1=$(./silkaj/silkaj amount "$BILLETPUBKEY")
|
||||||
|
log "Billet: $AMOUNTG1 ($VALbillet $UNIT): $BILLETPUBKEY"
|
||||||
|
|
||||||
|
# NO GOOD SECRET
|
||||||
|
if [[ "$SEC" != "$SECRET" ]]; then
|
||||||
|
# SEND ACTUAL BILLET VALUE
|
||||||
|
mess="[G1SMS]
|
||||||
|
Billet de $VALbillet $UNIT Valide!
|
||||||
|
Valeur: $AMOUNTG1 G1
|
||||||
|
https://www.g1sms.fr/contact"
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
log "BILLETCHK: $VALbillet $UNIT ($AMOUNTG1 G1)"
|
||||||
|
log_history $PHONE "BILLET_CHK, $AMOUNTG1, $bpath"
|
||||||
|
else
|
||||||
|
# TRANSFER & DESTROY
|
||||||
|
sms_INIT_ACCOUNT "$PHONE" "NOSMS"
|
||||||
|
if [[ "$UNKNOWN" == "unknown" ]]; then
|
||||||
|
# Account creation
|
||||||
|
sms_INIT_ACCOUNT "$PHONE"
|
||||||
|
fi
|
||||||
|
log "./silkaj/silkaj transaction --auth-scrypt -salt=\"$CODE\" -password=\"$SEC $SALT\" --amount=\"$AMOUNTG1\" --output=\"$PUBKEY\" --comment=\"THIRD_PARTY_MANAGER:$MASTERPUB:G1SMS:ENCAISSEMENT:$CODE\" -y"
|
||||||
|
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$CODE" -password="$SEC $SALT" --amount="$AMOUNTG1" --output="$PUBKEY" --comment="THIRD_PARTY_MANAGER:$MASTERPUB:ENCAISSEMENT:$CODE" -y)
|
||||||
|
|
||||||
|
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then
|
||||||
|
# DESTROY BILLET
|
||||||
|
rm -f ./billets/$bpath/note.*
|
||||||
|
rmdir ./billets/$bpath
|
||||||
|
# DESTROY PUBLIC CACHE in /tmp
|
||||||
|
if [ -d "/tmp/billets_valides/$bpath" ]; then
|
||||||
|
rm -f /tmp/billets_valides/$bpath/*
|
||||||
|
rmdir /tmp/billets_valides/$bpath
|
||||||
|
fi
|
||||||
|
|
||||||
|
SOLDE=$(./silkaj/silkaj amount "$PUBKEY")
|
||||||
|
|
||||||
|
mess="[G1SMS]
|
||||||
|
ENCAISSEMENT de $VALbillet $UNIT ($AMOUNTG1 G1)
|
||||||
|
ds le porte-monnaie $PHONE ($PUBKEY)
|
||||||
|
OK!
|
||||||
|
Solde: $SOLDE G1"
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
log "BILLETCHK DESTROY: $VALbillet $UNIT ($AMOUNTG1 G1)"
|
||||||
|
log "=> $PUBKEY"
|
||||||
|
log_history $PHONE "BILLET_CHK, $AMOUNTG1, $bpath, $PUBKEY"
|
||||||
|
else
|
||||||
|
sms_ERROR "$PHONE" "Erreur! Transaction Impossible... Réessayez plus tard ou contactez $ADMINPSEUDO : $ADMINPHONE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
sms_SEND "$PHONE" "BILLET \"$CODE\" INCONNU !!"
|
||||||
|
log_history $PHONE "BILLET_CHK, ERROR, $bpath"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "END sms_BILLETCHK.sh"
|
||||||
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
@ -0,0 +1,120 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Make Billet fabrique l'image de 6 billets de monnaie libre
|
||||||
|
# Date de validité de 6 mois à compter du premier jour du mois courant
|
||||||
|
############################################################################
|
||||||
|
# INSTALLER convert et qrencode: sudo apt install imagemagick qrencode
|
||||||
|
# IMPRIMANTE (http://smspi:631/) : sudo apt install printer-driver-all cups
|
||||||
|
# https://junise.wordpress.com/2015/04/12/install-online-cups-printer-in-raspberry-pi/
|
||||||
|
############################################################################
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
# TEST:
|
||||||
|
# ./shell/sms_BILLET_MAKE.sh "nu me ro test" "se cr et" 100 LOVE 10.04 "https://g1sms.fr" G1SMS TEST
|
||||||
|
############################################################################
|
||||||
|
source "./shell/init.sh"
|
||||||
|
source "./shell/functions.sh"
|
||||||
|
|
||||||
|
NUMERO="$1"
|
||||||
|
SECRET="$2"
|
||||||
|
MONTANT="$3"
|
||||||
|
UNIT="$4"
|
||||||
|
DUFACTOR="$5"
|
||||||
|
NOTERIB="$6"
|
||||||
|
MEMBER="$7"
|
||||||
|
TRANSAC="$8"
|
||||||
|
log "X ./shell/sms_BILLET_MAKE.sh \"$1\" \"$2\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7\" \"$8\""
|
||||||
|
|
||||||
|
if [[ "$NOTERIB" == "" || "$MEMBER" == "" ]]
|
||||||
|
then
|
||||||
|
log "ERROR MAKE BILLET"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# VALIDITY? Calculate 6 month period dates
|
||||||
|
cm=$(date +%m)
|
||||||
|
cy=$(date +%Y)
|
||||||
|
valid=$(bc <<< "$cm + 6")
|
||||||
|
if [ $valid -gt 12 ]
|
||||||
|
then
|
||||||
|
valid=$(bc <<< "$valid - 12")
|
||||||
|
year=$(bc <<< "$cy + 1")
|
||||||
|
else
|
||||||
|
year=$cy
|
||||||
|
fi
|
||||||
|
valid="0${valid:0:2}"
|
||||||
|
# ADD VALIDITY to convert: -pointsize 20 -draw 'text 380,410 "'"A encaisser avant le 01/$valid/$year"'"' \
|
||||||
|
|
||||||
|
# Add G1sms logo (250px)
|
||||||
|
composite -compose Over -gravity SouthWest -geometry +50+50 "./shell/G1sms.png" "./shell/Oeuro.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
|
||||||
|
# Prepare BILLET qrcode verification URL
|
||||||
|
#qrencode "$NOTERIB" -o "/tmp/$NUMERO_NOTERIB.png"
|
||||||
|
REQ=$(echo $NUMERO | sed 's/ /_/g')
|
||||||
|
qrencode "https://www.g1sms.fr/$ADMINPSEUDO/check.php?code=$REQ" -o "/tmp/$NUMERO_NOTERIB.png"
|
||||||
|
|
||||||
|
# BILL PUBKEY => Someone can Add amount to it !!!
|
||||||
|
# Add verification QRCode
|
||||||
|
composite -compose Over -gravity NorthEast -geometry +40+40 "/tmp/$NUMERO_NOTERIB.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
|
||||||
|
# Add June logo
|
||||||
|
case "$MONTANT" in
|
||||||
|
10)
|
||||||
|
convert "./shell/g1.png" -fuzz 20% -fill grey -opaque '#e5912b' "/tmp/g1.png"
|
||||||
|
;;
|
||||||
|
20)
|
||||||
|
convert "./shell/g1.png" -fuzz 20% -fill green -opaque '#e5912b' "/tmp/g1.png"
|
||||||
|
;;
|
||||||
|
50)
|
||||||
|
convert "./shell/g1.png" -fuzz 20% -fill orange -opaque '#e5912b' "/tmp/g1.png"
|
||||||
|
;;
|
||||||
|
100)
|
||||||
|
convert "./shell/g1.png" -fuzz 20% -fill blue -opaque '#e5912b' "/tmp/g1.png"
|
||||||
|
;;
|
||||||
|
200)
|
||||||
|
convert "./shell/g1.png" -fuzz 20% -fill purple -opaque '#e5912b' "/tmp/g1.png"
|
||||||
|
;;
|
||||||
|
500)
|
||||||
|
convert "./shell/g1.png" -fuzz 20% -fill red -opaque '#e5912b' "/tmp/g1.png"
|
||||||
|
;;
|
||||||
|
1000)
|
||||||
|
convert "./shell/g1.png" -fuzz 20% -fill black -opaque '#e5912b' "/tmp/g1.png"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cp "./shell/g1.png" "/tmp/g1.png"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
composite -compose Over -gravity SouthEast -geometry +20+20 "/tmp/g1.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
|
||||||
|
DUPART=$(bc -l <<< "scale=2; $MONTANT / 100")
|
||||||
|
# ADD 0 to <1 DUPART
|
||||||
|
testdu=$( echo "${DUPART} < 1" | bc -l )
|
||||||
|
if [[ "$testdu" -eq "1" ]]; then
|
||||||
|
DUPART="0${DUPART}"
|
||||||
|
fi
|
||||||
|
#SECRET=$(echo $SECRET | sed 's/ /\n/g')
|
||||||
|
|
||||||
|
convert -font 'Liberation-Sans' \
|
||||||
|
-pointsize 120 -fill black -draw 'text 200,220 "'"$DUPART DU"'"' \
|
||||||
|
-pointsize 45 -draw 'text 550,270 "'"$MONTANT $UNIT"'"' \
|
||||||
|
-pointsize 35 -draw 'text 50,60 "'"[G1sms] 06 66 80 57 20"'"' \
|
||||||
|
-pointsize 30 -draw 'text 60,100 "'"CHK $NUMERO"'"' \
|
||||||
|
-pointsize 22 -fill black -draw 'text 520,340 "'"$SECRET"'"' \
|
||||||
|
-pointsize 22 -fill black -draw 'text 400,410 "'"Encaisser avant le 01/$valid/$year"'"' \
|
||||||
|
-pointsize 20 -draw 'text 50,444 "'"Envoyer par sms, CHK $NUMERO + les mots découverts sous la zone à gratter"'"' \
|
||||||
|
"/tmp/$NUMERO.jpg" "/tmp/BILL.$year.$valid.$NUMERO.$MONTANT.$UNIT.jpg"
|
||||||
|
|
||||||
|
# Payable par SMS en envoyant les codes grattant la case comportant le SECRET
|
||||||
|
# "CHK $NUMERO $SECRET"
|
||||||
|
|
||||||
|
if [[ "$TRANSAC" == "TEST" ]]; then
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
# Move billet to MEMBER folder 6 month later
|
||||||
|
mkdir -p "./billets/MEMBERS/$MEMBER/"
|
||||||
|
mv "/tmp/BILL.$year.$valid.$NUMERO.$MONTANT.$UNIT.jpg" "./billets/MEMBERS/$MEMBER/"
|
||||||
|
# Clean TEMP files
|
||||||
|
rm "/tmp/$NUMERO_NOTERIB.png"
|
||||||
|
rm "/tmp/$NUMERO.jpg"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "END sms_BILLET_MAKE.sh"
|
||||||
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
@ -0,0 +1,76 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "X sms_COUNT.sh ($1=phone $2=NOSMS)"
|
||||||
|
PHONE=$1
|
||||||
|
TODAY=$(date '+%Y%m%d')
|
||||||
|
# Initialise PHONE, PIN, PUBKEY, UNIT
|
||||||
|
sms_INIT_ACCOUNT "$PHONE" "NOSMS"
|
||||||
|
if [[ $UNKNOWN == "unknown" && "$PHONE" != "" ]]; then
|
||||||
|
sms_ERROR "$PHONE" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check account amount
|
||||||
|
declare -a accounting
|
||||||
|
accounting=($(check_account))
|
||||||
|
log "$(declare -p accounting)"
|
||||||
|
AMOUNTG1=${accounting[0]}
|
||||||
|
AMOUNT=${accounting[1]}
|
||||||
|
UNIT=${accounting[2]}
|
||||||
|
|
||||||
|
# SEARCH FOR VIREMENT
|
||||||
|
if [[ -f ./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"
|
||||||
|
declare -a LIST
|
||||||
|
num=0
|
||||||
|
cat /tmp/VIREMENTS.$PHONE | while read LIST; do
|
||||||
|
if [[ ${LIST[0]} -gt $TODAY ]]; then
|
||||||
|
((num++))
|
||||||
|
todo="$todo
|
||||||
|
${LIST[0]}: ${LIST[3]} G1 vers ${LIST[5]}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm "/tmp/VIREMENTS.$PHONE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# LOG
|
||||||
|
log "Solde = $AMOUNTG1 ($UNIT)"
|
||||||
|
|
||||||
|
# If script control only run: NOSMS
|
||||||
|
if [ "$2" != "NOSMS" ]; then
|
||||||
|
if [[ "$AMOUNT" != "" ]]; then
|
||||||
|
mess="[G1sms+]
|
||||||
|
ID: $UIDNA <=> $MEMBER
|
||||||
|
$AMOUNT $UNIT ($AMOUNTG1 G1)
|
||||||
|
|
||||||
|
Recharger avec https://cesium.app"
|
||||||
|
# Send response SMS
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
sms_SEND "$PHONE" "$PUBKEY"
|
||||||
|
|
||||||
|
# CHECK NEXT VIREMENTS
|
||||||
|
if [[ $num -gt 0 ]]; then
|
||||||
|
sms_SEND "$PHONE" "Reste $num Virements récurrents
|
||||||
|
$(echo $todo | head -n 2)
|
||||||
|
...
|
||||||
|
|
||||||
|
$(echo $todo | tail -n 1)";
|
||||||
|
fi
|
||||||
|
log_history $PHONE "SOLDE, $AMOUNTG1"
|
||||||
|
else
|
||||||
|
sms_ERROR "$PHONE" "Problème de dialogue silkaj, Serveur $NEWDUNITER... Essayez dans 1 minute SVP..."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo $AMOUNTG1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "END sms_COUNT.sh"
|
||||||
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
|
@ -0,0 +1,75 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "__SUB:sms_DESTROY.sh: START ($1=phone, $2=uid)"
|
||||||
|
|
||||||
|
PHONE="$1"
|
||||||
|
MEMBERUID="$2"
|
||||||
|
TODAY=$(date '+%Y%m%d')
|
||||||
|
|
||||||
|
if [[ -f "./wallets/$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"
|
||||||
|
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"
|
||||||
|
sms_ERROR "$PHONE" "Votre portefeuille comporte des virements non réglés... FERMETURE IMPOSSIBLE!"
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
log "__SUB:sms_DESTROY.sh: VIREMENT $next OK "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialise PHONE, PIN, PUBKEY, UNIT ...
|
||||||
|
sms_INIT_ACCOUNT "$PHONE"
|
||||||
|
if [[ "$MEMBERUID" == "DON" || "$MEMBERUID" == "" || "$MEMBERUID" == "$MEMBER" ]]; then
|
||||||
|
# OK THAT GUYS KNOWS something (TODO Secure better with double authentification, with email or second phone number...)
|
||||||
|
# IF no Dest PubKey (no member) or DON, then MASTERPUB is collecting LOVE money.
|
||||||
|
if [[ $MEMRIB == "" || "$MEMBERUID" == "DON" ]]; then MEMBER=$ADMINPSEUDO; MEMRIB=$MASTERPUB; fi
|
||||||
|
|
||||||
|
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)
|
||||||
|
sleep 5
|
||||||
|
back=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$LIMIT" --output="$NODEG1PUB" --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
|
||||||
|
if [[ "$PHONE" != "" ]]; then
|
||||||
|
rm -Rf ./wallets/$PHONE;
|
||||||
|
rm -Rf ./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" "$NODEG1PUB" "$cents"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
log "__SUB:sms_DESTROY.sh: WALLET DESTROYED : $PHONE / $UIDNA / $MEMBER : OK"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
new=$(./shell/checknodes.sh "BAN")
|
||||||
|
sms_ERROR "$PHONE" "Problème de payement avec silkaj (changement de serveur $new): $PAY";
|
||||||
|
log "__SUB:sms_DESTROY.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
mess="[G1sms+] $PAY
|
||||||
|
Portefeuille détruit!
|
||||||
|
Viré vers $MEMBER
|
||||||
|
$MEMRIB
|
||||||
|
|
||||||
|
Merci, à bientôt.
|
||||||
|
$ADMINPSEUDO @ $NODEUIDNA
|
||||||
|
$back"
|
||||||
|
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
|
||||||
|
log "__SUB:sms_DESTROY.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
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)
|
||||||
|
|
||||||
|
# Initialise PHONE, PIN, PUBKEY, UNIT ...
|
||||||
|
sms_INIT_ACCOUNT "$phone" "NOSMS"
|
||||||
|
if [[ $UNKNOWN == "unknown" || "$MEMBER" == "" ]]; then
|
||||||
|
sms_ERROR "$phone" "Porte-monnaie non identifié.
|
||||||
|
Envoyez N suivi de votre pseudo membre (en respectant Majuscule et minuscule)."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$mail" != "" ]]; then
|
||||||
|
echo "$mail" > "$MAILFILE"
|
||||||
|
log "__SUB:sms_EMAIL.sh.sh: EMAIL $MEMBER ($PHONE) NOUVEAU: $mail... Publishing to IPFS"
|
||||||
|
ipfs_node_wallets_add
|
||||||
|
else
|
||||||
|
mail=$MAIL
|
||||||
|
fi
|
||||||
|
|
||||||
|
# SEND EMAIL WITH ssmtp
|
||||||
|
SUBJECT="[G1sms+] $MEMBER, message de votre portefeuille monnaie libre $UIDNA ($PHONE)"
|
||||||
|
MESSAGE="Bonjour $MEMBER\n\nLe detenteur du porte-monnaie G1sms $UIDNA ($PHONE) a choisi votre email comme contact.\nVous y recevrez nos prochains envois ...\n\n\nA bientot <3\n$ADMINPSEUDO - ($MASTERPHONE) Partenaire G1sms+"
|
||||||
|
cat ./email.txt | sed s/EMAIL/"${mail}"/g | sed s/SUBJECT/"${SUBJECT}"/g | sed s/MESSAGE/"${MESSAGE}"/g | ssmtp ${mail}
|
||||||
|
log "__SUB:sms_EMAIL.sh.sh: Send welcome EMAIL to $mail via ssmtp"
|
||||||
|
log_history $PHONE "EMAIL, $mail"
|
||||||
|
|
||||||
|
mess="[G1sms+]
|
||||||
|
$MEMBER
|
||||||
|
Votre email est : $mail
|
||||||
|
Mettez le à jour, quand cela est nécessaire..."
|
||||||
|
|
||||||
|
sms_SEND "$phone" "$mess"
|
||||||
|
|
||||||
|
|
||||||
|
log "END sms_EMAIL.sh"
|
||||||
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "X sms_ERROR.sh ($1=phone, $2=message)"
|
||||||
|
|
||||||
|
MESS="Commande inconnue $2."
|
||||||
|
|
||||||
|
# Send response SMS
|
||||||
|
$(sms_ERROR "$1" "$MESS")
|
||||||
|
|
||||||
|
exit
|
|
@ -0,0 +1,278 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
###########################################################################################
|
||||||
|
# == G1tag ==
|
||||||
|
# IPFS ZEN WALLETS
|
||||||
|
# RJ: READ G1Tag
|
||||||
|
# BJ: WRITE G1Tag
|
||||||
|
# WRITE ACCESS ONLY for B possessor and NODE G1Tag Creator
|
||||||
|
# TODO: MAKE http API for G1Tag accessible through local ipfs gateway !!!!
|
||||||
|
# TAG 250 => Imprime un G1Tag rempli de 250 UNIT
|
||||||
|
# TAG 2 100 => Imprime 100 G1Tag BON de 2 UNIT
|
||||||
|
# PHONE any ./wallets/IDs
|
||||||
|
###########################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "__SUB:sms_G1TAG.sh: START ($1=PHONE, $2=AMOUNT, $3=NUMBER)"
|
||||||
|
|
||||||
|
PHONE=$1
|
||||||
|
AMOUNT=$2
|
||||||
|
if [[ "$AMOUNT" == "" ]]; then AMOUNT=0; fi
|
||||||
|
NUMBER=$3
|
||||||
|
# DEFAULT TYPE IS PRINTED G1TAG
|
||||||
|
# BUT COULD BE USED TO CARRY VALUE INTO IPFS STORED FILES
|
||||||
|
# FIRST ATTEMPT IS TO COPY YOUTUBE INTO M4A AND LEND THEM G1.
|
||||||
|
TYPE=$4 # This is the type of passenger: YOUTUBE, NODE (EMPTY = default means sticker printed G1Tag)
|
||||||
|
# Give ipfs hash of any External ID like YOUTUBEID ;)
|
||||||
|
PASSENGER=$5
|
||||||
|
|
||||||
|
# == G1tag ==
|
||||||
|
# IPFS G1sms Wallet to TAG creation/relation manager
|
||||||
|
# TODO Modulate access to TAGs with IPNS publish key cypher
|
||||||
|
# A/R: (G1TagID)
|
||||||
|
# B: (GPG Key for HUMAN WRITE access)
|
||||||
|
# J: (IPNS link to G1tag storage)
|
||||||
|
# MASTER: Global SWARM Access
|
||||||
|
###############################################################################################
|
||||||
|
# Initialize PHONE, PIN, PUBKEY, UNIT, MEMBER, MEMRIB, EMAIL, etc...
|
||||||
|
sms_INIT_ACCOUNT "$PHONE" "NOSMS"
|
||||||
|
|
||||||
|
if [[ $UNKNOWN == "unknown" ]]; then
|
||||||
|
sms_ERROR "$PHONE" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer."
|
||||||
|
log "__SUB:sms_G1TAG.sh: Porte-monnaie inconnu"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
## NEEDED FOR Avatar + GeoPoint
|
||||||
|
if [[ ! $PASSENGER && "$MEMBER" == "" ]]; then
|
||||||
|
sms_ERROR "$PHONE" "Aucun membre associé à votre Portefeuille!? Envoyer N suivi de votre Pseudo membre pour activer la création de G1Tag..."
|
||||||
|
log "__SUB:sms_G1TAG.sh: Aucun membre associé"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# CALCULATE if wallet have enough for VIR+PERCENT
|
||||||
|
AMOUNT=$2 # AMOUNT was changed by sms_INIT_ACCOUNT call !!
|
||||||
|
if [[ "$AMOUNT" == "" ]]; then AMOUNT=0; fi
|
||||||
|
if [[ ! $PASSENGER && "$NUMBER" != "" ]]; then
|
||||||
|
# MULTI TAG NUMBER ($NUMBER = How many tags to print (with different R but same B)
|
||||||
|
AMOUNT=$(bc -l <<< "$AMOUNT * $NUMBER")
|
||||||
|
else
|
||||||
|
NUMBER=1
|
||||||
|
fi
|
||||||
|
VIR=0
|
||||||
|
accounting=($(make_accounting))
|
||||||
|
log "__SUB:sms_G1TAG.sh: $(declare -p accounting)"
|
||||||
|
testmin=${accounting[0]}
|
||||||
|
VIR=${accounting[1]}
|
||||||
|
PERCENT=${accounting[2]}
|
||||||
|
CHARGE=${accounting[3]}
|
||||||
|
if [[ $testmin -eq 0 ]]; then
|
||||||
|
sms_SEND "$PHONE" "Le solde de votre Porte-monnaie est insuffisant. Minimum requis = ${CHARGE} G1! Rechargez avec https://cesium.app "
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
##### IS G1DAB NODE?
|
||||||
|
if [[ ! $PASSENGER && ! $G1DAB ]]; then
|
||||||
|
if [[ -f ./wallets/$PHONE/ipfsid.G1TAGNODE ]]; then
|
||||||
|
DABnode=$(cat ./wallets/$PHONE/ipfsid.G1TAGNODE)
|
||||||
|
if [[ "$DABnode" == "$IPFSNODEID" ]]; then
|
||||||
|
sms_ERROR "$PHONE" "IMPRIMANTE G1Tag non détectée!! Choisissez un autre NODE G1Dab... $spot"
|
||||||
|
log "__SUB:sms_G1TAG.sh: IMPRIMANTE G1Tag non détectée!!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: SEARCH PROXIMITY DAB LOCATION (GeoPoint + GPS)...
|
||||||
|
# for node in ./wallets_swarm/.*/*.where; do
|
||||||
|
# done
|
||||||
|
###########################################################
|
||||||
|
# silkaj NODE CHANGE !!!
|
||||||
|
#SILKAJNODE=$(./shell/checknodes.sh)
|
||||||
|
#log "NEW SILKAJ NODE: $SILKAJNODE"
|
||||||
|
|
||||||
|
###########################################
|
||||||
|
# PAY VIR + PERCENT G1
|
||||||
|
ML=$(bc -l <<< "scale=2; $VIR + $PERCENT")
|
||||||
|
PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$ML" --output="$MASTERPUB" --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";
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
cents=$(echo $(bc -l <<< "scale=0; $ML * 100") | cut -d '.' -f 1)
|
||||||
|
move_g1cents "$PHONE" "$MASTERPUB" "$cents"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
log "__SUB:sms_G1TAG.sh: CREATE $NUMBER x $2 $UNIT G1Tag(s) for $MEMBER ($PHONE) : PAYEMENT $ML G1 to $MASTERPUB: $PAY"
|
||||||
|
c=0
|
||||||
|
while [[ $c -lt $NUMBER ]]; do
|
||||||
|
((c++))
|
||||||
|
# Create Unique SWARM G1tag!
|
||||||
|
AA=$(./shell/diceware.sh 6 | xargs); RR=$(echo ${AA} | sed s/\ //g );
|
||||||
|
while [ -d "./wallets_swarm/TAG/${RR}" ]; do
|
||||||
|
AA=$(./shell/diceware.sh 6 | xargs);
|
||||||
|
RR=$(echo ${AA} | sed s/\ //g );
|
||||||
|
done
|
||||||
|
BB=$(date +%N | sha256sum | base64 | head -c 32) #YjY4MDc3OTVjNmUxN2JhYWVjYmU3MDcy
|
||||||
|
# BB=$(openssl rand -base64 32 | base64) #Yk8yMnVtdzZmendJbHNoK2Q0b0liakRpNHNJUk9UQW5Dd042cFdDODlJTT0K
|
||||||
|
|
||||||
|
# G1Tag init
|
||||||
|
# TODO CHECK _nanodate to detect bad nodes/tx behaviour... and banish them)
|
||||||
|
TAGDATE="./TAG/${RR}/TAG_nanodate" # Nanodate notification (ntpdate in init.sh for NODE sync in case of
|
||||||
|
TAGNID="./TAG/${RR}/TAG_nodeid" # G1sms+ NODE IPFS ID managing that G1Tag
|
||||||
|
TAGID="./TAG/${RR}/TAG_id" #Nom du TAG
|
||||||
|
TAGN="./TAG/${RR}/TAG_n" # Tag modification number (0 first)
|
||||||
|
TAGCURRENCY="./TAG/${RR}/TAG_currency" # ZEN (0.01 G1)
|
||||||
|
TAGAMOUNT="./TAG/${RR}/TAG_amount" # Tag amount. It is!
|
||||||
|
TAGTYPE="./TAG/${RR}/TAG_type" # G1 Tag type
|
||||||
|
TAGPASSENGER="./TAG/${RR}/TAG_passenger" # Reference to G1Tag owner/counter put in "./wallets/.$IPFSNODEID/TAG/${J}"
|
||||||
|
# ... GESTION DE LA CLEF DE PUBLICATION IPNS ".ipfs/keystore/${RR}" ...
|
||||||
|
TAGBKEY="./TAG/${RR}/TAG_publishkey.B.gpg" # ipns publish key B cyphered
|
||||||
|
TAGG1smsWKEY="./TAG/${RR}/TAG_publishkey.$PHONE.crypt" # natools.py crypt with creator G1sms Wallet PUBKEY
|
||||||
|
TAGSWARMKEY="./TAG/${RR}/TAG_publishkey.MASTER.crypt" # natools.py crypt with creator G1sms Wallet PUBKEY
|
||||||
|
TAGIPNS="./TAG/${RR}/TAG_ipns" # /ipns/Qm... link to last G1Tag version
|
||||||
|
TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
|
||||||
|
|
||||||
|
# WRITE MULTITAG FILES with AMOUNT
|
||||||
|
mkdir -p ./TAG/${RR}
|
||||||
|
LIST="$LIST $RR ($2)"
|
||||||
|
log "__SUB:sms_G1TAG.sh: G1tag: $RR / ${NANODATE}"
|
||||||
|
log "__SUB:sms_G1TAG.sh: MEMRIB: $MEMRIB"
|
||||||
|
log "__SUB:sms_G1TAG.sh: A: ${AA}"
|
||||||
|
log "__SUB:sms_G1TAG.sh: B: ${BB}"
|
||||||
|
####################
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
# IPFS files are created and calculated immutable I
|
||||||
|
####################################################
|
||||||
|
# A or R is the Human readable G1tag ID (kind of TAG pubkey)
|
||||||
|
echo "${AA}" > "$TAGID"
|
||||||
|
echo "0" > "$TAGN"
|
||||||
|
echo "${NANODATE}" > "$TAGDATE"
|
||||||
|
echo "${IPFSNODEID}" > "$TAGNID"
|
||||||
|
echo "${TYPE}" > "$TAGTYPE"
|
||||||
|
|
||||||
|
echo "ZEN" > "$TAGCURRENCY"
|
||||||
|
ZEN=$(bc -l <<< "$2 * 100") # TODO, Test. Unit != G1 may lead to miss calculation BUG??
|
||||||
|
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
|
||||||
|
su $YOU -c "ipfs key gen -t rsa -s 2048 ${RR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: Regulate G1Tag Access to LostSecret OR PHONE ./wallets Pubkey OR SWARM G1 KEY
|
||||||
|
# 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 "$TAGBKEY" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "/home/$YOU/.ipfs/keystore/${RR}"
|
||||||
|
# GIVE CREATOR G1WALLET ACCESS TO ZEN TAG
|
||||||
|
# Enregistrement de la clef de publication chiffrée par $PUBKEY la clef publique du portefeuille G1 createur.
|
||||||
|
./shell/natools.py encrypt -p $PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGG1smsWKEY"
|
||||||
|
# GIVE SWARM ACCESS TO ZEN TAG
|
||||||
|
./shell/natools.py encrypt -p $MASTERPUB -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGSWARMKEY"
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# TAG IPFS STORAGE & G1Tag IPNS PUBLISHING
|
||||||
|
###########################################################
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
||||||
|
# MEMORIZE FOR CHAINING FUTURE CHANGES ( Block0 TAG version has no file published ;)
|
||||||
|
echo "${I}" > "$TAGCHAIN"
|
||||||
|
# Activate chain
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
||||||
|
# IPFS Hash for Immutable G1tag data
|
||||||
|
J=$(su $YOU -c "ipfs name publish -k ${RR} --quieter /ipfs/${I}")
|
||||||
|
echo "${J}" > "$TAGIPNS"
|
||||||
|
|
||||||
|
# KEEP G1Tag J MEMORY in NODE ./wallets/.$IPFSNODEID/TAG/ (TODO: OPTIMIZE SWARM SYNC and REPUBLISH)
|
||||||
|
mkdir -p "./wallets/.$IPFSNODEID/TAG/"
|
||||||
|
# WRITE PASSENGER to J Link (G1Tag is stick to it: PHONE, NODE, FILE )
|
||||||
|
echo "$PHONE" > "./wallets/.$IPFSNODEID/TAG/${J}"
|
||||||
|
if [[ $PASSENGER ]]; then
|
||||||
|
echo "$PASSENGER" > "./wallets/.$IPFSNODEID/TAG/${J}";
|
||||||
|
fi
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
log "__SUB:sms_G1TAG.sh: TAG: ipfs ls /ipns/$(cat $TAGIPNS)"
|
||||||
|
if [[ ! $PASSENGER ]]; then
|
||||||
|
# QR CODE LECTURE
|
||||||
|
qrencode -s 5 -o "./TAG/${RR}/TAG_READ.png" "RJ:${RR}#${J}"
|
||||||
|
log "__SUB:sms_G1TAG.sh: CREATE READ QRCODE -> RJ: ${RR} # ipfs ls /ipns/${J}"
|
||||||
|
|
||||||
|
# QR CODE ECRITURE
|
||||||
|
qrencode -s 5 -o "./TAG/${RR}/TAG_WRITE.png" "BJ:${BB}#${J}"
|
||||||
|
log "__SUB:sms_G1TAG.sh: CREATE WRITE QRCODE [] BJ: ${BB} # ipfs ls /ipns/${J}"
|
||||||
|
|
||||||
|
# COMPOSE G1TAG PRINT + TAG_READ.png + TAG_WRITE.png
|
||||||
|
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"
|
||||||
|
else
|
||||||
|
composite -compose Over -resize 100% -gravity Center "./shell/Portefeuille.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# WRITE G1Tag G1 amount
|
||||||
|
convert -pointsize 150 -fill black -gravity Center -draw 'text 240,-140 "'"$2"'"' "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
|
||||||
|
# WRITE G1Tag RR
|
||||||
|
convert -pointsize 40 -fill black -gravity SouthWest -draw 'text 0,0 "'"${RR}"'"' "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
|
||||||
|
|
||||||
|
# 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 [[ "$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 MASTERPUB ?
|
||||||
|
log "__SUB:sms_G1TAG.sh: Remote PRINT :: ./wallets/.$destnode/PRINT/${RR}.bin "
|
||||||
|
mkdir -p "./wallets/.$destnode/PRINT/"
|
||||||
|
./shell/natools.py encrypt -p $MASTERPUB -i "./TAG/${RR}/${RR}.png" -o "./wallets/.$destnode/PRINT/${RR}.bin"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
#
|
||||||
|
log "__SUB:sms_G1TAG.sh: Becoming default PRINTER :: $IPFSNODEID"
|
||||||
|
echo "$IPFSNODEID" > "./wallets/$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"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then
|
||||||
|
# PRINT $PHONE WALLET PUBKEY
|
||||||
|
qrencode -s 5 -o "/tmp/G1PubQR.$PHONE.png" "$(cat ./wallets/$PHONE/$PHONE.pub)"
|
||||||
|
composite -compose Over -resize 133% -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 -resize 150% -gravity Center "./wallets/$PHONE/$PHONE.avatar.png" "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
|
||||||
|
fi
|
||||||
|
convert -pointsize 60 -fill black -gravity Center -draw 'text 320,-160 "'"$MEMBER"'"' "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
|
||||||
|
convert -pointsize 70 -fill black -gravity Center -draw 'text 345, 0 "'"$UIDNA"'"' "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
|
||||||
|
convert -pointsize 60 -fill black -gravity Center -draw 'text 330,160 "'"$PHONE"'"' "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
|
||||||
|
brother_ql_create --model QL-700 "/tmp/G1PubQR.$PHONE.png" --label-size 62 > "/tmp/G1PubQR.$PHONE.bin"
|
||||||
|
brother_ql_print "/tmp/G1PubQR.$PHONE.bin" /dev/usb/lp0
|
||||||
|
rm -f /tmp/G1PubQR.*
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Send dest SMS
|
||||||
|
mess_dest="[G1sms+]
|
||||||
|
Vos $NUMBER G1Tag(s) de $2 $UNIT sont imprimé(s).
|
||||||
|
Veuillez les récupérer ici:
|
||||||
|
$ADRESSE
|
||||||
|
Merci"
|
||||||
|
sms_SEND "$PHONE" "$mess_dest"
|
||||||
|
|
||||||
|
ipfs_node_wallets_add
|
||||||
|
|
||||||
|
log "__SUB:sms_G1TAG.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "X sms_NEW.sh ($1=phone, $2=uid)"
|
||||||
|
|
||||||
|
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
|
||||||
|
MEMRIB=$(sms_uid2key "$MEMBERUID" "$PHONE" "$PIN")
|
||||||
|
if [[ $MEMRIB == "" ]]; then exit; fi
|
||||||
|
MEMBER="$MEMBERUID"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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+]
|
||||||
|
Id: $UIDNA
|
||||||
|
Solde: $AMOUNT $UNIT
|
||||||
|
DAB: $DABID
|
||||||
|
---
|
||||||
|
https://cesium.app
|
||||||
|
* Identifiant ="
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
sleep 2
|
||||||
|
sms_SEND "$PHONE" "$PHONE"
|
||||||
|
sleep 2
|
||||||
|
sms_SEND "$PHONE" "* Mot de passe ="
|
||||||
|
sleep 2
|
||||||
|
sms_SEND "$PHONE" "$PIN"
|
||||||
|
sleep 2
|
||||||
|
sms_SEND "$PHONE" "* Clef Publique (RIB) ="
|
||||||
|
sleep 2
|
||||||
|
sms_SEND "$PHONE" "$PUBKEY"
|
||||||
|
sleep 2
|
||||||
|
sms_SEND "$PHONE" "Compte relié? $MEMBER $MAIL
|
||||||
|
$MEMRIB"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
log "END sms_NEW.sh"
|
||||||
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
|
@ -0,0 +1,98 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "__SUB:sms_PAY.sh: START ($1=PHONE, $2=PHONEDEST, $3=AMOUNT)"
|
||||||
|
|
||||||
|
phone="$1"
|
||||||
|
PHONEDEST="$2"
|
||||||
|
|
||||||
|
# Initialise PHONE, PIN, PUBKEY, UNIT
|
||||||
|
sms_INIT_ACCOUNT "$phone" "NOSMS"
|
||||||
|
pin=$PIN
|
||||||
|
if [[ $UNKNOWN == "unknown" ]]; then
|
||||||
|
sms_ERROR "$phone" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# CALCULATE if wallet have enough for VIR+PERCENT
|
||||||
|
AMOUNT="$3"
|
||||||
|
accounting=($(make_accounting))
|
||||||
|
log "__SUB:sms_PAY.sh: $(declare -p accounting)"
|
||||||
|
testmin=${accounting[0]}
|
||||||
|
VIR=${accounting[1]}
|
||||||
|
PERCENT=${accounting[2]}
|
||||||
|
if [[ $testmin -eq 0 ]]; then
|
||||||
|
sms_ERROR "$phone" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum: $((VIR+PERCENT+LIMIT)) G1! Rechargez avec https://Cesium.app"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add COUNTRY code to PHONEDEST + PHONEDEST INIT
|
||||||
|
PHONEDEST="$COUNTRY${PHONEDEST:1:10}"
|
||||||
|
|
||||||
|
# CHECK if PHONEDEST have an account in IPFS G1sms+ SWARM
|
||||||
|
if [[ -f "./wallets_swarm/$PHONEDEST/$PHONEDEST.pub" ]]
|
||||||
|
then
|
||||||
|
PUBKEYDEST=$(cat "./wallets_swarm/$PHONEDEST/$PHONEDEST.pub")
|
||||||
|
UNITDEST=$(cat "./wallets_swarm/$PHONEDEST/$PHONEDEST.unit")
|
||||||
|
else
|
||||||
|
# NO, then create NEW Wallet
|
||||||
|
sms_INIT_ACCOUNT "$PHONEDEST"
|
||||||
|
# Refreshed new values
|
||||||
|
PUBKEYDEST="$PUBKEY"
|
||||||
|
UNITDEST="$UNIT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Payement
|
||||||
|
PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST" --comment="[G1sms+] PAY $AMOUNT $UNIT" -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";
|
||||||
|
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
|
||||||
|
|
||||||
|
# + G1SMS Commission
|
||||||
|
COM=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$PERCENT" --output="$MASTERPUB" --comment="[G1sms+] Commission" -y)
|
||||||
|
if [[ "$(echo $COM | 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): $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" "$MASTERPUB" "$cents"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# LOG ACCOUNT HISTORY EVENTS
|
||||||
|
log "__SUB:sms_PAY.sh: $1 => $2 = $3 $UNIT / SILKAJ == TxPay $PAY + TxCom $COM /"
|
||||||
|
log_history $phone "PAY, $VIR, $PHONEDEST, $PUBKEYDEST"
|
||||||
|
|
||||||
|
# Send response SMS
|
||||||
|
mess_src="[G1sms+]
|
||||||
|
Envoi de $VIR G1 vers $PHONEDEST effectué!
|
||||||
|
+ Commission: $PERCENT G1"
|
||||||
|
sms_SEND "$phone" "$mess_src"
|
||||||
|
|
||||||
|
# Send dest SMS
|
||||||
|
mess_dest="[G1sms+] Bonjour.
|
||||||
|
Un(e) ami(e) ($phone) vient de vous envoyer $VIR G1 sur votre portefeuille G1sms!
|
||||||
|
Envoyez D pour (D)étail.
|
||||||
|
A pour (A)ide..."
|
||||||
|
sms_SEND "$PHONEDEST" "$mess_dest"
|
||||||
|
|
||||||
|
|
||||||
|
log "__SUB:sms_PAY.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~ "
|
||||||
|
exit
|
|
@ -0,0 +1,168 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
# RECORD RECURRENT PAYEMENTS WITH "Cesium+ ID" Pubkey TODO cron ./wallets/$PHONE/VIREMENTS, Fusion avec sms_VIR.sh
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "__SUB:sms_REC.sh: START ($1=PHONE, $2=VIRDEST, $3=AMOUNT, $4=PERIOD, $5=TIME)"
|
||||||
|
|
||||||
|
PHONE="$1"
|
||||||
|
VIRDEST="$2"
|
||||||
|
AMOUNT=$3
|
||||||
|
PERIOD="$4"
|
||||||
|
TIME=$5
|
||||||
|
|
||||||
|
case "$PERIOD" in
|
||||||
|
J|D)
|
||||||
|
PERIOD="jour";
|
||||||
|
NEXTDATE="days";
|
||||||
|
;;
|
||||||
|
S|W)
|
||||||
|
PERIOD="semaine";
|
||||||
|
NEXTDATE="weeks";
|
||||||
|
;;
|
||||||
|
M)
|
||||||
|
PERIOD="mois";
|
||||||
|
NEXTDATE="months";
|
||||||
|
;;
|
||||||
|
A|Y)
|
||||||
|
PERIOD="année";
|
||||||
|
NEXTDATE="years";
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
sms_ERROR "$PHONE" "Erreur sur la période de votre virement! Jour, Semaine, Mois, Année? Valeur: J,S,M,A (ex: REC 10 Fred J 3)"
|
||||||
|
exit;
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# Initialise PHONE, PIN, PUBKEY, UNIT
|
||||||
|
sms_INIT_ACCOUNT "$PHONE" "NOSMS"
|
||||||
|
if [[ $MEMBER == "" ]]; then MEMBER=$UIDNA; fi
|
||||||
|
###########################################################
|
||||||
|
# CHECK FOR ERRORS
|
||||||
|
if [[ $UNKNOWN == "unknown" ]]; then
|
||||||
|
sms_ERROR "$PHONE" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
if [[ "$MEMBER" == "" ]]; then
|
||||||
|
sms_ERROR "$PHONE" "Aucun membre associé à votre Portefeuille!? Envoyer N suivi de votre Pseudo membre pour activer les virements récurrents..."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# CALCULATE if wallet have enough for VIR+PERCENT
|
||||||
|
AMOUNT=$(bc -l <<< "$3 * $TIME")
|
||||||
|
accounting=($(make_accounting))
|
||||||
|
log "__SUB:sms_REC.sh: $(declare -p accounting)"
|
||||||
|
testmin=${accounting[0]}
|
||||||
|
VIR=$(bc -l <<< "scale=2; ${accounting[1]} / $TIME")
|
||||||
|
PERCENT=${accounting[2]}
|
||||||
|
CHARGE=${accounting[3]}
|
||||||
|
if [[ $testmin -eq 0 ]]; then
|
||||||
|
sms_ERROR "$PHONE" "Votre Porte-monnaie G1sms doit comporter un solde suffisant! Au minimum $CHARGE G1! Rechargez par Cesium (ou contactez https://g1sms.fr)."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# TODO Unify REC and VIR
|
||||||
|
# FIND VIRDEST into wallets, wallest-swarm OR duniter (silkaj)
|
||||||
|
if [[ "$VIRDEST" == "" || "$VIRDEST" == "$MEMBER" ]]; then
|
||||||
|
# VIR TO MEMBER PHONE OWNER
|
||||||
|
DESTMEM="$MEMBER"
|
||||||
|
DESTRIB="$MEMRIB"
|
||||||
|
log "__SUB:sms_REC.sh: SEND TO MEMBER related wallet!!! $DESTRIB "
|
||||||
|
else
|
||||||
|
log "__SUB:sms_REC.sh: SEARCH $VIRDEST related wallet!!! $DESTRIB "
|
||||||
|
DESTMEM="$VIRDEST"
|
||||||
|
# SEARCH IN WALLETS
|
||||||
|
LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna* | tail -n 1 | cut -f 3 -d '/')
|
||||||
|
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)"
|
||||||
|
else
|
||||||
|
# SEARCH IN WALLETS SWARM
|
||||||
|
SWARMNB=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna* | tail -n 1 | cut -f 3 -d '/')
|
||||||
|
if [[ "$LOCAL" != "" ]]; then
|
||||||
|
REMOTENODE=$(cat ./wallets_swarm/$SWARMNB/MASTERPHONE.sms)
|
||||||
|
DESTRIB=$(cat ./wallets_swarm/$SWARMNB/$SWARMNB.pub)
|
||||||
|
DESTPHONE=$SWARMNB
|
||||||
|
log "__SUB:sms_REC.sh: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($SWARMNB)"
|
||||||
|
else
|
||||||
|
# SEARCH WITH SILKAJ
|
||||||
|
DESTRIB=$(./silkaj/silkaj id "$DESTMEM" | grep -w "$DESTMEM" | awk '{print $2}')
|
||||||
|
log "__SUB:sms_REC.sh: OUT OFF SWARM MEMBER wallet: $DESTRIB"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
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)
|
||||||
|
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";
|
||||||
|
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 ./wallets/$PHONE/VIREMENTS with FUTURE PAYEMENTS? $PAY"
|
||||||
|
|
||||||
|
########### MAKE ./wallets/$PHONE/VIREMENTS for NEXT ONES
|
||||||
|
if [[ -f "./wallets/$PHONE/VIREMENTS.gpg" ]]; then
|
||||||
|
# DECYPHER FILE FOR CHANGE
|
||||||
|
echo "${GPGPASS}" | gpg -d -q --output "./wallets/$PHONE/VIREMENTS" --yes --pinentry-mode loopback --passphrase-fd 0 "./wallets/$PHONE/VIREMENTS.gpg"
|
||||||
|
fi
|
||||||
|
# WRITE NEW LINES INTO AN ARRAY FILE: VIREMENTS
|
||||||
|
boucle=$((TIME - 1))
|
||||||
|
num=0
|
||||||
|
while [[ boucle -gt 0 ]]; do
|
||||||
|
$((boucle --))
|
||||||
|
$((num ++))
|
||||||
|
NEXT=$(date --date="$num $NEXTDATE" '+%Y%m%d')
|
||||||
|
# ADD NEW LINE IN VIREMENTS
|
||||||
|
echo "$NEXT $MEMBER $PHONE $VIR $DESTRIB $DESTMEM $MEMBER#$TIME#$AMOUNT#$DESTMEM $boucle " >> ./wallets/$PHONE/VIREMENTS
|
||||||
|
|
||||||
|
done
|
||||||
|
# CYPHER FILE
|
||||||
|
echo "${GPGPASS}" | gpg -q --output "./wallets/$PHONE/VIREMENTS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./wallets/$PHONE/VIREMENTS"
|
||||||
|
# EMPTY CLEAR FILE
|
||||||
|
log "__SUB:sms_REC.sh: $(cat ./wallets/$PHONE/VIREMENTS)"
|
||||||
|
echo "" > ./wallets/$PHONE/VIREMENTS
|
||||||
|
###########
|
||||||
|
|
||||||
|
log "__SUB:sms_REC.sh: .....................................OK!!!"
|
||||||
|
|
||||||
|
# SEND ACK SMS
|
||||||
|
log "__SUB:sms_REC.sh: VIREMENTS RECURRENTS $MEMBER#$TIME#$AMOUNT#$DESTMEM => $VIR G1 pour $DESTMEM (pendant $TIME $PERIOD) + AJOUT"
|
||||||
|
mess="[G1sms+]
|
||||||
|
Virement de $VIR G1 pour $DESTMEM (pendant $TIME $PERIOD)
|
||||||
|
Total: $AMOUNT $UNIT
|
||||||
|
|
||||||
|
$MEMBER#$TIME#$AMOUNT#$DESTMEM
|
||||||
|
$DESTRIB"
|
||||||
|
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
|
||||||
|
log_history "$PHONE" "REC, $VIR, $DESTRIB, $DESTMEM, $PERIOD, $TIME"
|
||||||
|
# Send DESTPHONE sms
|
||||||
|
if [[ "$DESTPHONE" != "" ]]; then
|
||||||
|
sms_SEND "$DESTPHONE" "[G1sms+] Bonjour $DESTMEM. Vous recev(r)ez un payement de $VIR G1 (pendant $TIME $PERIOD) de la part du portefeuille: $MEMBER."
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
log "__SUB:sms_REC.sh: ERROR $MEMBER: $DESTMEM DESTRIB NOT FOUND"
|
||||||
|
mess="[G1sms+] Virement annulé...
|
||||||
|
Destinataire: $DESTMEM inconnu! Vérifiez son existence."
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "__SUB:sms_REC.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "X sms_SETUNIT.sh ($1=phone, $2=unit)"
|
||||||
|
|
||||||
|
phone="$1"
|
||||||
|
unit="$2"
|
||||||
|
UNITFILE="./wallets/$phone/$phone.unit"
|
||||||
|
|
||||||
|
# Initialise PHONE, PIN, PUBKEY, UNIT, HIST
|
||||||
|
sms_INIT_ACCOUNT "$phone" "NOSMS"
|
||||||
|
|
||||||
|
if [[ $UNKNOWN == "unknown" ]]; then
|
||||||
|
sms_ERROR "$phone" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# No unit received
|
||||||
|
if [[ $unit == "U" || $unit == "" ]]; then
|
||||||
|
if [[ -f "$UNITFILE" ]]; then
|
||||||
|
unit=$(cat "$UNITFILE")
|
||||||
|
else
|
||||||
|
unit="$COIN";
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$unit" > "$UNITFILE"
|
||||||
|
log "G1sms wallet new $unit... IPFS SWARM publishing..."
|
||||||
|
ipfs_node_wallets_add
|
||||||
|
|
||||||
|
mess="[G1sms+]
|
||||||
|
Unité de votre portefeuille: $unit"
|
||||||
|
|
||||||
|
sms_SEND "$phone" "$mess"
|
||||||
|
|
||||||
|
log "END sms_SETUNIT.sh"
|
||||||
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
|
||||||
|
exit
|
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "__SUB:sms_VIR.sh: START ($1=phone, $2=AMOUNT, $3=VIRDEST)"
|
||||||
|
|
||||||
|
phone="$1"
|
||||||
|
AMOUNT="$2"
|
||||||
|
VIRDEST="$3"
|
||||||
|
|
||||||
|
# Initialise PHONE, PIN, PUBKEY, UNIT
|
||||||
|
sms_INIT_ACCOUNT "$phone" "NOSMS"
|
||||||
|
if [[ $MEMBER == "" ]]; then MEMBER=$UIDNA; fi
|
||||||
|
member=$MEMBER
|
||||||
|
if [[ "$AMOUNT" == "" ]]; then
|
||||||
|
sms_ERROR "$phone" "Montant incorrect!!
|
||||||
|
Ex:
|
||||||
|
VIR 100, pour virer 100 $UNIT vers votre compte relié.
|
||||||
|
VIR 100 $ADMINPSEUDO, pour virer 100 $UNIT au membre administrateur de ce NODE G1sms+ ;)"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# CALCULATE if wallet have enough for VIR+PERCENT
|
||||||
|
AMOUNT="$2"
|
||||||
|
accounting=($(make_accounting))
|
||||||
|
log "__SUB:sms_VIR.sh: $(declare -p accounting)"
|
||||||
|
testmin=${accounting[0]}
|
||||||
|
VIR=${accounting[1]}
|
||||||
|
PERCENT=${accounting[2]}
|
||||||
|
if [[ $testmin -eq 0 ]]; then
|
||||||
|
sms_ERROR "$PHONE" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum $charge G1! Rechargez par Cesium."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# FIND VIRDEST into wallets, wallest-swarm OR duniter (silkaj)
|
||||||
|
if [[ "$VIRDEST" == "" || "$VIRDEST" == "$MEMBER" ]]; then
|
||||||
|
# VIR TO MEMBER PHONE OWNER
|
||||||
|
DESTMEM="$MEMBER"
|
||||||
|
DESTRIB="$MEMRIB"
|
||||||
|
log "__SUB:sms_VIR.sh: SEND TO MEMBER related wallet!!! $DESTRIB "
|
||||||
|
else
|
||||||
|
log "__SUB:sms_VIR.sh: SEARCH $VIRDEST related wallet!!! $DESTRIB "
|
||||||
|
DESTMEM="$VIRDEST"
|
||||||
|
# SEARCH IN WALLETS
|
||||||
|
LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna* | tail -n 1 | cut -f 3 -d '/')
|
||||||
|
if [[ "$LOCAL" != "" ]]; then
|
||||||
|
# LOCAL G1sms account
|
||||||
|
DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub)
|
||||||
|
DESTPHONE=$LOCAL
|
||||||
|
log "__SUB:sms_VIR.sh: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)"
|
||||||
|
else
|
||||||
|
# SEARCH IN WALLETS SWARM
|
||||||
|
INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna* | tail -n 1 | cut -f 3 -d '/')
|
||||||
|
if [[ "$INSWARM" != "" ]]; then
|
||||||
|
REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms)
|
||||||
|
DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.pub)
|
||||||
|
DESTPHONE=$INSWARM
|
||||||
|
log "__SUB:sms_VIR.sh: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($INSWARM)"
|
||||||
|
else
|
||||||
|
# SEARCH WITH SILKAJ
|
||||||
|
DESTRIB=$(./silkaj/silkaj id "$DESTMEM" | grep -w "$DESTMEM" | awk '{print $2}')
|
||||||
|
log "__SUB:sms_VIR.sh: OUT OFF SWARM MEMBER wallet: $DESTRIB"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$DESTRIB" != "" ]]; then
|
||||||
|
PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -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
|
||||||
|
Virement de $AMOUNT $UNIT ($VIR G1)
|
||||||
|
vers $DESTMEM ($DESTRIB)
|
||||||
|
OK!
|
||||||
|
$PAY"
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
log_history "$PHONE" "VIR, $VIR, $DESTRIB, $DESTMEM"
|
||||||
|
# Send DESTPHONE sms
|
||||||
|
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 ($phone)"
|
||||||
|
fi
|
||||||
|
cents=$(echo $(bc -l <<< "scale=0; $VIR * 100") | cut -d '.' -f 1)
|
||||||
|
move_g1cents "$PHONE" "$DESTRIB" "$cents"
|
||||||
|
else
|
||||||
|
new=$(./shell/checknodes.sh "BAN")
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! Problème de payement avec silkaj (changement de serveur $new): $PAY";
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "__SUB:sms_VIR.sh: ERROR $MEMBER: $DESTMEM DESTRIB NOT FOUND"
|
||||||
|
mess="[G1sms+] Virement annulé...
|
||||||
|
Membre: $DESTMEM inconnu! Vérifiez son existence."
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "__SUB:sms_VIR.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
|
@ -0,0 +1,56 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# is there ADMINPSEUDO-UIDNATAIL in ./wallets_swarm/.*/*.uidna ?"
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
log "__SUB:sms_WHERE.sh: START ($1=PHONE $2=askeduidna)"
|
||||||
|
|
||||||
|
phone="$1"
|
||||||
|
askeduidna="$2"
|
||||||
|
|
||||||
|
# Initialise PHONE, PIN, PUBKEY, UIDNA, UIDNAFILE ...
|
||||||
|
sms_INIT_ACCOUNT "$phone" "NOSMS"
|
||||||
|
if [[ "$UNKNOWN" == "unknown" ]]; then
|
||||||
|
sms_ERROR "$phone" "Porte-monnaie non identifié!
|
||||||
|
Envoyez N pour créer votre portefeuille G1sms"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$askeduidna" == "" ]]; then #SELF
|
||||||
|
if [[ -f "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna" ]]; then
|
||||||
|
nodeuidnafile="./wallets/.$IPFSNODEID/$IPFSNODEID.uidna"
|
||||||
|
uidna=$(cat $nodeuidnafile)
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
nodeuidnafile=$(grep -Rwl "$askeduidna" ./wallets_swarm/.*/*.uidna)
|
||||||
|
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
|
||||||
|
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 ???"
|
||||||
|
sms_ERROR "$PHONE" "Désolé. Aucun Distributeur de G1Tag : $askeduidna !!!"
|
||||||
|
log "__SUB:sms_WHERE.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
mess="[G1sms+] $MEMBER
|
||||||
|
Votre distributeur de G1Tag par défaut est
|
||||||
|
$uidna ($ipfsnodeid), situé:
|
||||||
|
$(cat ./wallets_swarm/.$ipfsnodeid/$ipfsnodeid.where)"
|
||||||
|
|
||||||
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
|
||||||
|
|
||||||
|
log "__SUB:sms_WHERE.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
exit
|
|
@ -0,0 +1,164 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
###########################################################################################
|
||||||
|
# LOAD MUSIC FILE IN G1TAG... + SHELL OPCODE INJECTED INTO G1TAG
|
||||||
|
# sudo pip3 install duniterpy
|
||||||
|
###########################################################################################
|
||||||
|
# ipfs ls /ipns/QmY6ooFcsGXY4VSindqKMz9GvrprFXY32RrsTmqvVTYQX5
|
||||||
|
# QmZ3RfWk1u5LEGYLHA633B5TNJy3Du27K6Fny9wcxpowGS 4 TAG_amount
|
||||||
|
# QmXizDydPuiBd1V7JBVY5kdppShm9xdk2aoYj7c8V8Foxe 47 TAG_chain
|
||||||
|
# QmeHHBZKtLJHr11rwXKeimwDE4i3nLMy2VPkWZsNaFasg1 4 TAG_currency
|
||||||
|
# QmSjBDpjnoxnQT5RWRnyLxqwE3ovSRVb7xjwZoiufZAv3E 39 TAG_id
|
||||||
|
# QmUQcSjQx2bg4cSe2rUZyQi6F8QtJFJb74fWL7D784UWf9 2 TAG_n
|
||||||
|
# QmdbdBWv4SygqaaeWHAvABiQAa3faf4ncfSyzRnx8BDdCc 20 TAG_nanodate
|
||||||
|
# QmbN6gNM2vjLj7yaJ6xJcySDxmuSK2eB9ZDv5dpj2bo5pM 47 TAG_nodeid
|
||||||
|
# QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.MASTER.crypt
|
||||||
|
# QmWHsRZCTSjSxnp1Qm8WcmHNNQTJwDS2ukLE7NTccc3Kp9 1304 TAG_publishkey.B.gpg
|
||||||
|
# TAG_passenger, TAG_file is used to attach G1Tag to file.
|
||||||
|
# ADD A PASSENGER FILE (Web2.0ID) INTO a G1Tag + Add INIT credit/debit values to live in SWARM.
|
||||||
|
# GRAB a G1Tag CAPSULE + PUT A PASSENGER MUSIC FILE IN IT
|
||||||
|
#### TODO USE "ipfs dag" + json
|
||||||
|
# {
|
||||||
|
# "type": "REC_YOUTUBE",
|
||||||
|
# "search": "${MUSICFILE}",
|
||||||
|
# "id": "vLXHXGoXuBU",
|
||||||
|
# "title": "Tale Of Us - Oliver Koletzki - Miss Monique - More Artist • New Life III (DifferentSound Mix)",
|
||||||
|
# "size": 123,
|
||||||
|
# "debit": 10,
|
||||||
|
# "credit": 1,
|
||||||
|
# "file": {
|
||||||
|
# "ld": "LDhashIPFS",
|
||||||
|
# "sd": "SDhashIPFS",
|
||||||
|
# "hd": "HDhashIPFS"
|
||||||
|
# },
|
||||||
|
# "g1tag": "RR",
|
||||||
|
# "ipns": "J",
|
||||||
|
# "ld": "ZEN",
|
||||||
|
# "sd": "ZEN",
|
||||||
|
# "hd": "EUR"
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
#############################################################################################################
|
||||||
|
# ./shell/tag_LOAD_passenger.sh G1TagIPNS FileID MusicFile MASTERKEY
|
||||||
|
JSOURCE=$1
|
||||||
|
TUBEID=$2
|
||||||
|
MUSICFILE=$3
|
||||||
|
KEYFILE=$4
|
||||||
|
# EXTENSION (Define Debit for Hosting / Credit for Reading)
|
||||||
|
DEB=$5
|
||||||
|
CRED=$6
|
||||||
|
if [[ ! $DED ]]; then DED=10; fi
|
||||||
|
if [[ ! $CRED ]]; then CRED=1; fi
|
||||||
|
if [[ ! -f "$KEYFILE" || ! -f "$MUSICFILE" || ! -f "./g1sms.pub.key" ]]; then "Do you know what you are doing? MUSICFILE=$MUSICFILE? KEYFILE=$KEYFILE?"; exit; fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## INIT & root check
|
||||||
|
NANODATE=$(date -u +%s%N)
|
||||||
|
echo "__SUB:tag_LOAD_passenger.sh: LOAD \"$MUSICFILE\" into REC G1Tag $JSOURCE indexed by $TUBEID (using $KEYFILE)... $NANODATE"
|
||||||
|
if [[ "$USER" != "root" ]]; then echo "__SUB:tag_LOAD_passenger.sh: Hey, $USER you must be root. 'sudo ./shell/tag_LOAD_passenger.sh ...' ?"; exit; fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## CHECK ipfs daemon user
|
||||||
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "__SUB:tag_LOAD_passenger.sh: BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
|
||||||
|
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||||
|
|
||||||
|
######################################################
|
||||||
|
############## EXTRACT $JSOURCERR key, amount, nodeid
|
||||||
|
JSOURCERR=$(su $YOU -c "ipfs cat /ipns/$JSOURCE/TAG_id | sed s/\ //g");
|
||||||
|
if [[ "$JSOURCERR" == "" ]]; then echo "__SUB:tag_LOAD_passenger.sh: G1TAG DETRUIT. Aucun G1Tag /ipns/$JSOURCERR ici... Ciao."; exit; fi
|
||||||
|
mkdir -p ./TAG/${JSOURCERR}; rm -f ./TAG/${JSOURCERR}/*
|
||||||
|
echo "__SUB:tag_LOAD_passenger.sh: LOG. Hey You get a G1Tag!! GET IT now: ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE"
|
||||||
|
chown -R $YOU ./TAG/${JSOURCERR}/
|
||||||
|
su $YOU -c "ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE" 2>&1
|
||||||
|
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.MASTER.crypt"
|
||||||
|
JSOURCEVALUE=$(cat ./TAG/${JSOURCERR}/TAG_amount)
|
||||||
|
TAGNODEID=$(cat ./TAG/${JSOURCERR}/TAG_nodeid)
|
||||||
|
TAGPASSENGER="./TAG/${JSOURCERR}/TAG_passenger" # contains HASH for PASSENGER FILE (CRYPT & PUBLISH)
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# CAN IT LOAD PASSENGER ?
|
||||||
|
if [[ ! -f $TAGPASSENGER ]]; then
|
||||||
|
echo "__SUB:tag_LOAD_passenger.sh: G1TAG transmis pas encore transformé en REC TAG... Ciao $YOU !";
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
passenger=$(cat $TAGPASSENGER)
|
||||||
|
if [[ "$passenger" != "READY" ]]; then echo "__SUB:tag_LOAD_passenger.sh: REC TAG not READY ($passenger)!"; exit; # COMMENT TO ALLOW REWRITE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ONLY CREATOR NODE CAN LOAD G1TAG
|
||||||
|
if [[ "$IPFSNODEID" != "$TAGNODEID" ]]; then
|
||||||
|
echo "__SUB:tag_LOAD_passenger.sh: Ce G1Tag est géré par $TAGNODEID (vous êtes $IPFSNODEID)"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## EXTRACT $JSOURCERR PUBLISH KEY
|
||||||
|
if [[ -f "$KEYFILE" ]]; then
|
||||||
|
./shell/natools.py decrypt -k "$KEYFILE" -i "$JSOURCEPUBLISHKEY" -o "/home/$YOU/.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
|
||||||
|
fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## G1TAG OPERATION
|
||||||
|
NN=$(cat ./TAG/${JSOURCERR}/TAG_n); ((NN++)); echo "$NN" > "./TAG/${JSOURCERR}/TAG_n"
|
||||||
|
|
||||||
|
TAGTYPE="./TAG/${JSOURCERR}/TAG_type" # contains PASSENGER TYPE ("" = G1, YOUTUBE, any "REC SRC")
|
||||||
|
TAGPASSENGERID="./TAG/${JSOURCERR}/TAG_passenger_id" # contains PASSENGER ID (depending TYPE) YoutubeID,
|
||||||
|
|
||||||
|
TAGPASSENGERCRYPT="./TAG/${JSOURCERR}/TAG_passenger.crypt" # contains HASH for PASSENGER FILE natools crypt with MASTERKEY
|
||||||
|
TAGPASSENGERDEBIT="./TAG/${JSOURCERR}/TAG_passenger_debit" # Countains amount Passenger is Paying Daily to SWARM IPFS Nodes (PIN)
|
||||||
|
TAGPASSENGERCREDIT="./TAG/${JSOURCERR}/TAG_passenger_credit" # Countains amount Node G1Tag must pay to PLAY file passenger
|
||||||
|
TAGPASSENGERSIZE="./TAG/${JSOURCERR}/TAG_passenger_size" # contains File Size in Mo
|
||||||
|
|
||||||
|
echo "REC" > $TAGTYPE
|
||||||
|
echo "$TUBEID" > $TAGPASSENGERID
|
||||||
|
|
||||||
|
IFILE=$(su $YOU -c "ipfs add \"${MUSICFILE}\" | tail -n 1")
|
||||||
|
if [[ ! $IFILE ]]; then exit; fi
|
||||||
|
echo "$IFILE" > $TAGPASSENGER
|
||||||
|
# ONLY SWARM KEY CAN DECRYPT IPFS LINK TO FILE (TODO: Glue better)
|
||||||
|
MASTERPUB=$(cat "./g1sms.pub.key")
|
||||||
|
./shell/natools.py encrypt -p "$MASTERPUB" -i "$TAGPASSENGER" -o "$TAGPASSENGERCRYPT"
|
||||||
|
echo "LOADED" > $TAGPASSENGER
|
||||||
|
|
||||||
|
echo "$DEB" > $TAGPASSENGERDEBIT
|
||||||
|
echo "$CRED" > $TAGPASSENGERCREDIT
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
echo "${NANODATE}" > "./TAG/${JSOURCERR}/TAG_nanodate"
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${JSOURCERR} | tail -n 1")
|
||||||
|
# RECORD TAG_chain And HASH again before publish
|
||||||
|
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"
|
||||||
|
|
||||||
|
# WRITE FILE REC INDEX IN NODE G1TAG REF.
|
||||||
|
mkdir -p ./wallets/.$IPFSNODEID/TAG/
|
||||||
|
echo "$TUBEID" > "./wallets/.$IPFSNODEID/TAG/${J}.youtubeid"
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# REFRESH SWARM
|
||||||
|
##########################
|
||||||
|
IWALLETS=$(su $YOU -c "ipfs add -rHq './wallets' | tail -n 1")
|
||||||
|
|
||||||
|
# CHAIN STATE FOR $IPFSNODEID
|
||||||
|
echo $IWALLETS > ./wallets/.$IPFSNODEID.wallets.chain
|
||||||
|
echo "__SUB:tag_LOAD_passenger.sh: NEW './wallets' HASH ipfs ls $IWALLETS"
|
||||||
|
|
||||||
|
# PUBLISH IPNS NODE WALLETS
|
||||||
|
NODEWALLETS=$(su $YOU -c "ipfs name publish --quieter /ipfs/$IWALLETS")
|
||||||
|
echo "__SUB:tag_LOAD_passenger.sh: YOUTUBE REC G1 TAG LOADED ($TAGPASSENGERCRYPT) <<<<<< https://youtube.com/watch?v=$TUBEID"
|
||||||
|
echo "__SUB:tag_LOAD_passenger.sh: ipfs cat /ipns/$NODEWALLETS/.$IPFSNODEID/TAG/${J}.youtubeid"
|
||||||
|
exit
|
||||||
|
echo "__SUB:tag_LOAD_passenger.sh: ZEN BALANCE: $JSOURCEVALUE Zen. HEB: $DEB / PLAY: $CRED"
|
||||||
|
exit
|
|
@ -0,0 +1,164 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
###########################################################################################
|
||||||
|
# tag_OP.sh OPERATION ON G1TAG...
|
||||||
|
# sudo pip3 install duniterpy
|
||||||
|
###########################################################################################
|
||||||
|
# ipfs ls /ipns/QmY6ooFcsGXY4VSindqKMz9GvrprFXY32RrsTmqvVTYQX5
|
||||||
|
# QmZ3RfWk1u5LEGYLHA633B5TNJy3Du27K6Fny9wcxpowGS 4 TAG_amount
|
||||||
|
# QmXizDydPuiBd1V7JBVY5kdppShm9xdk2aoYj7c8V8Foxe 47 TAG_chain
|
||||||
|
# QmeHHBZKtLJHr11rwXKeimwDE4i3nLMy2VPkWZsNaFasg1 4 TAG_currency
|
||||||
|
# QmSjBDpjnoxnQT5RWRnyLxqwE3ovSRVb7xjwZoiufZAv3E 39 TAG_id
|
||||||
|
# QmUQcSjQx2bg4cSe2rUZyQi6F8QtJFJb74fWL7D784UWf9 2 TAG_n
|
||||||
|
# QmdbdBWv4SygqaaeWHAvABiQAa3faf4ncfSyzRnx8BDdCc 20 TAG_nanodate
|
||||||
|
# QmbN6gNM2vjLj7yaJ6xJcySDxmuSK2eB9ZDv5dpj2bo5pM 47 TAG_nodeid
|
||||||
|
# QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.MASTER.crypt
|
||||||
|
# QmWHsRZCTSjSxnp1Qm8WcmHNNQTJwDS2ukLE7NTccc3Kp9 1304 TAG_publishkey.B.gpg
|
||||||
|
# ...
|
||||||
|
# TAG_passenger, TAG_file is used to attach G1Tag to file.
|
||||||
|
#
|
||||||
|
# TRANSFERT ZEN FROM G1Tag to G1Tag
|
||||||
|
|
||||||
|
# G1Tag J References IPNS G1 Tag link
|
||||||
|
JSOURCE=$1
|
||||||
|
JDEST=$2
|
||||||
|
# Zen Amount to transfert
|
||||||
|
VALUE=$3
|
||||||
|
# Needed to Open ipfs publish Key
|
||||||
|
KEYFILE=$4
|
||||||
|
|
||||||
|
############################################
|
||||||
|
############## INIT & root check
|
||||||
|
NANODATE=$(date -u +%s%N)
|
||||||
|
echo "__SUB:tag_OP.sh: TRANSFER from $JSOURCE (1) to $JDEST (2) G1Tag = $VALUE (3) using \"$KEYFILE\" (4)... GO... $NANODATE"
|
||||||
|
if [[ "$USER" != "root" ]]; then echo "__SUB:tag_OP.sh: Hey, $USER you must at least be admin of your system. sudo -s ?"; exit; fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## CHECK ipfs daemon user
|
||||||
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "__SUB:tag_OP.sh: BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
|
||||||
|
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## SOURCE EXTRACTION
|
||||||
|
JSOURCERR=$(su $YOU -c "ipfs cat /ipns/$JSOURCE/TAG_id | sed s/\ //g");
|
||||||
|
#############################################
|
||||||
|
############## GOOD or BAD ?
|
||||||
|
if [[ "$JSOURCERR" == "" ]]; then echo "__SUB:tag_OP.sh: G1TAG DETRUIT. Aucun G1Tag /ipns/$JSOURCERR ici... Ciao."; exit; fi
|
||||||
|
echo "__SUB:tag_OP.sh: LOG. SOURCE G1Tag OK!! GREAT... Retrieving it all: ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE"
|
||||||
|
mkdir -p ./TAG/${JSOURCERR}; rm -f ./TAG/${JSOURCERR}/*
|
||||||
|
chown -R $YOU ./TAG/${JSOURCERR}/
|
||||||
|
su $YOU -c "ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE"
|
||||||
|
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.MASTER.crypt"
|
||||||
|
JSOURCEVALUE=$(cat ./TAG/${JSOURCERR}/TAG_amount);
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## No JDEST, then return $JSOURCEVALUE
|
||||||
|
if [[ "$JDEST" == "" ]]; then echo "__SUB:tag_OP.sh: OK. G1Tag $JSOURCE VALUE = $JSOURCEVALUE Zen"; exit; fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## TEST IF $VALUE IS AVAILABLE
|
||||||
|
FINALSOURCE=$( echo "${JSOURCEVALUE} - ${VALUE}" | bc -l )
|
||||||
|
if [[ $FINALSOURCE -lt 0 ]]; then echo "__SUB:tag_OP.sh: KO. La valeur de ce G1Tag ne peut pas être : $FINALSOURCE Zen... Ciao $YOU !"; exit; fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## EXTRACT $JSOURCERR PUBLISH KEY
|
||||||
|
if [[ -f $KEYFILE && ! -f "/home/$YOU/.ipfs/keystore/$JSOURCERR" ]]; then
|
||||||
|
./shell/natools.py decrypt -k "$KEYFILE" -i "$JSOURCEPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JSOURCERR"
|
||||||
|
else
|
||||||
|
echo "__SUB:tag_OP.sh: KO. La clef $KEYFILE fournie pour ce G1Tag $JSOURCERR est inexistante. Contact: https://g1sms.fr"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## DESTINATION EXTRACTION
|
||||||
|
JDESTRR=$(su $YOU -c "ipfs cat /ipns/$JDEST/TAG_id | sed s/\ //g");
|
||||||
|
if [[ "$JDESTRR" == "" ]]; then echo "__SUB:tag_OP.sh: BAD G1TAG. Aucun G1Tag /ipns/$JDESTRR ici... Ciao."; exit; fi
|
||||||
|
mkdir -p ./TAG/${JDESTRR}; rm -f ./TAG/${JDESTRR}/*
|
||||||
|
echo "__SUB:tag_OP.sh: LOG. Hey You get a G1Tag!! GREAT... ipfs get --output=./TAG/${JDESTRR}/ /ipns/$JDEST"
|
||||||
|
chown -R $YOU ./TAG/${JDESTRR}/
|
||||||
|
su $YOU -c "ipfs get --output=./TAG/${JDESTRR}/ /ipns/$JDEST"
|
||||||
|
JDESTPUBLISHKEY="./TAG/${JDESTRR}/TAG_publishkey.MASTER.crypt"
|
||||||
|
JDESTVALUE=$(cat ./TAG/${JDESTRR}/TAG_amount);
|
||||||
|
FINALDEST=$(echo "${JDESTVALUE} + ${VALUE}" | bc -l)
|
||||||
|
# EXTRACT $JSOURCERR PUBLISH KEY to "/home/$YOU/.ipfs/keystore/JSOURCE"
|
||||||
|
# EXTRACT PUBLISH KEY
|
||||||
|
if [[ -f $KEYFILE && ! -f "/home/$YOU/.ipfs/keystore/$JDESTRR" ]]; then
|
||||||
|
./shell/natools.py decrypt -k "$KEYFILE" -i "$JDESTPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JDESTRR"
|
||||||
|
else
|
||||||
|
echo "__SUB:tag_OP.sh: KO. La clef $KEYFILE fournie pour ce G1Tag $JDESTRR est inexistante. Be part of the G1sms+SWARM. https://g1sms.fr"
|
||||||
|
fi
|
||||||
|
|
||||||
|
######################################################################################################
|
||||||
|
if [[ -f "/home/$YOU/.ipfs/keystore/$JDESTRR" && -f "/home/$YOU/.ipfs/keystore/$JSOURCERR" ]]; then
|
||||||
|
# IF PUBLISH key for BOTH G1TAG exists
|
||||||
|
#############################################
|
||||||
|
############## SOURCE OPERATION
|
||||||
|
NN=$(cat ./TAG/${JSOURCERR}/TAG_n); ((NN++)); echo "$NN" > "./TAG/${JSOURCERR}/TAG_n"
|
||||||
|
#############################################
|
||||||
|
# Destroy B Access ?!!
|
||||||
|
#rm -f ./TAG/${JSOURCERR}/TAG_publishkey.B.gpg
|
||||||
|
echo "$FINALSOURCE" > "./TAG/${JSOURCERR}/TAG_amount"
|
||||||
|
echo "${NANODATE}" > "./TAG/${JSOURCERR}/TAG_nanodate" # TODO: ACTIVATE NANODATE CONTROL / NODES MEDIANTIME
|
||||||
|
echo "${IPFSNODEID}" > "./TAG/${JSOURCERR}/TAG_writerid"
|
||||||
|
|
||||||
|
if [[ "$JSOURCE" == "$JDEST" ]]; then
|
||||||
|
# PUT "READY" IN TAG_passenger (can now be loaded with a file), now actual IPFSNODEID is creator
|
||||||
|
echo "READY" > "./TAG/${JSOURCERR}/TAG_passenger"
|
||||||
|
echo "${IPFSNODEID}" > "./TAG/${JSOURCERR}/TAG_nodeid"
|
||||||
|
echo "__SUB:tag_OP.sh: ${IPFSNODEID} NODE created REC TAG. ${JSOURCERR}. READY to LOAD_passenger now!!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SOURCENODEID=$(cat "./TAG/${JSOURCERR}/TAG_nodeid")
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${JSOURCERR} | tail -n 1")
|
||||||
|
# RECORD TAG_chain And HASH again
|
||||||
|
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}")
|
||||||
|
# CLEAN IPFS keystore
|
||||||
|
if [[ "${SOURCENODEID}" != "${IPFSNODEID}" ]]; then
|
||||||
|
rm -f "/home/$YOU/.ipfs/keystore/$JSOURCERR"
|
||||||
|
fi
|
||||||
|
echo "__SUB:tag_OP.sh: G1Tag $JSOURCERR value ($FINALSOURCE) :: su $YOU -c \"ipfs cat /ipns/$JSOURCE/TAG_amount\""
|
||||||
|
|
||||||
|
if [[ "$JSOURCE" != "$JDEST" ]]; then
|
||||||
|
#############################################
|
||||||
|
############## DESTINATION OPERATION
|
||||||
|
NN=$(cat ./TAG/${JDESTRR}/TAG_n); ((NN++)); echo "$NN" > "./TAG/${JDESTRR}/TAG_n"
|
||||||
|
#############################################
|
||||||
|
# Destroy B Access ?!!
|
||||||
|
#rm -f ./TAG/${JDESTRR}/TAG_publishkey.B.gpg
|
||||||
|
echo "${FINALDEST}" > "./TAG/${JDESTRR}/TAG_amount"
|
||||||
|
##############################################################################################################################
|
||||||
|
if [[ $FINALSOURCE -eq 0 ]]; then
|
||||||
|
echo "OK. G1Tag ${JSOURCERR} is empty destroying it!!";
|
||||||
|
rm -f "./TAG/${JDESTRR}/TAG_id";
|
||||||
|
fi
|
||||||
|
##############################################################################################################################
|
||||||
|
echo "${NANODATE}" > "./TAG/${JDESTRR}/TAG_nanodate"
|
||||||
|
echo "${IPFSNODEID}" > "./TAG/${JDESTRR}/TAG_writerid"
|
||||||
|
DESTNODEID=$(cat "./TAG/${JDESTRR}/TAG_nodeid")
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${JDESTRR} | tail -n 1")
|
||||||
|
# RECORD TAG_chain And HASH again
|
||||||
|
echo "$I" > "./TAG/${JDESTRR}/TAG_chain"
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${JDESTRR} | tail -n 1")
|
||||||
|
# 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"
|
||||||
|
fi
|
||||||
|
echo "__SUB:tag_OP.sh: G1Tag $JDESTRR value ($FINALDEST) :: su $YOU -c \"ipfs cat /ipns/$JDEST/TAG_amount\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "__SUB:tag_OP.sh: DONE. G1Tag balance updated:
|
||||||
|
$JSOURCERR (/ipns/$JSOURCE) : $JSOURCEVALUE => $FINALSOURCE
|
||||||
|
$JDESTRR (/ipns/$JSDEST) : $JDESTVALUE) => $FINALDEST"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo "__SUB:tag_OP.sh: NO OPERATION DONE"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
######################################################################################################
|
|
@ -0,0 +1,68 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
###########################################################################################
|
||||||
|
# Find and PLAY (cat) passenger File OF G1Tag / REC TAG
|
||||||
|
# sudo pip3 install duniterpy
|
||||||
|
# READERID is PHONE or IPFSNODEID (G1 ./wallets/* )
|
||||||
|
# JSOURCE is G1Tag IPNS link with PASSENGER
|
||||||
|
###########################################################################################
|
||||||
|
READERID=$1
|
||||||
|
JSOURCE=$2
|
||||||
|
KEYFILE="./g1sms.priv.key"
|
||||||
|
MASTERPUB=$(cat "./g1sms.pub.key")
|
||||||
|
|
||||||
|
if [[ ! $READERID || ! $JSOURCE || ! -f "$KEYFILE" || ! $MASTERPUB ]]; then "Something is wrong! Do you know what you are doing?"; exit; fi
|
||||||
|
|
||||||
|
NODEG1TAG=$(cat "./wallets_swarm/.$READERID/TAG/$READERID") # Contains IPNS link to Node G1Tag
|
||||||
|
if [[ ! $NODEG1TAG ]]; then
|
||||||
|
# INIT NODE G1TAG WITH 1000 zen
|
||||||
|
echo "__SUB:tag_PLAY_passenger.sh: $READERID ne possède pas de G1Tag sudo ./shell/sms_G1TAG.sh \"$READERID\" \"10\" \"1\" \"NODE\" \"$READERID\" "
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## INIT & root check
|
||||||
|
NANODATE=$(date -u +%s%N)
|
||||||
|
echo "__SUB:tag_PLAY_passenger.sh: $READERID IS READING $JSOURCE"
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
############## CHECK ipfs daemon user
|
||||||
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
if [[ "$USER" != "root" ]]; then echo "__SUB:tag_PLAY_passenger.sh: Hey, $USER you must able to be root for now (try if sudo access is ok)"; fi
|
||||||
|
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "__SUB:tag_PLAY_passenger.sh: BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $USER !"; exit; fi
|
||||||
|
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
JSOURCERR=$(su $YOU -c "ipfs cat /ipns/$JSOURCE/TAG_id | sed s/\ //g");
|
||||||
|
if [[ "$JSOURCERR" == "" ]]; then echo "__SUB:tag_PLAY_passenger.sh: G1TAG DETRUIT. Aucun G1Tag /ipns/$JSOURCERR ici... Ciao."; exit; fi
|
||||||
|
mkdir -p ./TAG/${JSOURCERR}; rm -f ./TAG/${JSOURCERR}/*
|
||||||
|
echo "__SUB:tag_PLAY_passenger.sh: FOUND G1Tag... GETTING IT: ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE"
|
||||||
|
chown -R $YOU ./TAG/${JSOURCERR}/
|
||||||
|
su $YOU -c "ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE"
|
||||||
|
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.MASTER.crypt"
|
||||||
|
|
||||||
|
TAGZEN=$(cat "./TAG/${JSOURCERR}/TAG_amount");
|
||||||
|
DEB=$(cat "./TAG/${JSOURCERR}/TAG_passenger_debit")
|
||||||
|
CRED=$(cat "./TAG/${JSOURCERR}/TAG_passenger_credit")
|
||||||
|
|
||||||
|
##############################################
|
||||||
|
# MAKE TRANSACTIONS
|
||||||
|
NODEZEN=$(cat "./wallets/$READERID/$READERID.g1cents")
|
||||||
|
uidna=$(cat "./wallets/$READERID/$READERID.uidna")
|
||||||
|
if [[ $ZEN -gt $CRED ]]; then
|
||||||
|
REZ=$((TAGZEN + CRED))
|
||||||
|
|
||||||
|
#echo "$REZ" > "./TAG/${JSOURCERR}/TAG_amount"
|
||||||
|
# TODO READER NEEDS ITS G1TAG
|
||||||
|
#./shell/tag_OP.sh "$READERIDTAG" "J2TAG" "$CRED" $KEYFILE
|
||||||
|
else
|
||||||
|
echo "Désolé ;( $READERID vous manquez de ZEN ($ZEN) pour vous payer la lecture de $JSOURCE ($CRED)"
|
||||||
|
echo "Rechargez avec un VIREMENT vers $uidna"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# READ PASSENGER
|
||||||
|
|
|
@ -0,0 +1,250 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
echo "__SUB:tag_READ.sh: QRCODE READER : START"
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
|
||||||
|
# DOUCHETTE ES TU LA?
|
||||||
|
if [ ! $G1TX ]; then ./shell/parle.sh "Branchez votre lecteur de QR code!"; exit; fi
|
||||||
|
|
||||||
|
# TABLEAU MEMOIRE DE SCAN
|
||||||
|
declare -a act
|
||||||
|
declare -a obj
|
||||||
|
declare -a val
|
||||||
|
./shell/parle.sh "Lecteur de G1 Tag. OK. Prêt"
|
||||||
|
|
||||||
|
cat /dev/ttyACM0 | while read line; do
|
||||||
|
lon=${#line}
|
||||||
|
pref=$(echo $line | cut -d ":" -f 1)
|
||||||
|
qrvalue=$(echo $line | cut -d ":" -f 2)
|
||||||
|
log "__SUB:tag_READ.sh: SCAN /dev/ttyACM0 ($lon) :: $line"
|
||||||
|
|
||||||
|
case $pref in
|
||||||
|
RJ)
|
||||||
|
./shell/parle.sh "R J"
|
||||||
|
R=$(echo $qrvalue | cut -d '#' -f 1)
|
||||||
|
J=$(echo $qrvalue | cut -d '#' -f 2)
|
||||||
|
log "__SUB:tag_READ.sh: Lecture G1Tag $R $J"
|
||||||
|
#
|
||||||
|
ID=$(su $YOU -c "ipfs cat /ipns/$J/TAG_id");
|
||||||
|
if [[ "$ID" == "" ]]; then
|
||||||
|
./shell/parle.sh "G1 Tag déjà capturé, veuillez le détruire!";
|
||||||
|
sms_SEND "$ADMINPHONE" "ADMIN! FRAUDE G1Tag RJ $R $J"
|
||||||
|
# TODO: ENQUETER auprès du CREATEUR de ce G1 Tag !!
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
RR=$(echo $ID | sed s/\ //g)
|
||||||
|
FID=$(echo $ID | awk '{print toupper($1)}')
|
||||||
|
RVALUE=$(su $YOU -c "ipfs cat /ipns/$J/TAG_amount");
|
||||||
|
CURRENCY=$(su $YOU -c "ipfs cat /ipns/$J/TAG_currency" | awk '{print tolower($1)}')
|
||||||
|
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");
|
||||||
|
if [[ "$PASSENGER" != "" ]]; then
|
||||||
|
./shell/parle.sh "Rec Tag Machine $PASSENGER! Valeur $RVALUE $CUR";
|
||||||
|
else
|
||||||
|
G1VAL=$(bc -l <<< "scale=2; $RVALUE / 100" | cut -d '.' -f 1)
|
||||||
|
log "__SUB:tag_READ.sh: G1Tag $FID. Valeur $RVALUE $CURRENCY = $G1VAL G1"
|
||||||
|
./shell/parle.sh "G1 Tag $FID. Valeur $RVALUE $CUR convertible en $G1VAL June"
|
||||||
|
fi
|
||||||
|
cmd="RJ"
|
||||||
|
CASHBACK=""
|
||||||
|
val+=("$RVALUE")
|
||||||
|
;;
|
||||||
|
|
||||||
|
BJ)
|
||||||
|
./shell/parle.sh "B J"
|
||||||
|
BB=$(echo $qrvalue | cut -d '#' -f 1)
|
||||||
|
J=$(echo $qrvalue | cut -d '#' -f 2)
|
||||||
|
log "__SUB:tag_READ.sh: Ouverture G1Tag $BB $J"
|
||||||
|
#
|
||||||
|
ID=$(su $YOU -c "ipfs cat /ipns/$J/TAG_id");
|
||||||
|
FID=$(echo $ID | awk '{print toupper($1)}')
|
||||||
|
if [[ "$ID" == "" ]]; then
|
||||||
|
./shell/parle.sh "G1 Tag inconnu! veuillez le détruire!";
|
||||||
|
# sms_SEND "$ADMINPHONE" "ADMIN! FRAUDE G1Tag BJ $B $J"
|
||||||
|
# TODO: ENQUETER auprès du CREATEUR de ce G1 Tag !!
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
RR=$(echo $ID | sed s/\ //g)
|
||||||
|
BVALUE=$(su $YOU -c "ipfs cat /ipns/$J/TAG_amount")
|
||||||
|
CURRENCY=$(su $YOU -c "ipfs cat /ipns/$J/TAG_currency" | awk '{print tolower($1)}')
|
||||||
|
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
|
||||||
|
log "__SUB:tag_READ.sh: Clef de publication IPFS $RR déjà présente"
|
||||||
|
else
|
||||||
|
rm /tmp/TAG_publishkey.B.gpg
|
||||||
|
su $YOU -c "ipfs get -o /tmp/ /ipns/$J/TAG_publishkey.B.gpg"
|
||||||
|
# CHECK IF OK
|
||||||
|
gpg -d --output /tmp/ipns.key --pinentry-mode=loopback --passphrase $BB /tmp/TAG_publishkey.B.gpg
|
||||||
|
if [[ ! -f /tmp/ipns.key ]]; then
|
||||||
|
./shell/parle.sh "Erreur. Problème de déchiffrage PGP ${FID}! Vérifiez vos logs";
|
||||||
|
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
|
||||||
|
log "__SUB:tag_READ.sh: Récupération de la clef de publication $RR"
|
||||||
|
./shell/parle.sh "Récupération clef de publication du G1 Tag ${FID}"
|
||||||
|
fi
|
||||||
|
if [[ "$PASSENGER" != "" ]]; then
|
||||||
|
log "__SUB:tag_READ.sh: !!!! REC Tag = $BVALUE $CURRENCY"
|
||||||
|
./shell/parle.sh "Rec Tag Machine! Valeur $BVALUE $CUR";
|
||||||
|
else
|
||||||
|
log "__SUB:tag_READ.sh: Ce G1 Tag contient $BVALUE $CURRENCY"
|
||||||
|
./shell/parle.sh "Ce G1 Tag contient $BVALUE $CUR"
|
||||||
|
fi
|
||||||
|
cmd="BJ"
|
||||||
|
val+=("$BVALUE")
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
if [[ $lon -eq 44 ]]; then
|
||||||
|
./shell/parle.sh "Portefeuille G1?"
|
||||||
|
J=$qrvalue
|
||||||
|
if [[ "$J" != "${obj[0]}" ]]; then
|
||||||
|
VALUE=$(./shell/timeout.sh -t 15 ./silkaj/silkaj amount $J)
|
||||||
|
|
||||||
|
if [[ "$(echo $VALUE | cut -d ':' -f 1)" != "Error" && "$VALUE" != "" ]]; then
|
||||||
|
log "__SUB:tag_READ.sh: Ce compte monnaie libre contient $VALUE G1"
|
||||||
|
./shell/parle.sh "Ce compte monnaie libre contient $VALUE G1"
|
||||||
|
CASHBACK="$J"
|
||||||
|
cmd="G1"
|
||||||
|
val+=("$VALUE")
|
||||||
|
else
|
||||||
|
log "__SUB:tag_READ.sh: ERREUR QR code illisible. longueur $J = ${#J}"
|
||||||
|
if [[ "$VALUE" == "" ]]; then
|
||||||
|
DUNITER=$(./shell/checknodes.sh 'BAN')
|
||||||
|
echo "TIMEOUT. CHANGE SILKAJ SERVER: $DUNITER"
|
||||||
|
./shell/parle.sh "Temps dépassé. Changement de serveur $DUNITER"
|
||||||
|
CASHBACK=""
|
||||||
|
else
|
||||||
|
./shell/parle.sh "QR code inconnu."
|
||||||
|
CASHBACK=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
./shell/parle.sh "Ce compte monnaie libre contient ${val[0]} G1"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
./shell/parle.sh "QR code de type inconnu"
|
||||||
|
fi
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
||||||
|
###############################################################
|
||||||
|
# APRES G1 CASHBACK : G1 Tag BJ WRITE => ENCAISSEMENT
|
||||||
|
if [[ "${cmd}" == "BJ" && "$CASHBACK" != "" && -f /home/$YOU/.ipfs/keystore/${RR} ]]; then
|
||||||
|
./shell/parle.sh "Encaissement du G1 Tag"
|
||||||
|
log "__SUB:tag_READ.sh: G1 tag de $BVALUE G1 ! /ipns/$J Virement vers $CASHBACK? "
|
||||||
|
|
||||||
|
./shell/parle.sh "vers portefeuille G1"
|
||||||
|
# ipfs get G1Tag vers ./TAG/${RR}
|
||||||
|
mkdir -p ./TAG/${RR}; rm -f ./TAG/${RR}/*; chown -R $YOU ./TAG/${RR}/
|
||||||
|
log "__SUB:tag_READ.sh: ipfs get --output=./TAG/${RR} /ipns/$J"
|
||||||
|
su $YOU -c "ipfs get --output=./TAG/${RR} /ipns/$J"
|
||||||
|
|
||||||
|
if [[ $(cat ./TAG/${RR}/TAG_passenger) != "" ]]; then ./shell/parle.sh "Impossible à encaisser. REC Tag ${FID}. $(cat ./TAG/${RR}/TAG_passenger) de Valeur $BVALUE "; continue; fi
|
||||||
|
|
||||||
|
# Make Silkaj TX
|
||||||
|
G1VAL=$(bc -l <<< "scale=2; $BVALUE / 100" | cut -d '.' -f 1)
|
||||||
|
log "__SUB:tag_READ.sh: Silkaj TX $MASTERKEYFILE ($G1VAL) -> $CASHBACK"
|
||||||
|
PAY=$(./silkaj/silkaj transaction --auth-file -file="$MASTERKEYFILE" --amount=$G1VAL --output=$CASHBACK --comment="[G1sms+] CAPTURE G1Tag $RR" -y)
|
||||||
|
|
||||||
|
log "__SUB:tag_READ.sh: Silkaj output = $PAY"
|
||||||
|
if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then
|
||||||
|
new=$(./shell/checknodes.sh "BAN")
|
||||||
|
sms_ERROR "$ADMINPHONE" "Il est survenu un problème avec un virement. Retour silkaj: $PAY ... $new";
|
||||||
|
./shell/parle.sh "Erreur de virement. Changement de serveur Duniter. Veuillez recommencer"
|
||||||
|
else
|
||||||
|
# ENCAISSEMENT G1Tag
|
||||||
|
./shell/parle.sh "Transfert du Tag ${FID} de $G1VAL G1 vers portefeuille OK"
|
||||||
|
# CAPTURE / DESTRUCTION du G1 Tag
|
||||||
|
echo "0" > "./TAG/${RR}/TAG_amount"
|
||||||
|
echo "${J}" > "./TAG/${RR}/TAG_ipns"
|
||||||
|
|
||||||
|
# Iterate
|
||||||
|
if [[ -f ./TAG/${RR}/TAG_n ]]; then NN=$(cat ./TAG/${RR}/TAG_n); ((NN++)); else NN=0; fi
|
||||||
|
|
||||||
|
# TAG_actions
|
||||||
|
echo "$NN" > "./TAG/${RR}/TAG_n"
|
||||||
|
echo "${NANODATE}" > "./TAG/${RR}/TAG_nanodate"
|
||||||
|
echo "${IPFSNODEID}" > "./TAG/${RR}/TAG_writerid"
|
||||||
|
|
||||||
|
# EMPTY G1TAG ID AND REMOVE PUBLISHKEYS
|
||||||
|
echo "" > "./TAG/${RR}/TAG_id"
|
||||||
|
rm -f ./TAG/TAG_publishkey.*
|
||||||
|
|
||||||
|
log "__SUB:tag_READ.sh: Destruction G1Tag TAG_id $NN.${NANODATE} (par NODE ${IPFSNODEID}) => Value = 0"
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
||||||
|
# TAG_chain
|
||||||
|
echo "$I" > "./TAG/${RR}/TAG_chain"
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
||||||
|
# IPNS $RR PUBLISH
|
||||||
|
J=$(su $YOU -c "ipfs name publish -k ${RR} --quieter /ipfs/${I}")
|
||||||
|
|
||||||
|
log "__SUB:tag_READ.sh: Destruction de ce G1 Tag publish -k ${RR} --quieter /ipfs/${I} :: ipfs ls /ipns/$J"
|
||||||
|
./shell/parle.sh "${FID} G1 Tag vide. Merci de détruire ce G1 Tag!"
|
||||||
|
|
||||||
|
# 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}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# AJOUT MEMOIRE SCAN
|
||||||
|
./shell/parle.sh "Mémorisation"
|
||||||
|
act+=("$cmd")
|
||||||
|
obj+=("$J")
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# FLUSH MEMOIRE 2 SCAN
|
||||||
|
if [[ ${#act[@]} -eq 2 ]]; then
|
||||||
|
echo "${act[@]}"
|
||||||
|
echo "${obj[@]}"
|
||||||
|
echo "${val[@]}"
|
||||||
|
###############################################################
|
||||||
|
# PRESENTATION RJ puis BJ différents Tag WRITE = TRANSFERT G1 TAG
|
||||||
|
if [[ "${act[0]}" == "RJ" && "${act[1]}" == "BJ" && "${obj[0]}" != "${obj[1]}" ]]; then
|
||||||
|
PASSENGER=$(su $YOU -c "ipfs cat /ipns/${obj[1]}/TAG_passenger");
|
||||||
|
if [[ "$PASSENGER" != "" ]]; then
|
||||||
|
./shell/parle.sh "Rec Tag Machine non transférable!";
|
||||||
|
else
|
||||||
|
log "__SUB:tag_READ.sh: Transfert de G1 Tag à G1 Tag. $BVALUE $CUR"
|
||||||
|
./shell/parle.sh "Transfert de ${val[1]} $CUR vers le G1 Tag ${FID}"
|
||||||
|
log "__SUB:tag_READ.sh: $(./shell/tag_OP.sh ${obj[1]} ${obj[0]} ${val[1]} $MASTERKEYFILE)"
|
||||||
|
fi
|
||||||
|
CASHBACK=""
|
||||||
|
fi
|
||||||
|
###############################################################
|
||||||
|
# PRESENTATION BJ identiques TRANSFORMATION G1 TAG en REC TAG
|
||||||
|
if [[ "${act[0]}" == "BJ" && "${act[1]}" == "BJ" && "${obj[0]}" == "${obj[1]}" ]]; then
|
||||||
|
PASSENGER=$(su $YOU -c "ipfs cat /ipns/${obj[0]}/TAG_passenger");
|
||||||
|
if [[ "$PASSENGER" != "" ]]; then
|
||||||
|
./shell/parle.sh "Déjà Rec Tag Machine!";
|
||||||
|
else
|
||||||
|
log "__SUB:tag_READ.sh: Transformation du G1 Tag en Rec Tag. ${val[0]} = ${val[1]}"
|
||||||
|
./shell/parle.sh "Transformation du G1 Tag ${val[0]} $CUR en Rec Tag chargé de ${FID}..."
|
||||||
|
log "__SUB:tag_READ.sh: $(./shell/tag_OP.sh ${obj[0]} ${obj[0]} 0 $MASTERKEYFILE)"
|
||||||
|
fi
|
||||||
|
CASHBACK=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
act=()
|
||||||
|
obj=()
|
||||||
|
val=()
|
||||||
|
./shell/parle.sh "Nouveau cycle de lecture."
|
||||||
|
fi
|
||||||
|
|
||||||
|
./shell/parle.sh "Flasher un QR code"
|
||||||
|
|
||||||
|
done
|
|
@ -0,0 +1,91 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# The Bash shell script executes a command with a time-out.
|
||||||
|
# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal
|
||||||
|
# is blocked, then the subsequent SIGKILL (9) terminates it.
|
||||||
|
#
|
||||||
|
# Based on the Bash documentation example.
|
||||||
|
|
||||||
|
# Hello Chet,
|
||||||
|
# please find attached a "little easier" :-) to comprehend
|
||||||
|
# time-out example. If you find it suitable, feel free to include
|
||||||
|
# anywhere: the very same logic as in the original examples/scripts, a
|
||||||
|
# little more transparent implementation to my taste.
|
||||||
|
#
|
||||||
|
# Dmitry V Golovashkin <Dmitry.Golovashkin@sas.com>
|
||||||
|
|
||||||
|
scriptName="${0##*/}"
|
||||||
|
|
||||||
|
declare -i DEFAULT_TIMEOUT=9
|
||||||
|
declare -i DEFAULT_INTERVAL=1
|
||||||
|
declare -i DEFAULT_DELAY=1
|
||||||
|
|
||||||
|
# Timeout.
|
||||||
|
declare -i timeout=DEFAULT_TIMEOUT
|
||||||
|
# Interval between checks if the process is still alive.
|
||||||
|
declare -i interval=DEFAULT_INTERVAL
|
||||||
|
# Delay between posting the SIGTERM signal and destroying the process by SIGKILL.
|
||||||
|
declare -i delay=DEFAULT_DELAY
|
||||||
|
|
||||||
|
function printUsage() {
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
$scriptName [-t timeout] [-i interval] [-d delay] command
|
||||||
|
Execute a command with a time-out.
|
||||||
|
Upon time-out expiration SIGTERM (15) is sent to the process. If SIGTERM
|
||||||
|
signal is blocked, then the subsequent SIGKILL (9) terminates it.
|
||||||
|
|
||||||
|
-t timeout
|
||||||
|
Number of seconds to wait for command completion.
|
||||||
|
Default value: $DEFAULT_TIMEOUT seconds.
|
||||||
|
|
||||||
|
-i interval
|
||||||
|
Interval between checks if the process is still alive.
|
||||||
|
Positive integer, default value: $DEFAULT_INTERVAL seconds.
|
||||||
|
|
||||||
|
-d delay
|
||||||
|
Delay between posting the SIGTERM signal and destroying the
|
||||||
|
process by SIGKILL. Default value: $DEFAULT_DELAY seconds.
|
||||||
|
|
||||||
|
As of today, Bash does not support floating point arithmetic (sleep does),
|
||||||
|
therefore all delay/time values must be integers.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Options.
|
||||||
|
while getopts ":t:i:d:" option; do
|
||||||
|
case "$option" in
|
||||||
|
t) timeout=$OPTARG ;;
|
||||||
|
i) interval=$OPTARG ;;
|
||||||
|
d) delay=$OPTARG ;;
|
||||||
|
*) printUsage; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
# $# should be at least 1 (the command to execute), however it may be strictly
|
||||||
|
# greater than 1 if the command itself has options.
|
||||||
|
if (($# == 0 || interval <= 0)); then
|
||||||
|
printUsage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# kill -0 pid Exit code indicates if a signal may be sent to $pid process.
|
||||||
|
(
|
||||||
|
((t = timeout))
|
||||||
|
|
||||||
|
while ((t > 0)); do
|
||||||
|
sleep $interval
|
||||||
|
kill -0 $$ || exit 0
|
||||||
|
((t -= interval))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Be nice, post SIGTERM first.
|
||||||
|
# The 'exit 0' below will be executed if any preceeding command fails.
|
||||||
|
kill -s SIGTERM $$ && kill -0 $$ || exit 0
|
||||||
|
sleep $delay
|
||||||
|
kill -s SIGKILL $$
|
||||||
|
) 2> /dev/null &
|
||||||
|
|
||||||
|
exec "$@"
|
|
@ -0,0 +1,67 @@
|
||||||
|
# ---> Python
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*,cover
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Idea
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Vim swap files
|
||||||
|
*~
|
||||||
|
*.swp
|
||||||
|
*.swo
|
|
@ -0,0 +1,662 @@
|
||||||
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
# Silkaj
|
||||||
|
|
||||||
|
- CLI Duniter client written with Python 3.
|
||||||
|
- [Website](https://silkaj.duniter.org)
|
||||||
|
|
||||||
|
## Install
|
||||||
|
### With release
|
||||||
|
Download [last release](https://git.duniter.org/clients/python/silkaj/tags) with `wget`.
|
||||||
|
Check it's integrity comparing it to `silkaj_sha256sum`:
|
||||||
|
```bash
|
||||||
|
sha256sum silkaj
|
||||||
|
```
|
||||||
|
|
||||||
|
Add executable permissions:
|
||||||
|
```bash
|
||||||
|
chmod a+x silkaj
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manually
|
||||||
|
- [Install inside a Python environemnt](doc/install_pyenv.md)
|
||||||
|
- [Install without Python environment](doc/install_on_the_system.md)
|
||||||
|
- [Build an executable with Pyinstaller](doc/build_with_pyinstaller.md)
|
||||||
|
- [Install as a drop-down for GNOME Shell with Argos](doc/argos.md)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
- Get help usage with `-h`, `--help` or `--usage` options, then run:
|
||||||
|
```bash
|
||||||
|
./silkaj <sub-command>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Will automatically request and post data on `duniter.org 10901` main Ğ1 node.
|
||||||
|
|
||||||
|
- Specify a custom node with `-p` option:
|
||||||
|
```bash
|
||||||
|
./silkaj <sub-command> -p <address>:<port>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- Currency information
|
||||||
|
- Show amount of account
|
||||||
|
- Send transaction
|
||||||
|
- Proof-of-Work difficulties: Σ diffi, Π diffi, match
|
||||||
|
- network information tab:
|
||||||
|
- endpoints, ip6, ip4, domain name and port. Handle nodes sharing same pubkey.
|
||||||
|
- pubkey, uid, if member.
|
||||||
|
- Proof-of-Work difficulties.
|
||||||
|
- generated block and median times.
|
||||||
|
- nodes versions.
|
||||||
|
- current block n°, hash and time.
|
||||||
|
- Issuers last ones or all: hash, gentime, mediantime
|
||||||
|
|
||||||
|
## Example
|
||||||
|
```bash
|
||||||
|
./silkaj network
|
||||||
|
|
||||||
|
### 20 peers ups, with 15 members and 5 non-members
|
||||||
|
|
||||||
|
| domain | ip4 | port | block | hash | gen_time | uid |member| pubkey |diffi| version |
|
||||||
|
|---------------------+----------------+------+-------+-------------+----------+-----------+------+--------+-----+----------|
|
||||||
|
| cgeek.fr | 88.174.120.187 | 9330| 41166 | 000027421F… | 15:59:00 | cgeek | yes | HnFcS… | 77 | 0.31.0b6 |
|
||||||
|
| mirror1.cgeek.fr | 88.174.120.187 | 9331| 41166 | 000027421F… | 15:59:00 | | no | 4jT89… | | 0.31.0b6 |
|
||||||
|
| mirror2.cgeek.fr | 88.174.120.187 | 9332| 41166 | 000027421F… | 15:59:00 | | no | AZ2JP… | | 0.31.0b6 |
|
||||||
|
| …t.duniter.inso.ovh | | 80| 41166 | 000027421F… | 15:59:00 | inso | yes | 8Fi1V… | 231 | 0.30.17 |
|
||||||
|
| peer.duniter.org | 51.255.197.83 | 8999| 41166 | 000027421F… | 15:59:00 | | no | BSmby… | | 0.30.17 |
|
||||||
|
| desktop.moul.re | 78.227.107.45 | 24723| 41166 | 000027421F… | 15:59:00 | moul | yes | J78bP… | 77 | 0.31.0b7 |
|
||||||
|
| misc.moul.re | 78.227.107.45 | 8999| 41166 | 000027421F… | 15:59:00 | moul | yes | J78bP… | 77 | 0.31.0b7 |
|
||||||
|
| test-net.duniter.fr | 88.189.14.141 | 9201| 41166 | 000027421F… | 15:59:00 | kimamila | yes | 5ocqz… | 385 | 0.31.0b3 |
|
||||||
|
| raspi3.cgeek.fr | 88.174.120.187 | 8999| 41166 | 000027421F… | 15:59:00 | | no | G3wQw… | | 0.31.0a9 |
|
||||||
|
| duniter.vincentux.fr| | 8999| 41166 | 000027421F… | 15:59:00 | vincentux | yes | 9bZEA… | | 0.30.17 |
|
||||||
|
| remuniter.cgeek.fr | 88.174.120.187 | 16120| 41166 | 000027421F… | 15:59:00 | remuniter…| yes | TENGx… | | 0.30.17 |
|
||||||
|
| | 88.163.42.58 | 34052| 41166 | 000027421F… | 15:59:00 | cler53 | yes | 4eDis… | 77 | 0.30.17 |
|
||||||
|
| suchard.si7v.fr | 163.172.252.3 | 8999| 41166 | 000027421F… | 15:59:00 | hacky | yes | DesHj… | 77 | 0.31.0a8 |
|
||||||
|
| | 87.91.122.123 | 9330| 41166 | 000027421F… | 15:59:00 | mmpio | yes | BmDso… | 154 | 0.31.0b3 |
|
||||||
|
| …er.help-web-low.fr | 151.80.40.148 | 8999| 41166 | 000027421F… | 15:59:00 | pafzedog | yes | XeBpJ… | 154 | 0.30.17 |
|
||||||
|
| | 87.90.32.15 | 8999| 41166 | 000027421F… | 15:59:00 | nay4 | yes | BnSRj… | 77 | 0.31.0a9 |
|
||||||
|
| duniter.modulix.net | 212.47.227.101 | 9330| 41166 | 000027421F… | 15:59:00 | modulix | yes | DeCip… | | 0.30.17 |
|
||||||
|
| | 88.174.120.187 | 33036| 41166 | 000027421F… | 15:59:00 | | no | GNRug… | | 0.31.0b7 |
|
||||||
|
| duniter.cco.ovh | 163.172.176.32 | 8999| 41166 | 000027421F… | 15:59:00 | charles | yes | DA4PY… | 77 | 0.31.0a8 |
|
||||||
|
| duniter.ktorn.com | 107.170.192.122| 8999| 41166 | 000027421F… | 15:59:00 | ktorn | yes | BR5DD… | 77 | 0.30.17 |
|
||||||
|
```
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
Silkaj is based on Python dependencies:
|
||||||
|
|
||||||
|
- [Tabulate](https://bitbucket.org/astanin/python-tabulate/overview): to display charts.
|
||||||
|
- [Commandlines](https://github.com/chrissimpkins/commandlines): to parse command and sub-commands.
|
||||||
|
- [PyNaCl](https://github.com/pyca/pynacl/): Cryptography (NaCl) library.
|
||||||
|
- [scrypt](https://bitbucket.org/mhallin/py-scrypt): scrypt key derivation function.
|
||||||
|
- [pyaes](https://github.com/ricmoo/pyaes): Pure-Python implementation of AES
|
||||||
|
|
||||||
|
### Names
|
||||||
|
I wanted to call that program:
|
||||||
|
- bamiyan
|
||||||
|
- margouillat
|
||||||
|
- lsociety
|
||||||
|
- cashmere
|
||||||
|
|
||||||
|
I finally called it `Silkaj` as `Silk` in esperanto.
|
|
@ -0,0 +1 @@
|
||||||
|
8558401de5f7a29a7e5d06829d24f8043aef20afa66e83dfc9c25c5bf7739424
|
|
@ -0,0 +1,17 @@
|
||||||
|
## Integrate it on a dropdown menu to the panel
|
||||||
|
Under GNOME Shell, with [Argos](https://github.com/p-e-w/argos) extension:
|
||||||
|
|
||||||
|
- [Install Argos](https://github.com/p-e-w/argos#installation)
|
||||||
|
- Put inside `~/.config/argos/silkaj.30s.sh`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
/path/to/silkaj/silkaj argos
|
||||||
|
```
|
||||||
|
|
||||||
|
Add execution premission:
|
||||||
|
```bash
|
||||||
|
chmod u+x ~/.config/argos/silkaj.30s.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Argos should the script and reload it every 30 seconds.
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Build with Pyinstaller
|
||||||
|
|
||||||
|
## Install Pyinstaller
|
||||||
|
```bash
|
||||||
|
pip install pyinstaller
|
||||||
|
```
|
||||||
|
|
||||||
|
If you are using Pyenv, don’t forget to save pyinstaller install:
|
||||||
|
```bash
|
||||||
|
pyenv rehash
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build
|
||||||
|
```bash
|
||||||
|
pyinstaller src/silkaj.py --hidden-import=_cffi_backend --hidden-import=_scrypt --onefile
|
||||||
|
```
|
||||||
|
|
||||||
|
You will found the exetuable file on `silkaj/dist` folder.
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Install Silkaj on the system
|
||||||
|
|
||||||
|
## Retrieve sources
|
||||||
|
Clone repository:
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/duniter/silkaj.git
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
You may install dependencies.
|
||||||
|
You could install all dependencies from `pip`.
|
||||||
|
If you choose to install from distribution packages, some dependencies could be missing.
|
||||||
|
You will have to install them with `pip`.
|
||||||
|
|
||||||
|
### From pip
|
||||||
|
```bash
|
||||||
|
sudo pip3 install -r requirements.txt
|
||||||
|
```
|
||||||
|
Use `pip` command if `pip3` is not present.
|
||||||
|
Upgrade `pip` adding `--upgrade pip` to previous command.
|
||||||
|
|
||||||
|
### From distributions package managers
|
||||||
|
#### Debian-like
|
||||||
|
```bash
|
||||||
|
sudo apt-get install python-tabulate python-ipaddress
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Fedora
|
||||||
|
```bash
|
||||||
|
sudo dnf install python-devel python-ipaddress python3-tabulate python3-pynacl python3-devel python-pyaes
|
||||||
|
```
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Install Silkaj on a Python environment
|
||||||
|
|
||||||
|
## Install Pyenv
|
||||||
|
|
||||||
|
### Install pyenv tools
|
||||||
|
```bash
|
||||||
|
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
### Handle shell modifications: point 2,3 and 4.
|
||||||
|
- [Follow pyenv install documentation](https://github.com/pyenv/pyenv#installation)
|
||||||
|
|
||||||
|
|
||||||
|
### Install latest Python version and create pyenv
|
||||||
|
```bash
|
||||||
|
pyenv install 3.6.0
|
||||||
|
pyenv shell 3.6.0
|
||||||
|
pyenv virtualenv silkaj-env
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install Silkaj
|
||||||
|
|
||||||
|
### Retrieve silkaj sources
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/duniter/silkaj.git
|
||||||
|
cd silkaj
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install dependencies and store them on pyenv environement
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt --upgrade
|
||||||
|
pyenv rehash
|
||||||
|
```
|
||||||
|
|
||||||
|
### Activate pyenv and run silkaj
|
||||||
|
```bash
|
||||||
|
pyenv activate silkaj-env
|
||||||
|
./silkaj
|
||||||
|
```
|
|
@ -0,0 +1,2 @@
|
||||||
|
.idea/
|
||||||
|
Thumbs.db
|
|
@ -0,0 +1,13 @@
|
||||||
|
# inspiré de : https://forum.duniter.org/t/doppler-gitlab/3183/30
|
||||||
|
# GITHUB_URL_AND_KEY should look like https://duniter-gitlab:TOKEN@github.com/chemin/vers/ton/depot/github
|
||||||
|
mirror_to_github:
|
||||||
|
script:
|
||||||
|
- git remote add github $GITHUB_URL_AND_KEY
|
||||||
|
- git config --global user.email "contact@duniter.org"
|
||||||
|
- git config --global user.name "Duniter"
|
||||||
|
- git push --force --mirror github
|
||||||
|
npm:
|
||||||
|
script:
|
||||||
|
- echo TODO
|
||||||
|
only:
|
||||||
|
tags
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Licence Ǧ1 ([fr](license/license_g1-fr-FR.rst)) ([en](license/license_g1-en.rst))
|
||||||
|
|
||||||
|
Dernière version : (consulter la licence)
|
||||||
|
|
||||||
|
// TODO : import depuis npm, version npm publié automatiquement selon les tags
|
|
@ -0,0 +1,78 @@
|
||||||
|
License Ğ1 - v0.2.5
|
||||||
|
===================
|
||||||
|
|
||||||
|
:date: 2017-08-21 16:59
|
||||||
|
:modified: 2018-01-24 19:20
|
||||||
|
|
||||||
|
**Money licensing and liability commitment.**
|
||||||
|
|
||||||
|
Any certification operation of a new member of Ğ1 must first be accompanied by the transmission of this license of the currency Ğ1 whose certifier must ensure that it has been studied, understood and accepted by the person who will be certified.
|
||||||
|
|
||||||
|
Money Ğ1
|
||||||
|
--------
|
||||||
|
|
||||||
|
Ğ1 occurs via a Universal Dividend (DU) for any human member, which is of the form:
|
||||||
|
|
||||||
|
* 1 DU per person per day
|
||||||
|
|
||||||
|
The amount of DU is identical each day until the next equinox, where the DU will then be reevaluated according to the formula:
|
||||||
|
|
||||||
|
* DU <sub>day</sub> (the following equinox) = DU <day>(equinox) + c² (M / N) (equinox) / (15778800 seconds)</day>
|
||||||
|
|
||||||
|
With as parameters:
|
||||||
|
|
||||||
|
* c = 4.88% / equinox
|
||||||
|
* UD (0) = 10.00 Ğ1
|
||||||
|
|
||||||
|
And as variables:
|
||||||
|
|
||||||
|
* _M_ the total monetary mass at the equinox
|
||||||
|
* _N_ the number of members at the equinox
|
||||||
|
|
||||||
|
Web of Trust Ğ1 (WoT Ğ1)
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
**Warning:** Certifying is not just about making sure you've met the person, it's ensuring that the community Ğ1 knows the certified person well enough and Duplicate account made by a person certified by you, or other types of problems (disappearance ...), by cross-checking that will reveal the problem if necessary.
|
||||||
|
|
||||||
|
When you are a member of Ğ1 and you are about to certify a new account:
|
||||||
|
|
||||||
|
**You are assured:**
|
||||||
|
|
||||||
|
1°) The person who declares to manage this public key (new account) and to have personally checked with him that this is the public key is sufficiently well known (not only to know this person visually) that you are about to certify.
|
||||||
|
|
||||||
|
2a°) To meet her physically to make sure that it is this person you know who manages this public key.
|
||||||
|
|
||||||
|
2b°) Remotely verify the public person / key link by contacting the person via several different means of communication, such as social network + forum + mail + video conference + phone (acknowledge voice).
|
||||||
|
|
||||||
|
Because if you can hack an email account or a forum account, it will be much harder to imagine hacking four distinct means of communication, and mimic the appearance (video) as well as the voice of the person .
|
||||||
|
|
||||||
|
However, the 2 °) is preferable to 3 °, whereas the 1 °) is always indispensable in all cases.
|
||||||
|
|
||||||
|
3 °) To have verified with the person concerned that he has indeed generated his Duniter account revocation document, which will enable him, if necessary, to cancel his account (in case of account theft, ID, an incorrectly created account, etc.).
|
||||||
|
|
||||||
|
**Abbreviated WoT rules:**
|
||||||
|
|
||||||
|
Each member has a stock of 100 possible certifications, which can only be issued at the rate of 1 certification / 5 days.
|
||||||
|
|
||||||
|
Valid for 2 months, certification for a new member is definitively adopted only if the certified has at least 4 other certifications after these 2 months, otherwise the entry process will have to be relaunched.
|
||||||
|
|
||||||
|
To become a new member of WoT Ğ1 therefore 5 certifications must be obtained at a distance < 5 of 80% of the WoT sentinels.
|
||||||
|
|
||||||
|
A member of the TdC Ğ1 is sentinel when he has received and issued at least Y [N] certifications where N is the number of members of the TdC and Y [N] = ceiling N ^ (1/5). Examples:
|
||||||
|
|
||||||
|
* For 1024 < N ≤ 3125 we have Y [N] = 5
|
||||||
|
* For 7776 < N ≤ 16807 we have Y [N] = 7
|
||||||
|
* For 59049 < N ≤ 100 000 we have Y [N] = 10
|
||||||
|
|
||||||
|
Once the new member is part of the WoT Ğ1 his certifications remain valid for 2 years.
|
||||||
|
|
||||||
|
To remain a member, you must renew your agreement regularly with your private key (every 12 months) and make sure you have at least 5 certifications valid after 2 years.
|
||||||
|
|
||||||
|
Software Ğ1 and license Ğ1
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
The software Ğ1 allowing users to manage their use of Ğ1 must transmit this license with the software and all the technical parameters of the currency Ğ1 and TdC Ğ1 which are entered in block 0 of Ğ1.
|
||||||
|
|
||||||
|
For more details in the technical details it is possible to consult directly the code of Duniter which is a free software and also the data of the blockchain Ğ1 by retrieving it via a Duniter instance or node Ğ1.
|
||||||
|
|
||||||
|
More information on the Duniter Team website [https://www.duniter.org](https://www.duniter.org)
|
|
@ -0,0 +1,90 @@
|
||||||
|
Licence Ğ1 - v0.2.5
|
||||||
|
===================
|
||||||
|
|
||||||
|
:date: 2017-04-04 12:59
|
||||||
|
:modified: 2018-01-24 19:20
|
||||||
|
|
||||||
|
**Licence de la monnaie et engagement de responsabilité.**
|
||||||
|
|
||||||
|
Toute opération de certification d'un nouveau membre de Ğ1 doit préalablement s'accompagner de la transmission de cette licence de la monnaie Ğ1 dont le certificateur doit s'assurer qu'elle a été étudiée, comprise et acceptée par la personne qui sera certifiée.
|
||||||
|
|
||||||
|
Tout événement de rencontre concernant Ğ1 devrait s'accompagner de la transmission de cette licence, qui peut être lue à haute voix, et transmise par tout moyen.
|
||||||
|
|
||||||
|
Toile de confiance Ğ1 (TdC Ğ1)
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
**Avertissement :** Certifier n'est pas uniquement s'assurer que vous avez rencontré la personne, c'est assurer à la communauté Ğ1 que vous connaissez suffisamment bien la personne certifiée et que vous saurez ainsi la contacter facilement, et être en mesure de repérer un double compte effectué par une personne certifiée par vous-même, ou d'autres types de problèmes (disparition...), en effectuant des recoupements qui permettront de révéler le problème le cas échéant.
|
||||||
|
|
||||||
|
**Conseils fortement recommandés**
|
||||||
|
|
||||||
|
Ne certifiez jamais seul, mais accompagné d'au moins un autre membre de la TdC Ğ1 afin d'éviter toute erreur de manipulation. En cas d'erreur, prévenez immédiatement d'autres membres de la TdC Ğ1.
|
||||||
|
|
||||||
|
Avant toute certification, assurez vous de vérifier si son compte (qu'il soit en cours de validation ou déjà membre) a déjà reçu une ou plusieurs certifications. Le cas échéant demandez des informations pour entrer en contact avec ces autres certifieurs afin de vérifier ensemble que vous connaissez bien la personne concernée par la création du nouveau compte, ainsi que la clé publique correspondante.
|
||||||
|
|
||||||
|
Vérifiez que vos contacts ont bien étudié et compris la licence Ğ1 à jour.
|
||||||
|
|
||||||
|
Si vous vous rendez compte qu'un certifieur effectif ou potentiel du compte concerné ne connaît pas la personne concernée, alertez immédiatement des experts du sujet au sein de vos connaissance de la TdC Ğ1, afin que la procédure de validation soit vérifiée par la TdC Ğ1.
|
||||||
|
|
||||||
|
Lorsque vous êtes membre de la TdC Ğ1 et que vous vous apprêtez à certifier un nouveau compte :
|
||||||
|
|
||||||
|
**Vous êtes vous assuré :**
|
||||||
|
|
||||||
|
1°) D'avoir bien vérifié avec la personne concernée qu'elle a bien généré son document Duniter de révocation de compte, qui lui permettra le cas échéant de pouvoir annuler son compte (cas d'un vol de compte, d'un changement de ID, d'un compte créé à tort etc.).
|
||||||
|
|
||||||
|
2°) De suffisamment bien connaître (pas seulement de la connaître "de visu") la personne qui déclare gérer cette clé publique (nouveau compte) et d'avoir personnellement vérifié avec elle qu'il s'agit bien de cette clé publique que vous vous apprêtez à certifier (voir les conseils fortement recommandés ci-dessus pour s'assurer de "bien connaître").
|
||||||
|
|
||||||
|
3a°) De la rencontrer physiquement pour vous assurer que c'est bien cette personne que vous connaissez qui gère cette clé publique.
|
||||||
|
|
||||||
|
3b°) Ou bien de vérifer à distance le lien personne / clé publique en contactant la personne par plusieurs moyens de communication différents, comme réseau social + forum + mail + vidéo conférence + téléphone (reconnaître la voix). Car si l'on peut pirater un compte mail ou un compte forum, il sera bien plus difficile d'imaginer pirater quatre moyens de communication distincts, et imiter l'apparence (vidéo) ainsi que la voix de la personne en plus.
|
||||||
|
|
||||||
|
Le 3a°) restant toutefois préférable au 3b°), tandis que le 1°) et 2°) est toujours indispensable dans tous les cas.
|
||||||
|
|
||||||
|
**Règles abrégées de la TdC :**
|
||||||
|
|
||||||
|
Chaque membre a un stock de 100 certifications possibles, qu'il ne peut émettre qu'au rythme de 1 certification / 5 jours.
|
||||||
|
|
||||||
|
Valable 2 mois, une certification pour un nouveau membre n'est définitivement adoptée que si le certifié possède au moins 4 autres certifications au bout de ces 2 mois, sinon le processus d'entrée devra être relancé.
|
||||||
|
|
||||||
|
Pour devenir un nouveau membre de la TdC Ğ1 il faut donc obtenir 5 certifications et ne pas se trouver à une distance < 5 de 80% des membres référents de la TdC.
|
||||||
|
|
||||||
|
Un membre de la TdC Ğ1 est membre référent lorsqu'il a reçu et émis au moins Y[N] certifications où N est le nombre de membres de la TdC et Y[N] = plafond N^(1/5). Exemples :
|
||||||
|
|
||||||
|
* Pour 1024 < N ≤ 3125 on a Y[N] = 5
|
||||||
|
* Pour 7776 < N ≤ 16807 on a Y[N] = 7
|
||||||
|
* pour 59049 < N ≤ 100 000 on a Y[N] = 10
|
||||||
|
|
||||||
|
Une fois que le nouveau membre est partie prenante de la TdC Ğ1 ses certifications restent valables 2 ans.
|
||||||
|
|
||||||
|
Pour rester membre il faut renouveler son accord régulièrement avec sa clé privée (tous les 12 mois) et s'assurer d'avoir toujours au moins 5 certifications valides au delà des 2 ans.
|
||||||
|
|
||||||
|
Monnaie Ğ1
|
||||||
|
----------
|
||||||
|
|
||||||
|
Ğ1 se produit via un Dividende Universel (DU) pour tout être humain membre de la Toile de Confiance Ğ1, qui est de la forme :
|
||||||
|
|
||||||
|
* 1 DU par personne et par jour
|
||||||
|
|
||||||
|
**Code de la monnaie Ğ1**
|
||||||
|
|
||||||
|
Le montant en Ğ1 du DU est identique chaque jour jusqu'au prochain équinoxe où le DU sera alors réévalué selon la formule (avec 1 jour = 86 400 secondes) :
|
||||||
|
|
||||||
|
* DUjour(équinoxe suivant) = DUjour(équinoxe) + c² (M/N)(équinoxe) / (182,625 jours)
|
||||||
|
|
||||||
|
Avec comme paramètres :
|
||||||
|
|
||||||
|
* c = 4,88% / équinoxe
|
||||||
|
* DU(0) = 10,00 Ğ1
|
||||||
|
|
||||||
|
Et comme variables :
|
||||||
|
|
||||||
|
* *M* la masse monétaire totale à l'équinoxe
|
||||||
|
* *N* le nombre de membres à l'équinoxe
|
||||||
|
|
||||||
|
Logiciels Ğ1 et licence Ğ1
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
Les logiciels Ğ1 permettant aux utilisateurs de gérer leur utilisation de Ğ1 doivent transmettre cette licence avec le logiciel ainsi que l'ensemble des paramètres techniques de la monnaie Ğ1 et de la TdC Ğ1 qui sont inscrits dans le bloc 0 de Ğ1.
|
||||||
|
|
||||||
|
Pour plus de précisions dans les détails techniques il est possible de consulter directement le code de Duniter qui est un logiciel libre ansi que les données de la blockchain Ğ1 en la récupérant via une instance (ou noeud) Duniter Ğ1.
|
||||||
|
|
||||||
|
Plus d'informations sur le site de l'équipe Duniter https://www.duniter.org
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"name": "licence-g1",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Licence de la Ǧ1",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@git.duniter.org:communication/licence-G1.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"licence",
|
||||||
|
"crypto-currency",
|
||||||
|
"monnaie",
|
||||||
|
"libre",
|
||||||
|
"June",
|
||||||
|
"G1",
|
||||||
|
"Ǧ1"
|
||||||
|
],
|
||||||
|
"author": "Duniter community",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
VERSION=$1
|
||||||
|
|
||||||
|
check_argument_specified() {
|
||||||
|
if [[ -z $VERSION ]]; then
|
||||||
|
error_message "You should specify a version number as argument"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_version_format() {
|
||||||
|
if [[ ! $VERSION =~ ^[0-9]+.[0-9]+.[0-9]+[0-9A-Za-z]*$ ]]; then
|
||||||
|
error_message "Wrong format version"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_branch() {
|
||||||
|
branch=`git rev-parse --abbrev-ref HEAD`
|
||||||
|
if [[ "$branch" != "master" ]]; then
|
||||||
|
error_message "Current branch should be 'master'"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
update_version() {
|
||||||
|
sed -i "s/SILKAJ_VERSION = \"silkaj.*\"/SILKAJ_VERSION = \"silkaj $VERSION\"/" src/constants.py
|
||||||
|
git diff
|
||||||
|
}
|
||||||
|
|
||||||
|
commit_tag() {
|
||||||
|
git commit src/constants.py -m "v$VERSION"
|
||||||
|
git tag "v$VERSION" -a -m "$VERSION"
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
if [[ -z $VIRTUAL_ENV ]]; then
|
||||||
|
error_message "Activate silkaj-env"
|
||||||
|
fi
|
||||||
|
exec_installed pyinstaller
|
||||||
|
pyinstaller src/silkaj.py --hidden-import=_cffi_backend --hidden-import=_scrypt --onefile
|
||||||
|
}
|
||||||
|
|
||||||
|
checksum() {
|
||||||
|
# Generate sha256 checksum file
|
||||||
|
exec_installed sha256sum
|
||||||
|
cd dist
|
||||||
|
sha256sum silkaj > silkaj_sha256sum
|
||||||
|
}
|
||||||
|
|
||||||
|
exec_installed() {
|
||||||
|
if [[ ! `command -v $1` ]]; then
|
||||||
|
error_message "'$1' is not install on your machine"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
error_message() {
|
||||||
|
echo $1
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
check_argument_specified
|
||||||
|
check_version_format
|
||||||
|
check_branch
|
||||||
|
update_version
|
||||||
|
commit_tag
|
||||||
|
build
|
||||||
|
checksum
|
||||||
|
error_message "Build and checksum can be found in 'dist' folder"
|
|
@ -0,0 +1,7 @@
|
||||||
|
setuptools
|
||||||
|
commandlines
|
||||||
|
ipaddress
|
||||||
|
tabulate
|
||||||
|
pynacl
|
||||||
|
scrypt
|
||||||
|
pyaes
|
|
@ -0,0 +1 @@
|
||||||
|
src/silkaj.py
|
|
@ -0,0 +1,201 @@
|
||||||
|
from tools import get_publickey_from_seed, b58_decode, xor_bytes, message_exit
|
||||||
|
from nacl import encoding
|
||||||
|
import nacl.hash
|
||||||
|
from scrypt import hash
|
||||||
|
import pyaes
|
||||||
|
from getpass import getpass
|
||||||
|
from os import path
|
||||||
|
from re import compile, search
|
||||||
|
|
||||||
|
|
||||||
|
def auth_method(cli_args):
|
||||||
|
if cli_args.contains_switches('auth-scrypt'):
|
||||||
|
return auth_by_scrypt(cli_args)
|
||||||
|
if cli_args.contains_switches('auth-seed'):
|
||||||
|
return auth_by_seed()
|
||||||
|
if cli_args.contains_switches('auth-file'):
|
||||||
|
return auth_by_auth_file(cli_args)
|
||||||
|
if cli_args.contains_switches('auth-wif'):
|
||||||
|
return auth_by_wif()
|
||||||
|
message_exit("Error: no authentication method")
|
||||||
|
|
||||||
|
|
||||||
|
def generate_auth_file(cli_args):
|
||||||
|
if cli_args.contains_definitions('file'):
|
||||||
|
file = cli_args.get_definition('file')
|
||||||
|
else:
|
||||||
|
file = "authfile"
|
||||||
|
seed = auth_method(cli_args)
|
||||||
|
with open(file, "w") as f:
|
||||||
|
f.write(seed)
|
||||||
|
# G1SMS:: Remove verbose text
|
||||||
|
#print("Authfile generated for the public key: ", get_publickey_from_seed(seed))
|
||||||
|
print(get_publickey_from_seed(seed))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def auth_by_auth_file(cli_args):
|
||||||
|
if cli_args.contains_definitions('file'):
|
||||||
|
file = cli_args.get_definition('file')
|
||||||
|
else:
|
||||||
|
file = "authfile"
|
||||||
|
if not path.isfile(file):
|
||||||
|
message_exit("Error: the file \"" + file + "\" does not exist")
|
||||||
|
with open(file) as f:
|
||||||
|
filetxt = f.read()
|
||||||
|
|
||||||
|
regex_seed = compile('^[0-9a-fA-F]{64}$')
|
||||||
|
regex_gannonce = compile('^pub: [1-9A-HJ-NP-Za-km-z]{43,44}\nsec: [1-9A-HJ-NP-Za-km-z]{88,90}.*$')
|
||||||
|
# Seed Format
|
||||||
|
if search(regex_seed, filetxt):
|
||||||
|
seed = filetxt[0:64]
|
||||||
|
# gannonce.duniter.org Format
|
||||||
|
elif search(regex_gannonce, filetxt):
|
||||||
|
private_key = filetxt.split("sec: ")[1].split("\n")[0]
|
||||||
|
seed = encoding.HexEncoder.encode(b58_decode(private_key))[0:64].decode("utf-8")
|
||||||
|
else:
|
||||||
|
message_exit("Error: the format of the file is invalid")
|
||||||
|
return seed
|
||||||
|
|
||||||
|
|
||||||
|
def auth_by_seed():
|
||||||
|
seed = input("Please enter your seed on hex format: ")
|
||||||
|
regex = compile('^[0-9a-fA-F]{64}$')
|
||||||
|
if not search(regex, seed):
|
||||||
|
message_exit("Error: the format of the seed is invalid")
|
||||||
|
return seed
|
||||||
|
|
||||||
|
|
||||||
|
def auth_by_scrypt(cli_args):
|
||||||
|
# G1SMS:: Accept salt & password from "cli_args"
|
||||||
|
if cli_args.contains_definitions('salt') and cli_args.contains_definitions('password'):
|
||||||
|
salt = cli_args.get_definition('salt')
|
||||||
|
password = cli_args.get_definition('password')
|
||||||
|
else:
|
||||||
|
salt = getpass.getpass("Please enter your Scrypt Salt (Secret identifier): ")
|
||||||
|
password = getpass.getpass("Please enter your Scrypt password (masked): ")
|
||||||
|
|
||||||
|
if cli_args.contains_definitions('n') and cli_args.contains_definitions('r') and cli_args.contains_definitions('p'):
|
||||||
|
n, r, p = cli_args.get_definition('n'), cli_args.get_definition('r'), cli_args.get_definition('p')
|
||||||
|
if n.isnumeric() and r.isnumeric() and p.isnumeric():
|
||||||
|
n, r, p = int(n), int(r), int(p)
|
||||||
|
if n <= 0 or n > 65536 or r <= 0 or r > 512 or p <= 0 or p > 32:
|
||||||
|
message_exit("Error: the values of Scrypt parameters are not good")
|
||||||
|
else:
|
||||||
|
message_exit("one of n, r or p is not a number")
|
||||||
|
else:
|
||||||
|
# G1SMS:: Remove text
|
||||||
|
#print("Using default values. Scrypt parameters not specified or wrong format")
|
||||||
|
n, r, p = 4096, 16, 1
|
||||||
|
#print("Scrypt parameters used: N: {0}, r: {1}, p: {2}".format(n, r, p))
|
||||||
|
|
||||||
|
return get_seed_from_scrypt(salt, password, n, r, p)
|
||||||
|
|
||||||
|
|
||||||
|
def auth_by_wif():
|
||||||
|
wif = input("Please enter your WIF or Encrypted WIF address: ")
|
||||||
|
|
||||||
|
regex = compile('^[1-9A-HJ-NP-Za-km-z]*$')
|
||||||
|
if not search(regex, wif):
|
||||||
|
message_exit("Error: the format of WIF is invalid")
|
||||||
|
|
||||||
|
wif_bytes = b58_decode(wif)
|
||||||
|
fi = wif_bytes[0:1]
|
||||||
|
|
||||||
|
if fi == b'\x01':
|
||||||
|
return get_seed_from_wifv1(wif)
|
||||||
|
elif fi == b'\x02':
|
||||||
|
password = getpass("Please enter the " +
|
||||||
|
"password of WIF (masked): ")
|
||||||
|
return get_seed_from_ewifv1(wif, password)
|
||||||
|
|
||||||
|
message_exit("Error: the format of WIF is invalid or unknown")
|
||||||
|
|
||||||
|
|
||||||
|
def get_seed_from_scrypt(salt, password, N=4096, r=16, p=1):
|
||||||
|
seed = hash(password, salt, N, r, p, 32)
|
||||||
|
seedhex = encoding.HexEncoder.encode(seed).decode("utf-8")
|
||||||
|
return seedhex
|
||||||
|
|
||||||
|
|
||||||
|
def get_seed_from_wifv1(wif):
|
||||||
|
regex = compile('^[1-9A-HJ-NP-Za-km-z]*$')
|
||||||
|
if not search(regex, wif):
|
||||||
|
message_exit("Error: the format of WIF is invalid")
|
||||||
|
|
||||||
|
wif_bytes = b58_decode(wif)
|
||||||
|
if len(wif_bytes) != 35:
|
||||||
|
message_exit("Error: the size of WIF is invalid")
|
||||||
|
|
||||||
|
checksum_from_wif = wif_bytes[-2:]
|
||||||
|
fi = wif_bytes[0:1]
|
||||||
|
seed = wif_bytes[1:-2]
|
||||||
|
seed_fi = wif_bytes[0:-2]
|
||||||
|
|
||||||
|
if fi != b'\x01':
|
||||||
|
message_exit("Error: It's not a WIF format")
|
||||||
|
|
||||||
|
# checksum control
|
||||||
|
checksum = nacl.hash.sha256(
|
||||||
|
nacl.hash.sha256(seed_fi, encoding.RawEncoder),
|
||||||
|
encoding.RawEncoder)[0:2]
|
||||||
|
if checksum_from_wif != checksum:
|
||||||
|
message_exit("Error: bad checksum of the WIF")
|
||||||
|
|
||||||
|
seedhex = encoding.HexEncoder.encode(seed).decode("utf-8")
|
||||||
|
return seedhex
|
||||||
|
|
||||||
|
|
||||||
|
def get_seed_from_ewifv1(ewif, password):
|
||||||
|
regex = compile('^[1-9A-HJ-NP-Za-km-z]*$')
|
||||||
|
if not search(regex, ewif):
|
||||||
|
message_exit("Error: the format of EWIF is invalid")
|
||||||
|
|
||||||
|
wif_bytes = b58_decode(ewif)
|
||||||
|
if len(wif_bytes) != 39:
|
||||||
|
message_exit("Error: the size of EWIF is invalid")
|
||||||
|
|
||||||
|
wif_no_checksum = wif_bytes[0:-2]
|
||||||
|
checksum_from_ewif = wif_bytes[-2:]
|
||||||
|
fi = wif_bytes[0:1]
|
||||||
|
salt = wif_bytes[1:5]
|
||||||
|
encryptedhalf1 = wif_bytes[5:21]
|
||||||
|
encryptedhalf2 = wif_bytes[21:37]
|
||||||
|
|
||||||
|
if fi != b'\x02':
|
||||||
|
message_exit("Error: It's not a EWIF format")
|
||||||
|
|
||||||
|
# Checksum Control
|
||||||
|
checksum = nacl.hash.sha256(
|
||||||
|
nacl.hash.sha256(wif_no_checksum, encoding.RawEncoder),
|
||||||
|
encoding.RawEncoder)[0:2]
|
||||||
|
if checksum_from_ewif != checksum:
|
||||||
|
message_exit("Error: bad checksum of EWIF address")
|
||||||
|
|
||||||
|
# SCRYPT
|
||||||
|
password = password.encode("utf-8")
|
||||||
|
scrypt_seed = hash(password, salt, 16384, 8, 8, 64)
|
||||||
|
derivedhalf1 = scrypt_seed[0:32]
|
||||||
|
derivedhalf2 = scrypt_seed[32:64]
|
||||||
|
|
||||||
|
# AES
|
||||||
|
aes = pyaes.AESModeOfOperationECB(derivedhalf2)
|
||||||
|
decryptedhalf1 = aes.decrypt(encryptedhalf1)
|
||||||
|
decryptedhalf2 = aes.decrypt(encryptedhalf2)
|
||||||
|
|
||||||
|
# XOR
|
||||||
|
seed1 = xor_bytes(decryptedhalf1, derivedhalf1[0:16])
|
||||||
|
seed2 = xor_bytes(decryptedhalf2, derivedhalf1[16:32])
|
||||||
|
seed = seed1+seed2
|
||||||
|
seedhex = encoding.HexEncoder.encode(seed).decode("utf-8")
|
||||||
|
|
||||||
|
# Password Control
|
||||||
|
salt_from_seed = nacl.hash.sha256(
|
||||||
|
nacl.hash.sha256(
|
||||||
|
b58_decode(get_publickey_from_seed(seedhex)),
|
||||||
|
encoding.RawEncoder),
|
||||||
|
encoding.RawEncoder)[0:4]
|
||||||
|
if salt_from_seed != salt:
|
||||||
|
message_exit("Error: bad Password of EWIF address")
|
||||||
|
|
||||||
|
return seedhex
|
|
@ -0,0 +1,88 @@
|
||||||
|
import webbrowser
|
||||||
|
import urllib
|
||||||
|
|
||||||
|
from sys import exit
|
||||||
|
from pydoc import pager
|
||||||
|
from tabulate import tabulate
|
||||||
|
|
||||||
|
from auth import auth_method
|
||||||
|
from tools import get_publickey_from_seed, message_exit, sign_document_from_seed
|
||||||
|
from network_tools import get_current_block, post_request
|
||||||
|
from constants import NO_MATCHING_ID
|
||||||
|
from wot import is_member, get_pubkey_from_id, get_pubkeys_from_id,\
|
||||||
|
get_uid_from_pubkey
|
||||||
|
|
||||||
|
|
||||||
|
def send_certification(ep, cli_args):
|
||||||
|
current_blk = get_current_block(ep)
|
||||||
|
certified_uid = cli_args.subsubcmd
|
||||||
|
certified_pubkey = get_pubkey_from_id(ep, certified_uid)
|
||||||
|
|
||||||
|
# Check that the id is present on the network
|
||||||
|
if (certified_pubkey is NO_MATCHING_ID):
|
||||||
|
message_exit(NO_MATCHING_ID)
|
||||||
|
|
||||||
|
# Display license and ask for confirmation
|
||||||
|
license_approval(current_blk["currency"])
|
||||||
|
|
||||||
|
# Authentication
|
||||||
|
seed = auth_method(cli_args)
|
||||||
|
|
||||||
|
# Check whether current user is member
|
||||||
|
issuer_pubkey = get_publickey_from_seed(seed)
|
||||||
|
issuer_id = get_uid_from_pubkey(ep, issuer_pubkey)
|
||||||
|
if not is_member(ep, issuer_pubkey, issuer_id):
|
||||||
|
message_exit("Current identity is not member.")
|
||||||
|
|
||||||
|
# Check if this certification is already present on the network
|
||||||
|
id_lookup = get_pubkeys_from_id(ep, certified_uid)[0]
|
||||||
|
for certifiers in id_lookup["uids"][0]["others"]:
|
||||||
|
if certifiers["pubkey"] == issuer_pubkey:
|
||||||
|
message_exit("Identity already certified by " + issuer_id)
|
||||||
|
|
||||||
|
# Certification confirmation
|
||||||
|
if not certification_confirmation(issuer_id, issuer_pubkey, certified_uid, certified_pubkey):
|
||||||
|
return
|
||||||
|
cert_doc = generate_certification_document(id_lookup, current_blk, issuer_pubkey, certified_uid)
|
||||||
|
cert_doc += sign_document_from_seed(cert_doc, seed) + "\n"
|
||||||
|
|
||||||
|
# Send certification document
|
||||||
|
post_request(ep, "wot/certify", "cert=" + urllib.parse.quote_plus(cert_doc))
|
||||||
|
print("Certification successfully sent.")
|
||||||
|
|
||||||
|
|
||||||
|
def license_approval(currency):
|
||||||
|
if currency != "g1":
|
||||||
|
return
|
||||||
|
language = input("In which language would you like to display Ğ1 license [en/fr]? ")
|
||||||
|
if (language == "en"):
|
||||||
|
if not webbrowser.open("https://duniter.org/en/get-g1/"):
|
||||||
|
pager(open("licence-G1/license/license_g1-en.rst").read())
|
||||||
|
else:
|
||||||
|
if not webbrowser.open("https://duniter.org/fr/wiki/licence-g1/"):
|
||||||
|
pager(open("licence-G1/license/license_g1-fr-FR.rst").read())
|
||||||
|
|
||||||
|
if (input("Do you approve Ğ1 license [yes/no]? ") != "yes"):
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def certification_confirmation(issuer_id, issuer_pubkey, certified_uid, certified_pubkey):
|
||||||
|
cert = list()
|
||||||
|
cert.append(["Cert", "From", "–>", "To"])
|
||||||
|
cert.append(["ID", issuer_id, "–>", certified_uid])
|
||||||
|
cert.append(["Pubkey", issuer_pubkey, "–>", certified_pubkey])
|
||||||
|
if input(tabulate(cert, tablefmt="fancy_grid") +
|
||||||
|
"\nDo you confirm sending this certification? [yes/no]: ") == "yes":
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def generate_certification_document(id_lookup, current_blk, issuer_pubkey, certified_uid):
|
||||||
|
return "Version: 10\n\
|
||||||
|
Type: Certification\n\
|
||||||
|
Currency: " + current_blk["currency"] + "\n\
|
||||||
|
Issuer: " + issuer_pubkey + "\n\
|
||||||
|
IdtyIssuer: " + id_lookup["pubkey"] + "\n\
|
||||||
|
IdtyUniqueID: " + certified_uid + "\n\
|
||||||
|
IdtyTimestamp: " + id_lookup["uids"][0]["meta"]["timestamp"] + "\n\
|
||||||
|
IdtySignature: " + id_lookup["uids"][0]["self"] + "\n\
|
||||||
|
CertTimestamp: " + str(current_blk["number"]) + "-" + current_blk["hash"] + "\n"
|
|
@ -0,0 +1,249 @@
|
||||||
|
from datetime import datetime
|
||||||
|
from time import sleep
|
||||||
|
from os import system, popen
|
||||||
|
from collections import OrderedDict
|
||||||
|
from tabulate import tabulate
|
||||||
|
from operator import itemgetter
|
||||||
|
|
||||||
|
from wot import get_uid_from_pubkey
|
||||||
|
from network_tools import discover_peers, get_request, best_node, get_current_block
|
||||||
|
from tools import convert_time, get_currency_symbol, message_exit
|
||||||
|
from constants import NO_MATCHING_ID
|
||||||
|
|
||||||
|
|
||||||
|
def currency_info(ep):
|
||||||
|
info_type = ["newcomers", "certs", "actives", "leavers", "excluded", "ud", "tx"]
|
||||||
|
i, info_data = 0, dict()
|
||||||
|
while (i < len(info_type)):
|
||||||
|
info_data[info_type[i]] = get_request(ep, "blockchain/with/" + info_type[i])["result"]["blocks"]
|
||||||
|
i += 1
|
||||||
|
current = get_current_block(ep)
|
||||||
|
system("clear")
|
||||||
|
print("Connected to node:", ep[best_node(ep, 1)], ep["port"],
|
||||||
|
"\nCurrent block number:", current["number"],
|
||||||
|
"\nCurrency name:", get_currency_symbol(current["currency"]),
|
||||||
|
"\nNumber of members:", current["membersCount"],
|
||||||
|
"\nMinimal Proof-of-Work:", current["powMin"],
|
||||||
|
"\nCurrent time:", convert_time(current["time"], "all"),
|
||||||
|
"\nMedian time:", convert_time(current["medianTime"], "all"),
|
||||||
|
"\nDifference time:", convert_time(current["time"] - current["medianTime"], "hour"),
|
||||||
|
"\nNumber of blocks containing: \
|
||||||
|
\n- new comers:", len(info_data["newcomers"]),
|
||||||
|
"\n- Certifications:", len(info_data["certs"]),
|
||||||
|
"\n- Actives (members updating their membership):", len(info_data["actives"]),
|
||||||
|
"\n- Leavers:", len(info_data["leavers"]),
|
||||||
|
"\n- Excluded:", len(info_data["excluded"]),
|
||||||
|
"\n- UD created:", len(info_data["ud"]),
|
||||||
|
"\n- transactions:", len(info_data["tx"]))
|
||||||
|
|
||||||
|
|
||||||
|
def match_pattern(pow, match='', p=1):
|
||||||
|
while pow > 0:
|
||||||
|
if pow >= 16:
|
||||||
|
match += "0"
|
||||||
|
pow -= 16
|
||||||
|
p *= 16
|
||||||
|
else:
|
||||||
|
match += "[0-" + hex(15 - pow)[2:].upper() + "]"
|
||||||
|
p *= pow
|
||||||
|
pow = 0
|
||||||
|
return match + '*', p
|
||||||
|
|
||||||
|
|
||||||
|
def power(nbr, pow=0):
|
||||||
|
while nbr >= 10:
|
||||||
|
nbr /= 10
|
||||||
|
pow += 1
|
||||||
|
return "{0:.1f} × 10^{1}".format(nbr, pow)
|
||||||
|
|
||||||
|
|
||||||
|
def difficulties(ep):
|
||||||
|
while True:
|
||||||
|
diffi = get_request(ep, "blockchain/difficulties")
|
||||||
|
levels = [OrderedDict((i, d[i]) for i in ("uid", "level")) for d in diffi["levels"]]
|
||||||
|
diffi["levels"] = levels
|
||||||
|
current = get_current_block(ep)
|
||||||
|
issuers, sorted_diffi = 0, sorted(diffi["levels"], key=itemgetter("level"), reverse=True)
|
||||||
|
for d in diffi["levels"]:
|
||||||
|
if d["level"] / 2 < current["powMin"]:
|
||||||
|
issuers += 1
|
||||||
|
d["match"] = match_pattern(d["level"])[0][:20]
|
||||||
|
d["Π diffi"] = power(match_pattern(d["level"])[1])
|
||||||
|
d["Σ diffi"] = d.pop("level")
|
||||||
|
system("clear")
|
||||||
|
print("Minimal Proof-of-Work: {0} to match `{1}`\nDifficulty to generate next block n°{2} for {3}/{4} nodes:\n{5}"
|
||||||
|
.format(current["powMin"], match_pattern(int(current["powMin"]))[0], diffi["block"], issuers, len(diffi["levels"]),
|
||||||
|
tabulate(sorted_diffi, headers="keys", tablefmt="orgtbl", stralign="center")))
|
||||||
|
sleep(5)
|
||||||
|
|
||||||
|
|
||||||
|
network_sort_keys = ["block", "member", "diffi", "uid"]
|
||||||
|
|
||||||
|
|
||||||
|
def set_network_sort_keys(some_keys):
|
||||||
|
global network_sort_keys
|
||||||
|
if some_keys.endswith(","):
|
||||||
|
message_exit("Argument 'sort' ends with a comma, you have probably inserted a space after the comma, which is incorrect.")
|
||||||
|
network_sort_keys = some_keys.split(",")
|
||||||
|
|
||||||
|
|
||||||
|
def get_network_sort_key(endpoint):
|
||||||
|
t = list()
|
||||||
|
for akey in network_sort_keys:
|
||||||
|
if akey == 'diffi' or akey == 'block' or akey == 'port':
|
||||||
|
t.append(int(endpoint[akey]) if akey in endpoint else 0)
|
||||||
|
else:
|
||||||
|
t.append(str(endpoint[akey]) if akey in endpoint else "")
|
||||||
|
return tuple(t)
|
||||||
|
|
||||||
|
|
||||||
|
def network_info(ep, discover):
|
||||||
|
rows, columns = popen('stty size', 'r').read().split()
|
||||||
|
# print(rows, columns) # debug
|
||||||
|
wide = int(columns)
|
||||||
|
if wide < 146:
|
||||||
|
message_exit("Wide screen need to be larger than 146. Current wide: " + wide)
|
||||||
|
# discover peers
|
||||||
|
# and make sure fields are always ordered the same
|
||||||
|
endpoints = [OrderedDict((i, p.get(i, None)) for i in ("domain", "port", "ip4", "ip6", "pubkey")) for p in discover_peers(ep, discover)]
|
||||||
|
# Todo : renommer endpoints en info
|
||||||
|
diffi = get_request(ep, "blockchain/difficulties")
|
||||||
|
i, members = 0, 0
|
||||||
|
print("Getting informations about nodes:")
|
||||||
|
while (i < len(endpoints)):
|
||||||
|
print("{0:.0f}%".format(i/len(endpoints) * 100, 1), end=" ")
|
||||||
|
best_ep = best_node(endpoints[i], 0)
|
||||||
|
print(best_ep if best_ep is None else endpoints[i][best_ep], end=" ")
|
||||||
|
print(endpoints[i]["port"])
|
||||||
|
try:
|
||||||
|
endpoints[i]["uid"] = get_uid_from_pubkey(ep, endpoints[i]["pubkey"])
|
||||||
|
if endpoints[i]["uid"] is NO_MATCHING_ID:
|
||||||
|
endpoints[i]["uid"] = None
|
||||||
|
else:
|
||||||
|
endpoints[i]["member"] = "yes"
|
||||||
|
members += 1
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if endpoints[i].get("member") is None:
|
||||||
|
endpoints[i]["member"] = "no"
|
||||||
|
endpoints[i]["pubkey"] = endpoints[i]["pubkey"][:5] + "…"
|
||||||
|
# Todo: request difficulty from node point of view: two nodes with same pubkey id could be on diffrent branches and have different difficulties
|
||||||
|
# diffi = get_request(endpoints[i], "blockchain/difficulties") # super long, doit être requetté uniquement pour les nœuds d’une autre branche
|
||||||
|
for d in diffi["levels"]:
|
||||||
|
if endpoints[i].get("uid") is not None:
|
||||||
|
if endpoints[i]["uid"] == d["uid"]:
|
||||||
|
endpoints[i]["diffi"] = d["level"]
|
||||||
|
if len(endpoints[i]["uid"]) > 10:
|
||||||
|
endpoints[i]["uid"] = endpoints[i]["uid"][:9] + "…"
|
||||||
|
current_blk = get_current_block(endpoints[i])
|
||||||
|
if current_blk is not None:
|
||||||
|
endpoints[i]["gen_time"] = convert_time(current_blk["time"], "hour")
|
||||||
|
if wide > 171:
|
||||||
|
endpoints[i]["mediantime"] = convert_time(current_blk["medianTime"], "hour")
|
||||||
|
if wide > 185:
|
||||||
|
endpoints[i]["difftime"] = convert_time(current_blk["time"] - current_blk["medianTime"], "hour")
|
||||||
|
endpoints[i]["block"] = current_blk["number"]
|
||||||
|
endpoints[i]["hash"] = current_blk["hash"][:10] + "…"
|
||||||
|
endpoints[i]["version"] = get_request(endpoints[i], "node/summary")["duniter"]["version"]
|
||||||
|
if endpoints[i].get("domain") is not None and len(endpoints[i]["domain"]) > 20:
|
||||||
|
endpoints[i]["domain"] = "…" + endpoints[i]["domain"][-20:]
|
||||||
|
if endpoints[i].get("ip6") is not None:
|
||||||
|
if wide < 156:
|
||||||
|
endpoints[i].pop("ip6")
|
||||||
|
else:
|
||||||
|
endpoints[i]["ip6"] = endpoints[i]["ip6"][:8] + "…"
|
||||||
|
i += 1
|
||||||
|
system("clear")
|
||||||
|
print(len(endpoints), "peers ups, with", members, "members and", len(endpoints) - members, "non-members at", datetime.now().strftime("%H:%M:%S"))
|
||||||
|
endpoints = sorted(endpoints, key=get_network_sort_key)
|
||||||
|
print(tabulate(endpoints, headers="keys", tablefmt="orgtbl", stralign="center"))
|
||||||
|
|
||||||
|
|
||||||
|
def list_issuers(ep, nbr, last):
|
||||||
|
current_blk = get_current_block(ep)
|
||||||
|
current_nbr = current_blk["number"]
|
||||||
|
if nbr == 0:
|
||||||
|
nbr = current_blk["issuersFrame"]
|
||||||
|
url = "blockchain/blocks/" + str(nbr) + "/" + str(current_nbr - nbr + 1)
|
||||||
|
blocks, list_issuers, j = get_request(ep, url), list(), 0
|
||||||
|
issuers_dict = dict()
|
||||||
|
while j < len(blocks):
|
||||||
|
issuer = OrderedDict()
|
||||||
|
issuer["pubkey"] = blocks[j]["issuer"]
|
||||||
|
if last or nbr <= 30:
|
||||||
|
issuer["block"] = blocks[j]["number"]
|
||||||
|
issuer["gentime"] = convert_time(blocks[j]["time"], "hour")
|
||||||
|
issuer["mediantime"] = convert_time(blocks[j]["medianTime"], "hour")
|
||||||
|
issuer["hash"] = blocks[j]["hash"][:10]
|
||||||
|
issuers_dict[issuer["pubkey"]] = issuer
|
||||||
|
list_issuers.append(issuer)
|
||||||
|
j += 1
|
||||||
|
for pubkey in issuers_dict.keys():
|
||||||
|
issuer = issuers_dict[pubkey]
|
||||||
|
uid = get_uid_from_pubkey(ep, issuer["pubkey"])
|
||||||
|
for issuer2 in list_issuers:
|
||||||
|
if issuer2.get("pubkey") is not None and issuer.get("pubkey") is not None and \
|
||||||
|
issuer2["pubkey"] == issuer["pubkey"]:
|
||||||
|
issuer2["uid"] = uid
|
||||||
|
issuer2.pop("pubkey")
|
||||||
|
system("clear")
|
||||||
|
print("Issuers for last {0} blocks from block n°{1} to block n°{2}".format(nbr, current_nbr - nbr + 1, current_nbr), end=" ")
|
||||||
|
if last or nbr <= 30:
|
||||||
|
sorted_list = sorted(list_issuers, key=itemgetter("block"), reverse=True)
|
||||||
|
print("\n{0}".format(tabulate(sorted_list, headers="keys", tablefmt="orgtbl", stralign="center")))
|
||||||
|
else:
|
||||||
|
i, list_issued = 0, list()
|
||||||
|
while i < len(list_issuers):
|
||||||
|
j, found = 0, 0
|
||||||
|
while j < len(list_issued):
|
||||||
|
if list_issued[j].get("uid") is not None and \
|
||||||
|
list_issued[j]["uid"] == list_issuers[i]["uid"]:
|
||||||
|
list_issued[j]["blocks"] += 1
|
||||||
|
found = 1
|
||||||
|
break
|
||||||
|
j += 1
|
||||||
|
if found == 0:
|
||||||
|
issued = OrderedDict()
|
||||||
|
issued["uid"] = list_issuers[i]["uid"]
|
||||||
|
issued["blocks"] = 1
|
||||||
|
list_issued.append(issued)
|
||||||
|
i += 1
|
||||||
|
i = 0
|
||||||
|
while i < len(list_issued):
|
||||||
|
list_issued[i]["percent"] = list_issued[i]["blocks"] / nbr * 100
|
||||||
|
i += 1
|
||||||
|
sorted_list = sorted(list_issued, key=itemgetter("blocks"), reverse=True)
|
||||||
|
print("from {0} issuers\n{1}".format(len(list_issued),
|
||||||
|
tabulate(sorted_list, headers="keys", tablefmt="orgtbl", floatfmt=".1f", stralign="center")))
|
||||||
|
|
||||||
|
|
||||||
|
def argos_info(ep):
|
||||||
|
info_type = ["newcomers", "certs", "actives", "leavers", "excluded", "ud", "tx"]
|
||||||
|
pretty_names = {'g1': 'Ğ1', 'gtest': 'Ğtest'}
|
||||||
|
i, info_data = 0, dict()
|
||||||
|
while (i < len(info_type)):
|
||||||
|
info_data[info_type[i]] = get_request(ep, "blockchain/with/" + info_type[i])["result"]["blocks"]
|
||||||
|
i += 1
|
||||||
|
current = get_current_block(ep)
|
||||||
|
pretty = current["currency"]
|
||||||
|
if current["currency"] in pretty_names:
|
||||||
|
pretty = pretty_names[current["currency"]]
|
||||||
|
print(pretty, "|")
|
||||||
|
print("---")
|
||||||
|
href = 'href=http://%s:%s/' % (ep[best_node(ep, 1)], ep["port"])
|
||||||
|
print("Connected to node:", ep[best_node(ep, 1)], ep["port"], "|", href,
|
||||||
|
"\nCurrent block number:", current["number"],
|
||||||
|
"\nCurrency name:", get_currency_symbol(current["currency"]),
|
||||||
|
"\nNumber of members:", current["membersCount"],
|
||||||
|
"\nMinimal Proof-of-Work:", current["powMin"],
|
||||||
|
"\nCurrent time:", convert_time(current["time"], "all"),
|
||||||
|
"\nMedian time:", convert_time(current["medianTime"], "all"),
|
||||||
|
"\nDifference time:", convert_time(current["time"] - current["medianTime"], "hour"),
|
||||||
|
"\nNumber of blocks containing… \
|
||||||
|
\n-- new comers:", len(info_data["newcomers"]),
|
||||||
|
"\n-- Certifications:", len(info_data["certs"]),
|
||||||
|
"\n-- Actives (members updating their membership):", len(info_data["actives"]),
|
||||||
|
"\n-- Leavers:", len(info_data["leavers"]),
|
||||||
|
"\n-- Excluded:", len(info_data["excluded"]),
|
||||||
|
"\n-- UD created:", len(info_data["ud"]),
|
||||||
|
"\n-- transactions:", len(info_data["tx"]))
|
|
@ -0,0 +1,5 @@
|
||||||
|
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"
|