Merge branch 'master' of https://git.p2p.legal/axiom-team/ssb-g1like into dev-fred

This commit is contained in:
qo-op 2020-03-15 04:18:03 +01:00
commit 46fe548d8a
8 changed files with 162 additions and 173 deletions

BIN
doc/cesium-dunikey-800.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
doc/process-likes-g1tx.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 KiB

View File

@ -16,14 +16,7 @@
# INSTALL requirements
[[ ! $(which base58) ]] && sudo apt install build-essential base58 -y
# INSTALL Cargo
if [[ ! $(which cargo) ]]; then
curl https://sh.rustup.rs -sSf | sh
PATH=$PATH:~/.cargo/env
source $HOME/.cargo/env
fi
# INSTALL silkaj
# INSTALL Silkaj, CLI for Duniter
if [[ ! $(which silkaj) ]]; then
echo "INSTALL silkaj"
sudo apt update || true
@ -31,6 +24,57 @@ if [[ ! $(which silkaj) ]]; then
echo 'PATH=$PATH:.local/bin' >> ~/.bashrc && source ~/.bashrc
fi
# Install ScuttleButt
if [[ ! $(which sbot) ]]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
source ~/.bashrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install --lts
sudo apt install libtool autoconf -y
npm install sodium-native ssb-backlinks
sudo npm install -g ssb-server
echo "Adresse DNS de votre Pub SSB? hostname.yourdomain.tld"
read EXTERNAL
mkdir -p ~/.ssb
cat > ~/.ssb/config <<EOF
{
"connections": {
"incoming": {
"net": [
{
"scope": "public", "external": ["$EXTERNAL"], "transform": "shs", "port": 8008
},
{ "scope": "private", "transform": "shs", "port": 8008, "host": "127.0.0.1" }
]
},
"outgoing": {
"net": [
{
"transform": "shs"
}
]
}
}
}
EOF
cat > ~/run-ssb-PUB_$EXTERNAL.sh <<EOF
#!/bin/bash
while true; do
ssb-server start --host $EXTERNAL
done
EOF
chmod 755 ~/run-ssb-PUB_$EXTERNAL.sh
~/run-ssb-PUB_$EXTERNAL.sh &
fi
# INSTALL sbotc
if [[ ! $(which sbotc) ]]; then
sudo apt install libsodium-dev jq -y
@ -45,6 +89,41 @@ fi
####################### G1 SSB ACCOUNT MANAGER ############################################
###########################################################################################
# If user already has an SSB account, we generate Duniter secret key from SSB secret key
if [[ -f ~/.ssb/secret ]]; then
ssbpub=$(cat ~/.ssb/secret | grep public\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g)
ssbpriv=$(cat ~/.ssb/secret | grep private\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g)
g1pub=$(echo $ssbpub | base64 -d | base58)
g1priv=$(echo $ssbpriv | base64 -d | base58)
cat > ~/.ssb/secret.dunikey <<EOF
Type: PubSec
Version: 1
pub: $g1pub
sec: $g1priv
EOF
# If user doesn't have an SSB account, we create one
else
mkdir -p ~/.ssb
echo "WELCOME CREATING YOUR G1 SSB ACCOUNT !!!"
echo "CHOOSE YOU LOGIN or LEAVE BLANK & HIT ENTER FOR AUTO GENERATION"
read salt
[[ $salt != "" ]] && echo "PASSWORD?" && read pepper && [[ $pepper == "" ]] && exit
# INSTALL Cargo
if [[ ! $(which cargo) ]]; then
curl https://sh.rustup.rs -sSf | sh
PATH=$PATH:~/.cargo/env
source $HOME/.cargo/env
fi
# Install DUP-Mnemonic
if [[ ! $(which dup-mnemonic) ]]; then
@ -55,15 +134,6 @@ if [[ ! $(which dup-mnemonic) ]]; then
sudo cp target/release/dup-mnemonic /usr/local/bin
fi
# CHECK SSB ~/.ssb/secret
if [[ ! -f ~/.ssb/secret ]]; then
mkdir -p ~/.ssb
echo "WELCOME CREATING YOUR G1 SSB ACCOUNT !!!"
echo "CHOOSE YOU LOGIN or LEAVE BLANK & HIT ENTER FOR AUTO GENERATION"
read salt
[[ $salt != "" ]] && echo "PASSWORD?" && read pepper && [[ $pepper == "" ]] && exit
# GENERATE MNEMONIC KEY: 9 MOTS
if [[ $salt == "" ]]; then
declare -a makeyarray
@ -80,7 +150,7 @@ echo "CREDENTIAL: $salt / $pepper"
python3 ./key_create_dunikey.py "$salt" "$pepper"
mv ./.secret.dunikey ~/.ssb/secret.dunikey
# CREATE
# CREATE SSB secret
pub=$(cat ~/.ssb/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
priv=$(cat ~/.ssb/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
ssbpub=$(echo $pub | base58 -d | base64)
@ -105,23 +175,6 @@ cat > ~/.ssb/secret <<EOF
EOF
else
# CREATE ~/.ssb/secret.dunikey
ssbpub=$(cat ~/.ssb/secret | grep public\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g)
ssbpriv=$(cat ~/.ssb/secret | grep private\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g)
g1pub=$(echo $ssbpub | base64 -d | base58)
g1priv=$(echo $ssbpriv | base64 -d | base58)
cat > ~/.ssb/secret.dunikey <<EOF
Type: PubSec
Version: 1
pub: $g1pub
sec: $g1priv
EOF
fi
@ -129,3 +182,5 @@ echo -e "Installation complete"
exit 0

View File

@ -1,133 +0,0 @@
#!/bin/bash
################################################################################
# Authors:
# [@cel](@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519)
# [@Fred](@9BbJwPDjcyIqrOUPNn0nJZBduWdIrpMk3Cjz5MP361s=.ed25519)
# [@Boris](@l5nYExWYIgDLV6BYHOJPoI97jIUyTdSm8CTLpQ0XeOg=.ed25519)
# Version: 1.0
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
###########################################################################################
# ADD G1 Layer 10 LOVE to message writer you like !
# INSTALL silkaj sbotc
# PREVENT DOUBLE PAYEMENT
############################################################################################
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' ]
}
# INSTALL silkaj
if ! fn_exists silkaj; then
echo "INSTALL silkaj"
sudo apt-get update -y || true
sudo apt install python3-pip python3-setuptools python3-wheel -y && pip3 install silkaj --user
echo 'PATH=$PATH:.local/bin' >> ~/.bashrc && source ~/.bashrc
fi
# INSTALL build-essential
if ! dpkg -s build-essential; then
sudo apt install build-essential -y
fi
# INSTALL sbotc
if ! fn_exists sbotc; then
sudo apt install libsodium-dev jq -y
git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc
cd sbotc
make
sudo make install
fi
###########################################################################################
####################### G1 SSB ACCOUNT MANAGER ############################################
###########################################################################################
# If user already has an SSB account, we generate Duniter secret key from SSB secret key
if [[ -f ~/.ssb/secret ]]; then
ssbpub=$(cat ~/.ssb/secret | grep public\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g)
ssbpriv=$(cat ~/.ssb/secret | grep private\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g)
g1pub=$(echo $ssbpub | base64 -d | base58)
g1priv=$(echo $ssbpriv | base64 -d | base58)
cat > ~/.ssb/secret.dunikey <<EOF
Type: PubSec
Version: 1
pub: $g1pub
sec: $g1priv
EOF
# If user doesn't have an SSB account, we create one
else
mkdir -p ~/.ssb
echo "WELCOME CREATING YOUR G1 SSB ACCOUNT !!!"
echo "CHOOSE YOU LOGIN or LEAVE BLANK & HIT ENTER FOR AUTO GENERATION"
read salt
[[ $salt != "" ]] && echo "PASSWORD?" && read pepper && [[ $pepper == "" ]] && exit
# Install DUP-Mnemonic
if ! fn_exists dup-mnemonic; then
cd /tmp
git clone https://git.duniter.org/tools/dup-mnemonic-rs
cd dup-mnemonic-rs
cargo build --release
sudo cp target/release/dup-mnemonic /usr/local/bin
fi
# GENERATE MNEMONIC KEY: 9 MOTS
if [[ $salt == "" ]]; then
declare -a makeyarray
makeyarray=($(dup-mnemonic -l $lang))
# LOGIN (=SALT) 6 MOTS
salt="${makeyarray[0]} ${makeyarray[1]} ${makeyarray[2]} ${makeyarray[3]} ${makeyarray[4]} ${makeyarray[5]}"
# PASS (=PEPPER) 3 MOTS
pepper="${makeyarray[6]} ${makeyarray[7]} ${makeyarray[8]}"
fi
echo "........."
echo "CREDENTIAL: $salt / $pepper"
# CREATE ~/.ssb/secret.dunikey
python3 ./key_create_dunikey.py "$salt" "$pepper"
mv ./.secret.dunikey ~/.ssb/secret.dunikey
# CREATE SSB secret
pub=$(cat ~/.ssb/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
priv=$(cat ~/.ssb/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
ssbpub=$(echo $pub | base58 -d | base64)
ssbpriv=$(echo $priv | base58 -d | base64)
cat > ~/.ssb/secret <<EOF
# This secret is related to your G1Wallet - https://cesium.app
# silkaj balance $pub
# ID (salt): $salt / Pass: $pepper
# THIS KEY IS YOURS! REMIND IT AND KEEP IT SAFE AS A REAL WALLET
# chmod 400 ~/.zen/secret
{
"curve": "ed25519",
"public": "$ssbpub.ed25519",
"private": "$ssbpriv.ed25519",
"id": "@$ssbpub.ed25519"
}
# WARNING! It's vital that you DO NOT edit OR share your secret name
# instead, share your public name
# your SSB public name: @$ssbpub.ed25519
EOF
fi

View File

@ -20,7 +20,7 @@ ssbpub=$(cat ~/.ssb/secret | grep public\" | cut -d ' ' -f 4 | cut -d '.' -f 1 |
#### CHECK LIKE AND SEND LOVE
# Let's get G1 account balance
echo ""
echo "Welcome G1/SSB Astroport Pioneer!"
echo "Welcome to the G1 SSB like microdonation system!"
echo "
MMMMMMMMMMMMMNk;'cdxxd:,c0WMMMMMMMMMMMMM
MMMMMMMMMMMMMNx,. .;kWMMMMMMMMMMMMM
@ -102,11 +102,16 @@ process_msg() {
target_id=$(printf %s "$msg" | jq -r '.value?.content?.vote?.link') || return 1
target_msg=$(sbotc -e get "$target_id") || return 1
target_author=$(printf %s "$target_msg" | jq -r .author) || return 1
author_s_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$target_author"'", "content":{"type":"about", "about": "'"$target_author"'"}}}}]}' | jq .value?.content?.name | grep -v null | tail -n 1)
root_id=$(printf %s "$target_msg" | jq -r .content?.root) || return 1
[[ $root_id == "null" ]] && root_id=$target_id
g1_author=$(echo $target_author | cut -d '.' -f 1 | cut -d '@' -f2 | base64 -d | base58)
msg_excerpt=$(printf %s "$target_msg" | jq -r .content?.text | head -n 10) || return 1
}
bold=$(tput bold)
normal=$(tput sgr0)
sbotc query.read '{"query":[{"$filter":{"value":{"author":"'"$self"'","content":{"type":"vote", "vote":{"expression":"Like"}},"timestamp":{"$gt":'"$last_ts"'}}}}]}' | while read -r msg
do
if ! ts=$(printf %s "$msg" | jq -r .value.timestamp)
@ -127,14 +132,32 @@ do
printf 'Unable to process message %s\n' "$msg_id" >&2
exit 1
fi
printf 'Message: %s ( Author: %s )\n' "$target_id" "$target_author"
echo ""
echo "================================================================"
printf "Let's thank ${bold}%s ${normal}for their message: \n" "$author_s_name"
echo "================================================================"
printf "%s" "$msg_excerpt"
echo ""
echo "----------------------------------------------------------------"
if [[ $g1_author != $g1pub ]]; then
sleep 3
#printf '%s\n' "silkaj -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD 0.1 --comment _SSB:LIKE:$target_id"
#### SEND 10 LOVE = 0.1 DU to $g1_author wallet
silkaj -p "$duniter_server" -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD 0.1 --comment "_SSB:LIKE:$target_id" -y 2>/dev/null
#### WRITE RESPONSE MESSAGE
<<<<<<< HEAD
sbotc publish '{"type":"post","text":"Thanks for this post ; I have just sent you G1 libre money. Get code from [https://git.p2p.legal/Axiom-Team/ssb-g1like](https://git.p2p.legal/Axiom-Team/ssb-g1like). Access your wallet with [Cesium](https://cesium.app).", "branch": "'"$target_id"'", "root": "'"$root_id"'"}' 2>&1>/dev/null
=======
sbotc publish '{"type":"post","text":"Thanks for this post ; I have just sent you G1 libre money. Use it with [Cesium](https://cesium.app). Get it from [https://git.p2p.legal/Axiom-Team/ssb-g1like](https://git.p2p.legal/Axiom-Team/ssb-g1like) ", "branch": "'"$target_id"'", "root": "'"$root_id"'"}' 2>&1>/dev/null
#printf "0.1 G1UD sent to %s!\n" "$author_s_name"
#echo "----------------------------------------------------------------"
echo ""
echo ""
>>>>>>> 8407b404a0b2257457a0a15acb1b3b17784ae8a1
sleep 20 # DO NOT OVER CHARGE DUNITER
else
echo "I LIKE MY MESSAGE $target_id"
@ -146,3 +169,30 @@ do
exit 1
fi
done
<<<<<<< HEAD
=======
#######################################################################
## SCAN G1 BLOCKCHAIN FOR INCOMING TX
#######################################################################
EVERY=1
TIMEBEFORE=$(date --date="-$EVERY minutes" +"%s")
TIMESTAMP=$(date +"%s")
#log "GETTING last $EVERY mn TX : https://duniter-g1.p2p.legal/tx/history/$g1pub/times/$TIMEBEFORE/$TIMESTAMP"
json=$(curl -s https://$duniter_server/tx/history/$g1pub/times/$TIMEBEFORE/$TIMESTAMP)
pending_tx=$(printf %s "$json" | jq '.history.pending')
pending_tx_comments==$(printf %s "$pending_tx" | jq '.[].comment')
printf %s "$pending_tx_comments" > /tmp/zenfontain.g1tx.txt
#while read txincmd
#do
# export $txincmd
# log "$g1pub TX IN PENDING !! COMMENT = " $txincmd
#
# # We have to check if [].issuers.0 != $g1pub
# # or else it will publish the following message each time we SEND a transaction
#
# #sbotc publish '{"type":"post","text":"I am receiving G1 on my SSB Wallet $g1pub"}'
# done < /tmp/zenfontain.g1tx.txt
>>>>>>> 8407b404a0b2257457a0a15acb1b3b17784ae8a1

View File

@ -35,11 +35,28 @@ The Ğ1 currency originated in called France, so the main part of the fun happen
The economy is still in its infancy, but you can already [book a reservation in a B&B](https://www.gchange.fr/#/app/market/lg?last&category=cat67&type=offer).
An other way to spend your Ğ1 is use it with this micro-donation system.
An other way to spend your Ğ1 is use it with this micro-donation system:
![](https://git.p2p.legal/axiom-team/ssb-g1like/raw/dev-boris/doc/process-likes-g1tx.gif)
## An SSB user sent you Ğ1? Here is how to claim it:
First, you need to get your Duniter secret key from your SSB secret key.
```
chmod +x secret2dunikey.sh
./secret2dunikey.sh
```
Then, all you need to do is connect to a Duniter client, like [Cesium](https://cesium.app/), using the generated ~/.ssb/secret.dunikey
On Cesium homescreen, click "**Other methods**" and choose "**Keychain file**" :
![Cesium authentification](https://git.p2p.legal/axiom-team/ssb-g1like/raw/dev-boris/doc/cesium-other-methods-800.png)
Then, browse your filesystem to select your Duniter secret key stored in ~/.ssb/secret.dunikey :
![Cesium log with keychain file](https://git.p2p.legal/axiom-team/ssb-g1like/raw/dev-boris/doc/cesium-dunikey-800.png)

0
secret2dunikey.sh Normal file → Executable file
View File