diff options
author | epochqwert <epoch@hacking.allowed.org> | 2018-12-19 19:33:37 +0000 |
---|---|---|
committer | epochqwert <epoch@hacking.allowed.org> | 2018-12-19 19:33:37 +0000 |
commit | 36f7747780ea5f459e17f34c42d646abff6e6dbc (patch) | |
tree | a72a0c3f6fa918323b37bff7da047c08a8bdb9a4 /bin | |
parent | ff822dd2295faa2e3fce3fe2bde391c5a1ad53e7 (diff) | |
download | segfault_home-36f7747780ea5f459e17f34c42d646abff6e6dbc.tar.gz segfault_home-36f7747780ea5f459e17f34c42d646abff6e6dbc.zip |
updated scripts, and xchg stuff added
Diffstat (limited to 'bin')
-rw-r--r-- | bin/rates | 24 | ||||
-rwxr-xr-x | bin/xchg.buy | 89 | ||||
-rwxr-xr-x | bin/xchg.getdoublerate | 3 | ||||
-rwxr-xr-x | bin/xchg.getrate | 3 | ||||
-rwxr-xr-x | bin/xchg.getrates | 3 | ||||
-rwxr-xr-x | bin/xchg.give | 90 | ||||
-rw-r--r-- | bin/xchg.help | 10 | ||||
-rwxr-xr-x | bin/xchg.init | 4 | ||||
-rwxr-xr-x | bin/xchg.list | 5 |
9 files changed, 231 insertions, 0 deletions
diff --git a/bin/rates b/bin/rates new file mode 100644 index 0000000..5a92b59 --- /dev/null +++ b/bin/rates @@ -0,0 +1,24 @@ +{ + "USD" : {"15m" : 6427.15, "last" : 6427.15, "buy" : 6427.15, "sell" : 6427.15, "symbol" : "$"}, + "AUD" : {"15m" : 8790.79, "last" : 8790.79, "buy" : 8790.79, "sell" : 8790.79, "symbol" : "$"}, + "BRL" : {"15m" : 25277.38, "last" : 25277.38, "buy" : 25277.38, "sell" : 25277.38, "symbol" : "R$"}, + "CAD" : {"15m" : 8399.3, "last" : 8399.3, "buy" : 8399.3, "sell" : 8399.3, "symbol" : "$"}, + "CHF" : {"15m" : 6385.05, "last" : 6385.05, "buy" : 6385.05, "sell" : 6385.05, "symbol" : "CHF"}, + "CLP" : {"15m" : 4292375.13, "last" : 4292375.13, "buy" : 4292375.13, "sell" : 4292375.13, "symbol" : "$"}, + "CNY" : {"15m" : 44082.89, "last" : 44082.89, "buy" : 44082.89, "sell" : 44082.89, "symbol" : "¥"}, + "DKK" : {"15m" : 41914.54, "last" : 41914.54, "buy" : 41914.54, "sell" : 41914.54, "symbol" : "kr"}, + "EUR" : {"15m" : 5628.79, "last" : 5628.79, "buy" : 5628.79, "sell" : 5628.79, "symbol" : "€"}, + "GBP" : {"15m" : 5031.26, "last" : 5031.26, "buy" : 5031.26, "sell" : 5031.26, "symbol" : "£"}, + "HKD" : {"15m" : 50451.56, "last" : 50451.56, "buy" : 50451.56, "sell" : 50451.56, "symbol" : "$"}, + "INR" : {"15m" : 448702.8, "last" : 448702.8, "buy" : 448702.8, "sell" : 448702.8, "symbol" : "₹"}, + "ISK" : {"15m" : 696961.02, "last" : 696961.02, "buy" : 696961.02, "sell" : 696961.02, "symbol" : "kr"}, + "JPY" : {"15m" : 712850.89, "last" : 712850.89, "buy" : 712850.89, "sell" : 712850.89, "symbol" : "¥"}, + "KRW" : {"15m" : 7208053.77, "last" : 7208053.77, "buy" : 7208053.77, "sell" : 7208053.77, "symbol" : "₩"}, + "NZD" : {"15m" : 9696.83, "last" : 9696.83, "buy" : 9696.83, "sell" : 9696.83, "symbol" : "$"}, + "PLN" : {"15m" : 24194.07, "last" : 24194.07, "buy" : 24194.07, "sell" : 24194.07, "symbol" : "zł"}, + "RUB" : {"15m" : 432235.78, "last" : 432235.78, "buy" : 432235.78, "sell" : 432235.78, "symbol" : "RUB"}, + "SEK" : {"15m" : 58987.13, "last" : 58987.13, "buy" : 58987.13, "sell" : 58987.13, "symbol" : "kr"}, + "SGD" : {"15m" : 8812.36, "last" : 8812.36, "buy" : 8812.36, "sell" : 8812.36, "symbol" : "$"}, + "THB" : {"15m" : 212144.3, "last" : 212144.3, "buy" : 212144.3, "sell" : 212144.3, "symbol" : "฿"}, + "TWD" : {"15m" : 197782.91, "last" : 197782.91, "buy" : 197782.91, "sell" : 197782.91, "symbol" : "NT$"} +}
\ No newline at end of file diff --git a/bin/xchg.buy b/bin/xchg.buy new file mode 100755 index 0000000..a0a3a8a --- /dev/null +++ b/bin/xchg.buy @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +nick=$1 +amount=$2 +target=$3 +source=$4 +if [ "$nick" = "" ];then + echo missing argument for nick + exit 1 +fi +if [ ! -d /var/cache/segfault/xchg/$nick/ ];then + /home/segfault/bin/xchg.init $nick +fi +if [ "$amount" = "" ];then + echo missing argument for amount + exit 1 +fi +if [ "$target" = "" ];then + echo missing argument for target currency + exit 1 +fi +if [ "$source" = "" ];then + echo missing argument for source currency + exit 1 +fi + +rate=1 + +#if [ $target != BTC ];then +# rate2=$(/home/segfault/bin/xchg.getrate $target) +# if [ "$rate2" = "null" ];then +# echo "invalid currency type $target used" +# exit 1 +# fi +# rate=$(echo | awk "{print $rate / $rate2}") +#fi + +#if [ $source != BTC ];then +# rate2=$(/home/segfault/bin/xchg.getrate $source) +# if [ "$rate2" = "null" ];then +# echo "invalid currency type $source used" +# exit 1 +# fi +# rate=$(echo | awk "{print $rate * $rate2}") +#fi + +rate=$(/home/segfault/bin/xchg.getdoublerate $source $target) + +walletsrc=$(cat /var/cache/segfault/xchg/$nick/$source 2>&-) +walletdst=$(cat /var/cache/segfault/xchg/$nick/$target 2>&-) + +if [ "$walletsrc" = "" ];then + walletsrc=0 +fi +if [ "$walletdst" = "" ];then + walletdst=0 +fi + +### if other types of ways of specifying how much are added, remember to set both srcamt and amount. +if [ $amount = "all" ];then + amount="100%" +fi +if grep '%' <<< "$amount" 2>&1 > /dev/null;then + percentage="$(printf "%s\n" "$amount" | tr -cd '0-9.')" + srcamt="$(echo | awk "{print ($percentage / 100) * $walletsrc}")" + amount=$(echo | awk "{print $srcamt / $rate}") +else + srcamt=$(echo | awk "{print $amount * $rate}") +fi + +if [ "$srcamt" = "" ];then + srcamt=0 +fi + +echo trying to buy $amount of $target for $srcamt $source... + + +postwalletsrc=$(echo | awk "{print $walletsrc - $srcamt}") + +if printf "%s\n" $postwalletsrc | grep ^- 2>&1 > /dev/null;then + echo you, $1, would need to have $srcamt $source to buy $amount $target. you only have $walletsrc $source. + exit 1 +fi + +### if we got here we have enough money... guess make the purchase +#echo updating your source wallet... +echo $(echo | awk "{print $walletsrc - $srcamt}") > /var/cache/segfault/xchg/$nick/$source +#echo updating your target wallet... +echo $(echo | awk "{print $walletdst + $amount}") > /var/cache/segfault/xchg/$nick/$target +echo done diff --git a/bin/xchg.getdoublerate b/bin/xchg.getdoublerate new file mode 100755 index 0000000..2a29c8c --- /dev/null +++ b/bin/xchg.getdoublerate @@ -0,0 +1,3 @@ +#!/bin/sh +wget -qO- "https://min-api.cryptocompare.com/data/price?fsym=$2&tsyms=$1" | jq '.["'"$1"'"]' +#/home/segfault/bin/xchg.getrates | jq '.["'"$1"'"].last' diff --git a/bin/xchg.getrate b/bin/xchg.getrate new file mode 100755 index 0000000..b545667 --- /dev/null +++ b/bin/xchg.getrate @@ -0,0 +1,3 @@ +#!/bin/sh +wget -qO- "https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=$1" | jq '.["'"$1"'"]' +#/home/segfault/bin/xchg.getrates | jq '.["'"$1"'"].last' diff --git a/bin/xchg.getrates b/bin/xchg.getrates new file mode 100755 index 0000000..3a73af2 --- /dev/null +++ b/bin/xchg.getrates @@ -0,0 +1,3 @@ +#!/bin/sh +#cat /home/segfault/bin/rates +wget -qO- https://blockchain.info/ticker diff --git a/bin/xchg.give b/bin/xchg.give new file mode 100755 index 0000000..11f6158 --- /dev/null +++ b/bin/xchg.give @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +nick=$1 +amount=$2 +type=$3 +dstnick=$4 +if [ "$nick" = "" ];then + echo missing argument for nick + exit 1 +fi +if [ ! -d /var/cache/segfault/xchg/$nick/ ];then + /home/segfault/bin/xchg.init $nick +fi +if [ "$amount" = "" ];then + echo missing argument for amount + exit 1 +fi +if [ "$type" = "" ];then + echo missing argument for type of currency + exit 1 +fi +if [ "$dstnick" = "" ];then + echo missing argument for who is to receive the money + exit 1 +fi + +rate=1 + +#if [ $target != BTC ];then +# rate2=$(/home/segfault/bin/xchg.getrate $target) +# if [ "$rate2" = "null" ];then +# echo "invalid currency type $target used" +# exit 1 +# fi +# rate=$(echo | awk "{print $rate / $rate2}") +#fi + +#if [ $source != BTC ];then +# rate2=$(/home/segfault/bin/xchg.getrate $source) +# if [ "$rate2" = "null" ];then +# echo "invalid currency type $source used" +# exit 1 +# fi +# rate=$(echo | awk "{print $rate * $rate2}") +#fi + +#rate=$(/home/segfault/bin/xchg.getdoublerate $source $target) +rate=1 + +walletsrc=$(cat /var/cache/segfault/xchg/$nick/$type 2>&-) +walletdst=$(cat /var/cache/segfault/xchg/$dstnick/$type 2>&-) + +if [ "$walletsrc" = "" ];then + walletsrc=0 +fi +if [ "$walletdst" = "" ];then + walletdst=0 +fi + +### if other types of ways of specifying how much are added, remember to set both srcamt and amount. +if [ $amount = "all" ];then + amount="100%" +fi +if grep '%' <<< "$amount" 2>&1 > /dev/null;then + percentage="$(printf "%s\n" "$amount" | tr -cd '0-9.')" + srcamt="$(echo | awk "{print ($percentage / 100) * $walletsrc}")" + amount=$srcamt +else + srcamt=$amount +fi + +if [ "$srcamt" = "" ];then + srcamt=0 +fi + +echo trying to give $srcamt $type to $dstnick... + + +postwalletsrc=$(echo | awk "{print $walletsrc - $srcamt}") + +if printf "%s\n" $postwalletsrc | grep ^- 2>&1 > /dev/null;then + echo you, $1, would need to have $srcamt $source to give $amount $type to $dstnick. you only have $walletsrc $source. + exit 1 +fi + +### if we got here we have enough money... guess make the purchase +#echo updating your source wallet... +echo $(echo | awk "{print $walletsrc - $srcamt}") > /var/cache/segfault/xchg/$nick/$type +#echo updating your target wallet... +echo $(echo | awk "{print $walletdst + $amount}") > /var/cache/segfault/xchg/$dstnick/$type +echo done diff --git a/bin/xchg.help b/bin/xchg.help new file mode 100644 index 0000000..fb40ba8 --- /dev/null +++ b/bin/xchg.help @@ -0,0 +1,10 @@ + $list Shows how many coin you have + $buy [amount] [what_you_want] [what_you_dont] + I think of it like: xchg, I want to buy 100 bitcoins with US dollars. + example: $but 100 BTC USD + $sell [amount] [what_you_want] [what_you_dont] + $give [amount] [type] [their_nick] + I think of this one like: xchg, I want to give 100 bitcoins to my_bro + example: $give 20 ETH epoch + amounts can also be percentages or "all" which just gets turned into 100% + these percentages are based on the amount of money of the type that is being spent. diff --git a/bin/xchg.init b/bin/xchg.init new file mode 100755 index 0000000..b449ba7 --- /dev/null +++ b/bin/xchg.init @@ -0,0 +1,4 @@ +#!/bin/sh +rm -r /var/cache/segfault/xchg/$1 2>/dev/null +mkdir -p /var/cache/segfault/xchg/$1 +echo 1000 > /var/cache/segfault/xchg/$1/BTC diff --git a/bin/xchg.list b/bin/xchg.list new file mode 100755 index 0000000..cad49f4 --- /dev/null +++ b/bin/xchg.list @@ -0,0 +1,5 @@ +#!/bin/sh +if [ ! -d /var/cache/segfault/xchg/$1 ];then + /home/segfault/bin/xchg.init $1 +fi +grep -H . /var/cache/segfault/xchg/$1/* | grep -v ':0$' | cut -d/ -f6- |