Compare commits

...

11 commits

Author SHA1 Message Date
nahuhh
6c25035021 placeorder fixes 2024-10-09 14:40:50 +00:00
nahuhh
a8fc72a359 add placeorder script 2024-10-09 14:23:26 +00:00
nahuhh
1ed76033ac placeorder_patch 2024-10-09 14:23:26 +00:00
nahuhh
fd4eb9c034 friendly update coincurve 2024-10-09 14:23:26 +00:00
nahuhh
3ff9bb6810 use dev branches 2024-10-09 14:23:26 +00:00
nahuhh
0fd75d4294 rename xmr variable 2024-10-09 14:23:26 +00:00
nahuhh
2eb3465704 add PATH to zshrc 2024-10-09 12:38:06 +00:00
nahuhh
41ae85ee08 use coincurve tags 2024-09-21 14:16:20 +00:00
nahuhh
a4720f834b dont delete coin_versions 2024-09-21 14:15:04 +00:00
nahuhh
5c491184ff Check for running instance 2024-09-21 14:14:58 +00:00
nahuhh
e8f3a7d964 hide xfce err 2024-09-16 19:17:57 +00:00
16 changed files with 589 additions and 35 deletions

View file

@ -4,14 +4,14 @@ BasicSwapDEX on Windows(WSL)/Debian/Ubuntu/Arch/Fedora
### New Installation
```bash
git clone https://github.com/nahuhh/basicswap-bash
git clone https://github.com/nahuhh/basicswap-bash -b placeorders
cd basicswap-bash && ./install.sh
cd .. && rm -rf basicswap-bash
```
### Update scripts from older versions
``` bash
cd ~/coinswaps/basicswap
git clone https://github.com/nahuhh/basicswap-bash
git clone https://github.com/nahuhh/basicswap-bash -b placeorders
cd basicswap-bash
mkdir -p $HOME/.local/bin
rm -r $HOME/.local/bin/bsx

View file

@ -1,5 +1,21 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
python3 -m venv "$SWAP_DATADIR/venv"
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is already running.\n"; $nocolor
exit
fi
fi
fi
. $SWAP_DATADIR/venv/bin/activate && python -V
$HOME/.local/bin/bsx/startup.sh

View file

@ -1,10 +1,23 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
# Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
@ -28,6 +41,6 @@ read -p 'Select an option [1|2]: ' l
;;
esac
done
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
$HOME/.local/bin/bsx/addcoin.sh

View file

@ -1,10 +1,23 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
# Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
@ -28,6 +41,6 @@ read -p 'Select an option [1|2]: ' l
;;
esac
done
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
$HOME/.local/bin/bsx/disabletor.sh

View file

@ -1,10 +1,23 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
# Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
@ -28,6 +41,6 @@ read -p 'Select an option [1|2]: ' l
;;
esac
done
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
$HOME/.local/bin/bsx/enabletor.sh

25
bsx-placeorder Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
# Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
bsx_run=$(pidof particld | grep $bsx_pid)
if ! [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX must be running.\n"; $nocolor
exit
fi
else
$red"\nError: BasicSwapDEX must be running.\n"; $nocolor
exit
fi
mv $HOME/.local/bin/bsx/placeorders/* $SWAP_DATADIR/basicswap/scripts/
cd $SWAP_DATADIR/basicswap/scripts/
./placeorders.sh

View file

@ -1,10 +1,23 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
# Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
@ -28,6 +41,6 @@ read -p 'Select an option [1|2]: ' l
;;
esac
done
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
$HOME/.local/bin/bsx/removecoin.sh

View file

@ -1,5 +1,23 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
# Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
. $SWAP_DATADIR/venv/bin/activate && python -V
if [ -f /usr/local/bin/bsx/update.sh ]; then

View file

@ -1,10 +1,23 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
# Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
@ -28,6 +41,6 @@ read -p 'Select an option [1|2]: ' l
;;
esac
done
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
$HOME/.local/bin/bsx/upgradecoins.sh

View file

@ -0,0 +1,25 @@
{
"offers": [],
"bids": [
{
"coin_from": "COIN_TO_BUY",
"coin_to": "COIN_TO_SELL",
"amount": AMOUNT,
"maxrate": RATE,
"address": "-1",
"min_swap_amount": MIN_SWAP,
"max_coin_from_balance": -1,
"min_coin_to_balance": 0,
"max_concurrent": MAXBIDS,
"name": "GUI Bid"
}
],
"stealthex": [],
"min_seconds_between_offers": 5,
"max_seconds_between_offers": 5,
"min_seconds_between_bids": 10,
"max_seconds_between_bids": 10,
"num_enabled_offers": 0,
"num_enabled_bids": 1,
"num_enabled_swaps": 0
}

View file

@ -0,0 +1,27 @@
{
"offers": [
{
"enabled": true,
"coin_from": "COIN_TO_SELL",
"coin_to": "COIN_TO_BUY",
"amount": AMOUNT,
"minrate": RATE,
"ratetweakpercent": PERCENT,
"amount_variable": true,
"address": "-1",
"name": "GUI Offer",
"min_coin_from_amt": AMOUNT,
"min_swap_amount": MIN_SWAP,
"offer_valid_seconds": 1200
}
],
"bids": [],
"stealthex": [],
"min_seconds_between_offers": 10,
"max_seconds_between_offers": 10,
"min_seconds_between_bids": 10,
"max_seconds_between_bids": 10,
"num_enabled_offers": 1,
"num_enabled_bids": 0,
"num_enabled_swaps": 0
}

338
bsx/placeorders/placeorders.sh Executable file
View file

@ -0,0 +1,338 @@
#!/bin/bash
############################
###########################
#set -x
PORT=12700 # BasicSwapDex http port
# config file location
taker=placebid.json
maker=placeoffer.json
state=placeorders_state.json
# Defaults
ALLOW_SPLIT_ORDERS=true # Sane default TODO
MAXBIDS=10 # TODO
PERCENT=2.5 # Max slippage for "Market" order types
# FUNC - dont touch
BUYORSELL=""
AMOUNT=""
TAKER_RATE=""
MAKER_RATE=""
OB_MIN=""
MIN_MAKER=""
MIN_TAKER=""
###########################
############################
# Colors
cy="echo -e -n \e[36;1m"
cy2="\e[36;1m"
red="echo -e -n \e[31;1m"
red2="\e[31;1m"
grn="echo -e -n \e[32;1m"
grn2="\e[32;1m"
nc="echo -e -n \e[0m"
nc2="\e[0m"
# Choose Coins
coin_prompt_buy() {
THEIR_COIN=$COIN
theircoin=$coinsymbol
theircapital=$coinname
}
coin_prompt_sell() {
YOUR_COIN=$COIN
yourcoin=$coinsymbol
yourcapital=$coinname
}
coin() {
coin=""
echo -e "\n[1] Bitcoin\n[2] Monero\n[3] Litecoin\n[4] Firo\n[5] Dash\n[6] Decred\n[7] PIVX\n[8] Particl\n[9] Wownero\n"
until [[ $coin =~ ^[1-9]$ ]]; do
read -p 'Select an option: ' coin
case $coin in
1) COIN="bitcoin"
coinname="Bitcoin"
coinsymbol="BTC"
;;
2) COIN="monero"
coinname="Monero"
coinsymbol="XMR"
;;
3) COIN="litecoin"
coinname="Litecoin"
coinsymbol="LTC"
;;
4) COIN="zcoin"
coinname="Firo"
coinsymbol="FIRO"
;;
5) COIN="dash"
coinname="Dash"
coinsymbol="DASH"
;;
6) COIN="dcr"
coinname="Decred"
coinsymbol="DCR"
;;
7) COIN="pivx"
coinname="PIVX"
coinsymbol="PIVX"
;;
8) COIN="particl"
coinname="Particl"
coinsymbol="PART"
;;
9) COIN="wownero"
coinname="Wownero"
coinsymbol="WOW"
;;
*) $red "\nYou must answer 1-9\n"; $nc
;;
esac
done
}
book_min() {
if [[ $coin = 1 ]]; then # BITCOIN
OB_MIN=0.0050
MIN_SWAP=0.0010
elif [[ $coin = 2 ]]; then # MONERO
OB_MIN=0.2000
MIN_SWAP=0.0300
elif [[ $coin = 3 ]]; then # LITECOIN
OB_MIN=0.4000
MIN_SWAP=0.0600
elif [[ $coin = 4 ]]; then # FIRO
OB_MIN=20.0000
MIN_SWAP=8.0000
elif [[ $coin = 5 ]]; then # DASH
OB_MIN=1.0000
MIN_SWAP=0.2000
elif [[ $coin = 6 ]]; then # DECRED
OB_MIN=1.0000
MIN_SWAP=0.2000
elif [[ $coin = 7 ]]; then # PIVX
OB_MIN=50.0000
MIN_SWAP=10.0000
elif [[ $coin = 8 ]]; then # PARTICL
OB_MIN=50.0000
MIN_SWAP=10.0000
elif [[ $coin = 9 ]]; then # WOWNERO
OB_MIN=50.0000
MIN_SWAP=10.0000
fi
}
set_fiat() {
echo -e "[1] USD [default]\n[2] EUR\n[3] CAD\n[4] AUD\n[5] CUSTOM"
read -p 'Select an option: ' fiat_select
case $fiat_select in
1) FIAT=USD
fiat=usd
;;
2) FIAT=EUR
fiat=eur
;;
3) FIAT=CAD
fiat=cad
;;
4) FIAT=AUD
fiat=aud
;;
5) read -p 'Please enter the lowecase 3 character currency code [example: jpy] ' FIAT
fiat=$FIAT
;;
*) FIAT=USD
fiat=usd
;;
esac
}
coin_price() {
echo -e "\nCurrent Market Rates are.."
YOUR_FIAT=$(curl -s "https://api.coingecko.com/api/v3/simple/price?ids=$THEIR_COIN,$YOUR_COIN&vs_currencies=$fiat" | jq -r ".$YOUR_COIN.$fiat")
THEIR_FIAT=$(curl -s "https://api.coingecko.com/api/v3/simple/price?ids=$THEIR_COIN,$YOUR_COIN&vs_currencies=$fiat" | jq -r ".$THEIR_COIN.$fiat")
TAKER_RATE=$(echo $THEIR_FIAT $YOUR_FIAT | awk '{ printf "%.8f\n", $1 / $2 }' )
MAKER_RATE=$(echo $TAKER_RATE | awk '{ printf "%.8f\n", 1 / $1 }')
$cy"$THEIR_FIAT $FIAT$nc2/$grn2$theircoin$nc2 which is $red2$TAKER_RATE $yourcoin$nc2/$grn2$theircoin$nc2\n"
$cy"$YOUR_FIAT $FIAT$nc2/$red2$yourcoin$nc2 which is $grn2$MAKER_RATE $theircoin$nc2/$red2$yourcoin$nc2\n"
}
buy_sell() {
echo -e "\n[1] BUY a specific amount of $grn2$theircapital$nc2\n[2] SELL a specific amount of your $red2$yourcapital$nc2\n"
until [[ $BUYORSELL =~ ^[12]$ ]]; do
read -p 'Select an option: ' BUYORSELL
case $BUYORSELL in
1) read -p "How much $theircapital do you want to BUY? [example: 1] " AMOUNT
$cy "\n4. Rate you will pay:\n";$nc
echo -e "[1] CUSTOM RATE: Specific Crypto Rate $red2$yourcoin$nc2/$grn2$theircoin$nc2\n[2] CUSTOM PERCENT: $red2$TAKER_RATE $yourcoin$nc2/$grn2$theircoin $cy2+/- CUSTOM Percent$nc2\n[3] PRESET: $red2$TAKER_RATE $yourcoin$nc2/$grn2$theircoin$nc2\n[4] PRESET: $red2$TAKER_RATE $yourcoin$nc2/$grn2$theircoin $cy2+ $PERCENT%$nc2\n[ENTER] FIAT: Enter a $cy2$FIAT$nc2 rate to pay"
read -p 'Select an option: ' RATESEL
case $RATESEL in
1) read -p $"At what rate would you like to Pay? [example: $TAKER_RATE] " RATE
PRICE=$(echo $YOUR_FIAT $RATE | awk '{ printf "%.2f\n", $1 * $2 }')
PERCENT=0
;;
2) read -p 'Pay this much % above or below market [example: [0.5|-0.5] ' PERCENT
RATE=$(echo $TAKER_RATE $PERCENT | awk '{ printf "%.8f\n", ( $1 * ( $2 / 100 + 1 ))}')
PRICE=$(echo $YOUR_FIAT * $RATE | awk '{ printf "%.2f\n", $1 * $2 }')
;;
3) RATE=$TAKER_RATE
PRICE=$THEIR_FIAT
PERCENT=0
;;
4) RATE=$(echo $TAKER_RATE $PERCENT | awk '{ printf "%.8f\n", ( $1 * ( $2 / 100 + 1 ))}')
PRICE=$(echo $YOUR_FIAT $RATE | awk '{ printf "%.2f\n", $1 * $2 }')
;;
*) read -p $"Enter specific price in $FIAT to PAY? [example: "$THEIR_FIAT"] " PRICE
RATE=$(echo $PRICE $YOUR_FIAT | awk '{ printf "%.8f\n", $1 / $2 }')
PERCENT=0
;;
esac
MAKER_RATE=$(echo $RATE | awk '{ printf "%.8f\n", 1 / $1 }')
echo -e "\nPaying: $red2 $PRICE$FIAT$nc2 which is $red2($RATE $yourcoin$nc2/$grn2$theircoin$nc2)"
echo -e "Rate to be paid: $grn2$MAKER_RATE $theircoin$nc2/$red2$yourcoin$nc2\n"
;;
2) read -p "How much YOUR $yourcapital do you want to SELL [example: 1] " AMOUNT
$cy "\n4. Rate to charge:\n";$nc
echo -e "[1] CUSTOM: Specific Crypto Rate $grn2$theircoin$nc2/$red2$yourcoin$nc2\n[2] CUSTOM: $grn2$MAKER_RATE $theircoin$nc2/$red2$yourcoin $cy2+/- CUSTOM Percent$nc2\n[3] PRESET: $grn2$MAKER_RATE $theircoin$nc2/$red2$yourcoin$nc2\n[4] PRESET: $grn2$MAKER_RATE $theircoin$nc2/$red2$yourcoin $cy2+ $PERCENT%$nc2\n[ENTER] FIAT: Enter a $cy2$FIAT$nc2 rate to charge"
read -p 'Select an option: ' RATESEL
case $RATESEL in
1) read -p $"Enter specific rate to Charge? [example: $MAKER_RATE] " RATE
PRICE=$(echo $THEIR_FIAT $RATE | awk '{ printf "%.2f\n", $1 * $2 }')
PERCENT=0
;;
2) read -p 'Charge this much percent above market [example: [0.5 or -0.5] ] ' PERCENT
RATE=$(echo $MAKER_RATE $PERCENT | awk '{ printf "%.8f\n", ( $1 * ( $2 / 100 + 1 ))}')
PRICE=$(echo $THEIR_FIAT $RATE | awk '{ printf "%.2f\n", $1 * $2 }')
;;
3) RATE=$MAKER_RATE
PRICE=$(echo $THEIR_FIAT $RATE | awk '{ printf "%.2f\n", $1 * $2 }')
PERCENT=0
;;
4) RATE=$(echo $MAKER_RATE $PERCENT | awk '{ printf "%.8f\n", ( $1 * ( $2 / 100 + 1 ))}')
PRICE=$(echo $THEIR_FIAT $RATE | awk '{ printf "%.2f\n", $1 * $2 }')
;;
*) read -p $"Enter specific price in $FIAT to Charge? [example: "$YOUR_FIAT"] " PRICE
RATE=$(echo $PRICE $THEIR_FIAT | awk '{ printf "%.8f\n", $1 / $2 }')
PERCENT=0
;;
esac
TAKER_RATE=$(echo $RATE | awk '{ printf "%.8f\n", 1 / $1 }')
echo -e "Selling at $PRICE$FIAT which is a rate of $grn2$RATE $theircoin$nc2/$red2$yourcoin$nc2"
;;
*) $red "\nYou must answer 1 or 2\n"; $nc
;;
esac
done
}
# TODO // ENABLE SPLIT ORDERS
split_orders() {
if [ $ALLOW_SPLIT_ORDERS = true ]; then
MIN_SWAP=$(echo $AMOUNT $MAXBIDS | awk '{ printf "%.0f\n", $1 / $2 }')
echo -e "$cy2#TODO$nc2 Splitting into multiple bids if necessary. $red2$MAXBIDS$nc2 tx at most"
else
MIN_SWAP=$AMOUNT
$red"One order only. Not Recommended";$nc
echo "$MIN_SWAP"
fi
}
apply_config() {
# Convert amount
MIN_TAKER=$(echo $MIN_SWAP $MAKER_RATE | awk '{ printf "%.8f\n", $1 * $2 }')
sed -i -z "s/MIN_SWAP/$MIN_TAKER/" $taker
sed -i -z "s/MIN_SWAP/$MIN_SWAP/" $maker
sed -i -z "s/COIN_TO_SELL/$yourcapital/" $taker $maker
sed -i -z "s/COIN_TO_BUY/$theircapital/" $taker $maker
sed -i -z "s/PERCENT/$PERCENT/" $maker
sed -i -z "s/MAXBIDS/$MAXBIDS/" $taker
echo -e "\nMinumum amt per swap = $grn2$MIN_TAKER $theircoin$nc2"
echo -e " = $red2$MIN_SWAP $yourcoin$nc2\n"
if [[ $BUYORSELL = 1 ]]; then
MAKERAMOUNT=$(echo $AMOUNT $MAKER_RATE | awk '{ printf "%.8f\n", $1 / $2 }')
OB_AMOUNT=$MAKERAMOUNT
echo -e "Outgoing: $red2$MAKERAMOUNT $yourcoin$nc2"
echo -e "Incoming: $grn2~$AMOUNT $theircoin$nc2"
sed -i -z "s/AMOUNT/$MAKERAMOUNT/g" $maker
sed -i -z "s/RATE/$MAKER_RATE/" $maker
sed -i -z "s/RATE/$RATE/" $taker
sed -i -z "s/AMOUNT/$AMOUNT/g" $taker
else
TAKERAMOUNT=$(echo $AMOUNT $MAKER_RATE | awk '{ printf "%.8f\n", $1 * $2 }')
OB_AMOUNT=$AMOUNT
echo -e "Outgoing: $red2$AMOUNT $yourcoin$nc2"
echo -e "Incoming: $grn2~$TAKERAMOUNT $theircoin$nc2"
sed -i -z "s/AMOUNT/$TAKERAMOUNT/g" $taker
sed -i -z "s/RATE/$TAKER_RATE/" $taker
sed -i -z "s/RATE/$RATE/" $maker
sed -i -z "s/AMOUNT/$AMOUNT/g" $maker
fi
}
revert_config() {
cp placeorders_state.json.template $state
cp placeoffer.json.template $maker
cp placebid.json.template $taker
}
check_bids() {
# oneshot. Check for matching offers before posting one
apply_config
FOUNDBID=$(python createoffers.py --configfile $taker --statefile $state --port=$PORT --oneshot --debug | grep "New bid")
if [[ $FOUNDBID ]]; then
$grn"Placed bid successfully! Check BasicSwapDEX to confirm\n";$nc
elif [[ $OB_AMOUNT < $OB_MIN && -z $FOUNDBID ]]; then
echo -e "Checking for a matching offer"
echo -e "No matching offers found $red2:@ !!!$nc2\nBid quantity too$red2 low$nc2 to post to order book.\nTrying again in 30 seconds"
sleep 2
revert_config
sleep 28
apply_config
$cy"Rechecking bids\n";$nc
recheck_bids
else
# Post as limit order on the book
$cy"No matching offers found. Posting to the orderbook\n";$nc
ORDERPLACED=$(python createoffers.py --configfile $maker --statefile $state --port=$PORT --oneshot | grep "New offer")
if [[ $ORDERPLACED ]]; then
revert_config
$grn"OFFER POSTED! Please check BasicSwapDEX to confirm\n";$nc
else
revert_config
$red"Placing Order failed. Try again$nc2\n"
fi
fi
}
recheck_bids() {
check_bids
echo rechecking
}
# 1. Choose coins
revert_config
set_fiat
$grn"\n\nName of coin to buy";$nc
coin
coin_prompt_buy
$red"\n\nName of coin to sell";$nc
coin
coin_prompt_sell
echo -e "Buying: $grn2$theircapital$nc2"
echo -e "Selling: $red2$yourcapital$nc2"
#2. Set rates
# Pull Market rate
coin_price
buy_sell
split_orders
book_min
#3. Attempt bid / Post offer
check_bids

View file

@ -0,0 +1,6 @@
{
"offers": {
},
"bids": {
}
}

View file

@ -7,17 +7,16 @@ nocolor="echo -e -n \e[0m"
## Download & Install coincurve stuff
cd $SWAP_DATADIR
wget -O coincurve-anonswap.zip https://github.com/tecnovert/coincurve/archive/refs/tags/anonswap_v0.2.zip
unzip -d coincurve-anonswap coincurve-anonswap.zip
mv -f ./coincurve-anonswap/*/{.,}* ./coincurve-anonswap || true
cd $SWAP_DATADIR/coincurve-anonswap
git clone https://github.com/basicswap/coincurve -b basicswap_v0.2 coincurve-basicswap
cd $SWAP_DATADIR/coincurve-basicswap
$SWAP_DATADIR/venv/bin/pip install .
## Clone basicswap git
cd $SWAP_DATADIR
git clone https://github.com/basicswap/basicswap
git clone https://github.com/basicswap/basicswap -b dev
cd $SWAP_DATADIR/basicswap
## Install basicswap
$SWAP_DATADIR/venv/bin/pip install wheel
$SWAP_DATADIR/venv/bin/pip install .
## Decide a source for Monero's restore height
@ -42,7 +41,7 @@ enable_tor() {
if [[ "$particl_mnemonic" && "$monerod_addr" ]]; then
# Restore seed
PARTICL_MNEMONIC=$particl_mnemonic
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port \
XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port \
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000 --particl_mnemonic="$PARTICL_MNEMONIC"
enable_tor
elif [[ "$particl_mnemonic" ]]; then
@ -52,7 +51,7 @@ elif [[ "$particl_mnemonic" ]]; then
enable_tor
elif [[ "$monerod_addr" ]]; then
# Setup new install and use a remote monero node
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port \
XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port \
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
$red"\n\nMake note of your seed above\n"; $nocolor
enable_tor
@ -63,4 +62,5 @@ else
enable_tor
fi
$green"Install complete.\n\nUse 'basicswap-bash' to run, 'bsx-update' to update, and 'bsx-addcoin' to add a coin\n"; $nocolor
$green"Install complete.\n\nUse 'basicswap-bash' to run, 'bsx-update' to update, and 'bsx-addcoin' to add a coin\n\nYou'll need to open a new login shell (a new terminal window) for the start scripts to be recognized.\n";$nocolor
$red"XFCE will require you to logout / login";$nocolor

View file

@ -1,9 +1,10 @@
#!/bin/bash
COINCURVE=0.2
cd $SWAP_DATADIR/basicswap
# Download updated scripts
echo "Updating basicswap-bash scripts" && sleep 1
git clone https://github.com/nahuhh/basicswap-bash
git clone https://github.com/nahuhh/basicswap-bash -b placeorders
cd basicswap-bash
# Move scripts
@ -17,6 +18,18 @@ echo "Updating BasicSwapDEX" && sleep 1
# Delete dangling build folder. Same as --no-cache for docker
rm -rf $SWAP_DATADIR/basicswap/build
# Coincurve
cd $SWAP_DATADIR
if [[ -d coincurve-basicswap ]]; then
cd coincurve-basicswap
git pull
git checkout basicswap_v$COINCURVE
else
git clone https://github.com/basicswap/coincurve -b basicswap_v$COINCURVE coincurve-basicswap && cd $_
fi
$SWAP_DATADIR/venv/bin/pip install .
# BasicSwap
# Switch to new repo: basicswap/basicswap
cd $SWAP_DATADIR/basicswap
git remote set-url origin https://github.com/basicswap/basicswap
@ -30,4 +43,4 @@ $SWAP_DATADIR/venv/bin/pip install .
$HOME/.local/bin/bsx/auto_coinupd8.sh
# Cleanup
rm -rf basicswap-bash core_versions
rm -rf basicswap-bash

View file

@ -1,10 +1,23 @@
#/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
# Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is already installed.\n"; $nocolor
exit
fi
fi
fi
# Title Bar
$green "\n"
title="BasicSwapDEX Installer"
@ -66,9 +79,9 @@ detect_os_arch
## Update & Install dependencies
echo -e "\n\nInstalling dependencies\nPress CTRL-C at password prompt(s) to skip. If skipped, you must install the dependencies manually before proceeding"
$green"$UPDATE\n$INSTALL $DEPENDENCY git curl wget unzip automake libtool jq\n"; $nocolor
$green"$UPDATE\n$INSTALL $DEPENDENCY curl automake libtool jq\n"; $nocolor
$UPDATE
$INSTALL $DEPENDENCY git curl wget unzip automake libtool jq
$INSTALL $DEPENDENCY curl automake libtool jq
# Enable tor
echo -e "\n\n[1] Tor ON (requires sudo)\n[2] Tor OFF\n"
@ -164,31 +177,39 @@ echo -e "\n\nInstalling BasicSwapDEX"
read -p 'Press Enter to continue, or CTRL-C to exit.'
# Quest to make trasher happy
trasherdk=$(echo $PATH | grep $USER/.local/bin)
addpath='PATH="$HOME/.local/bin:$PATH"'
trasherdk=$(echo $PATH | grep .local/bin)
if ! [[ $trasherdk ]]; then
mkdir -p $HOME/.local/bin
fi
# Move scripts to .local/bin
if [ -d $HOME/.local/bin/bsx ]; then
rm -r $HOME/.local/bin/bsx* $HOME/.local/bin/basicswap-bash
fi
mv -f -t $HOME/.local/bin/ basicswap-bash bsx*
# Enable .profile detection on XFCE
xfce_check=$(echo $XDG_CURRENT_DESKTOP | grep XFCE)
xsessionrc_check=$(cat ~/.xsessionrc | grep '. ~/.profile')
if [[ $xfce_chek ]] && [[ -z $xsessionrc_check ]]; then
echo '. ~/.profile' | tee -a ~/.xsessionrc
mkdir -p $HOME/.local/bin
# Bash
if [[ -f $HOME/.bashrc ]]; then
echo "export $addpath" | tee -a $HOME/.bashrc
fi
# Zsh
if [[ -f $HOME/.zshrc ]]; then
echo "export $addpath" | tee -a $HOME/.zshrc
fi
# xfce4
if [[ -f $HOME/.xsessionrc ]]; then
echo "export $addpath" | tee -a $HOME/.xsessionrc
fi
fi
# Move scripts to .local/bin
if [[ -d $HOME/.local/bin/bsx ]]; then
rm -r $HOME/.local/bin/bsx* $HOME/.local/bin/basicswap-bash
fi
mv -f -t $HOME/.local/bin/ basicswap-bash bsx*
## Make venv and set variables for install
export SWAP_DATADIR=$HOME/coinswaps
export monerod_addr=$monerod_addr
export monerod_port=$monerod_port
export particl_mnemonic=$particl_mnemonic
export xmrrestoreheight=$xmrrestoreheight
export tor_on=$tor_on
export TAILS=$TAILS
mkdir -p "$SWAP_DATADIR/venv"
python -m venv "$SWAP_DATADIR/venv"
## Activate venv
$HOME/.local/bin/bsx/activate_venv.sh