Compare commits

..

3 commits

Author SHA1 Message Date
nahuhh
e7e55e74ed placeorders: printf and small changes 2024-11-09 03:11:48 +00:00
nahuhh
b25aecc6b9 mac: bad zsh formatting and colors 2024-11-09 03:03:53 +00:00
nahuhh
dacdee2570
placeorder: python3 2024-11-08 21:49:42 +00:00
14 changed files with 172 additions and 146 deletions

View file

@ -2,15 +2,15 @@
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"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \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)
bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
@ -18,7 +18,7 @@ if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
fi
fi
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
printf "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
case $l in

View file

@ -2,15 +2,15 @@
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"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \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)
bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
@ -18,7 +18,7 @@ if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
fi
fi
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
printf "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
case $l in

View file

@ -2,15 +2,15 @@
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"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \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)
bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
@ -18,7 +18,7 @@ if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
fi
fi
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
printf "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
case $l in

View file

@ -2,14 +2,14 @@
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"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \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)
bsx_run=$(pgrep particld | grep $bsx_pid)
if ! [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX must be running.\n"; $nocolor
exit
@ -19,7 +19,7 @@ else
exit
fi
mv $HOME/.local/bin/bsx/placeorders/* $SWAP_DATADIR/basicswap/scripts/
cp $HOME/.local/bin/bsx/placeorders/* $SWAP_DATADIR/basicswap/scripts/.
cd $SWAP_DATADIR/basicswap/scripts/
./placeorders.sh

View file

@ -2,15 +2,15 @@
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"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \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)
bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
@ -18,7 +18,7 @@ if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
fi
fi
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
printf "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
case $l in

View file

@ -2,15 +2,15 @@
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"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \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)
bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit

View file

@ -1,7 +1,7 @@
#!/bin/bash
## Prompt for user input
echo -e "\n\nThe following coins can be added (case sensitive)\nbitcoin\ndash\ndecred\nfiro\nlitecoin\npivx\nwownero\n"
printf "\n\nThe following coins can be added (case sensitive)\nbitcoin\ndash\ndecred\nfiro\nlitecoin\npivx\nwownero\n\n"
read -p 'Full name of coin to add [example: litecoin] ' addcoin
## Confirm
read -p $'\nAdd '$addcoin' to your BasicSwap install, correct? Press ENTER to continue. CTRL-C to exit'

View file

@ -1,36 +1,58 @@
#!/bin/bash
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \e[0m"
# Detect Operating system
INSTALL=""
UPDATE=""
INIT_TOR="sudo systemctl restart tor"
INIT_TOR=""
SYSTEMD_TOR="sudo systemctl restart tor"
check_tails() {
if [[ $USER == amnesia ]]; then
$green"\n\nDetected Tails";$nocolor
TAILS=1
else
$green"\n\nDetected Debian";$nocolor
fi
}
detect_os_arch() {
if type -P apt > /dev/null; then
if [[ $(uname -s) = "Darwin" ]]; then
# MacOS
export MACOS=1
if type -p brew > /dev/null; then
$green"Homebrew is installed\n";$nc
INSTALL="brew install"
else
$green"Installing Homebrew\n";$nc
INSTALL="curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | /bin/bash && brew install"
fi
INIT_TOR="pkill tor && tor"
$green"\n\nDetected MacOS";$nocolor
elif type -p apt > /dev/null; then
check_tails
# Debian / Ubuntu / Mint
INSTALL="sudo apt install -y"
INSTALL="sudo apt install"
UPDATE="sudo apt update"
$green"\nDetected Debian\n";$nocolor
elif type -P dnf > /dev/null; then
INIT_TOR=$SYSTEMD_TOR
elif type -p dnf > /dev/null; then
# Fedora
INSTALL="sudo dnf install -y"
INSTALL="sudo dnf install"
UPDATE="sudo dnf check-update"
$green"\nDetected Fedora\n";$nocolor
elif type -P pacman > /dev/null; then
INIT_TOR=$SYSTEMD_TOR
$green"\n\nDetected Fedora";$nocolor
elif type -p pacman > /dev/null; then
# Arch Linux
INSTALL="sudo pacman -S"
UPDATE="sudo pacman -Syu"
$green"\nDetected Arch Linux\n";$nocolor
elif type -P brew > /dev/null; then
# MacOS
INSTALL="brew install"
$green"\nDetected MacOS\n";$nocolor
INIT_TOR=$SYSTEMD_TOR
$green"\n\nDetected Arch Linux";$nocolor
else
$red"Failed to detect OS. Unsupported or unknown distribution.\nInstall Failed.";$nocolor
$red"\nFailed to detect OS. Unsupported or unknown distribution.\nInstall Failed.\n";$nocolor
exit
fi
}
@ -38,8 +60,8 @@ detect_os_arch() {
detect_os_arch
# Check for Tor installation
if type -P tor > /dev/null; then
echo -e "\nTor is already installed :)"
if type -p tor > /dev/null; then
printf "\nTor is already installed :)\n"
else
# Install and configure tor
echo "Installing Tor..."
@ -48,7 +70,7 @@ else
fi
# Create HashedControlPassword
echo -e "In the next step you'll choose a password. NOTE: It will be saved in PLAIN TEXT."
printf "In the next step you'll choose a password. NOTE: It will be saved in PLAIN TEXT.\n"
read -p "Enter a (new) tor control password [example: 123123] " torcontrolpass
# Edit /etc/tor/torrc
torhashedpass=$(tor --hash-password $torcontrolpass)
@ -57,9 +79,9 @@ skipcontrol=$(sudo grep -x "$enabledcontrol" /etc/tor/torrc)
echo "Check torrc for enabled ControlPort"
if [[ $skipcontrol ]]; then
# Use Existing enabled ControlPort and append HashedControlPassword
echo -e "# Added by basicswap-bash\nHashedControlPassword $torhashedpass" | sudo tee -a /etc/tor/torrc
printf "# Added by basicswap-bash\nHashedControlPassword $torhashedpass\n" | sudo tee -a /etc/tor/torrc
else
echo -e "# Added by basicswap-bash\n$enabledcontrol\nHashedControlPassword $torhashedpass" | sudo tee -a /etc/tor/torrc
printf "# Added by basicswap-bash\n$enabledcontrol\nHashedControlPassword $torhashedpass\n" | sudo tee -a /etc/tor/torrc
fi
# Restart tor to apply

View file

@ -26,13 +26,13 @@ MIN_TAKER=""
############################
# Colors
cy="echo -e -n \e[36;1m"
cy="printf \e[36;1m"
cy2="\e[36;1m"
red="echo -e -n \e[31;1m"
red="printf \e[31;1m"
red2="\e[31;1m"
grn="echo -e -n \e[32;1m"
grn="printf \e[32;1m"
grn2="\e[32;1m"
nc="echo -e -n \e[0m"
nc="printf \e[0m"
nc2="\e[0m"
# Choose Coins
@ -48,7 +48,7 @@ coin_prompt_sell() {
}
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"
printf "\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\n"
until [[ $coin =~ ^[1-9]$ ]]; do
read -p 'Select an option: ' coin
case $coin in
@ -88,7 +88,7 @@ coin() {
coinname="Wownero"
coinsymbol="WOW"
;;
*) $red "\nYou must answer 1-9\n"; $nc
*) $red"\nYou must answer 1-9\n"; $nc
;;
esac
done
@ -126,48 +126,56 @@ book_min() {
}
set_fiat() {
echo -e "[1] USD [default]\n[2] EUR\n[3] CAD\n[4] AUD\n[5] CUSTOM"
printf "[1] USD [default]\n[2] EUR\n[3] CAD\n[4] AUD\n[5] CUSTOM\n\n"
read -p 'Select an option: ' fiat_select
case $fiat_select in
1) FIAT=USD
fiat=usd
echo "USD"
;;
2) FIAT=EUR
fiat=eur
echo "EUR"
;;
3) FIAT=CAD
fiat=cad
echo "CAD"
;;
4) FIAT=AUD
fiat=aud
echo "AUD"
;;
5) read -p 'Please enter the lowecase 3 character currency code [example: jpy] ' FIAT
fiat=$FIAT
;;
*) FIAT=USD
fiat=usd
echo "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")
printf "\n\nCurrent Market Rates are..\n"
curl -s "https://api.coingecko.com/api/v3/simple/price?ids=$THEIR_COIN,$YOUR_COIN&vs_currencies=$fiat" > rates.txt
YOUR_FIAT=$(cat rates.txt | jq -r ".$YOUR_COIN.$fiat")
THEIR_FIAT=$(cat rates.txt | 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"
rm rates.txt
}
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"
printf "\n\n[1] BUY a specific amount of $grn2$theircapital$nc2\n[2] SELL a specific amount of your $red2$yourcapital$nc2\n\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 "\nRate you will pay:\n";$nc
echo -e "[1] CUSTOM: Specific Crypto Rate $red2$yourcoin$nc2/$grn2$theircoin$nc2\n[2] CUSTOM: $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"
1) read -p $'\nHow much '"$theircapital"' do you want to BUY? [example: 1] ' AMOUNT
$cy"\nRate you will pay:\n";$nc
printf "\n[1] CUSTOM: Specific Crypto Rate $red2$yourcoin$nc2/$grn2$theircoin$nc2\n[2] CUSTOM: $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\n\n"
read -p 'Select an option: ' RATESEL
case $RATESEL in
1) read -p $"At what rate would you like to Pay? [example: $TAKER_RATE] " RATE
@ -191,12 +199,12 @@ buy_sell() {
;;
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"
printf "\nPaying: $red2 $PRICE$FIAT$nc2 which is $red2($RATE $yourcoin$nc2/$grn2$theircoin$nc2)\n"
printf "Rate to be paid: $grn2$MAKER_RATE $theircoin$nc2/$red2$yourcoin$nc2\n\n"
;;
2) read -p "How much YOUR $yourcapital do you want to SELL [example: 1] " AMOUNT
$cy "\nRate 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"
2) read -p $'\nHow much YOUR '"$yourcapital"' do you want to SELL [example: 1] ' AMOUNT
$cy"\nRate to charge:\n";$nc
printf "\n[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\n\n"
read -p 'Select an option: ' RATESEL
case $RATESEL in
1) read -p $"Enter specific rate to Charge? [example: $MAKER_RATE] " RATE
@ -220,9 +228,9 @@ buy_sell() {
;;
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"
printf "Selling at $PRICE$FIAT which is a rate of $grn2$RATE $theircoin$nc2/$red2$yourcoin$nc2\n"
;;
*) $red "\nYou must answer 1 or 2\n"; $nc
*) $red"\nYou must answer 1 or 2\n"; $nc
;;
esac
done
@ -232,7 +240,7 @@ buy_sell() {
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"
printf "$cy2#TODO$nc2 Splitting into multiple bids if necessary. $red2$MAXBIDS$nc2 tx at most\n"
else
MIN_SWAP=$AMOUNT
$red"One order only. Not Recommended";$nc
@ -249,14 +257,14 @@ apply_config() {
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"
printf "\nMinumum amt per swap = $grn2$MIN_TAKER $theircoin$nc2\n"
printf " = $red2$MIN_SWAP $yourcoin$nc2\n\n"
if [[ $BUYORSELL = 1 ]]; then
MAKERAMOUNT=$(echo $AMOUNT $MAKER_RATE | awk '{ printf "%.8f\n", $1 / $2 }')
OB_AMOUNT=$MAKERAMOUNT
INCREMENT=$(echo $OB_AMOUNT | awk '{ printf "%.4f", $1 / 10 }')
echo -e "Outgoing: $red2$MAKERAMOUNT $yourcoin$nc2"
echo -e "Incoming: $grn2~$AMOUNT $theircoin$nc2"
printf "Outgoing: $red2$MAKERAMOUNT $yourcoin$nc2\n"
printf "Incoming: $grn2~$AMOUNT $theircoin$nc2\n"
sed -i -z "s/AMOUNT/$MAKERAMOUNT/g" $maker
sed -i -z "s/RATE/$MAKER_RATE/" $maker
sed -i -z "s/RATE/$RATE/" $taker
@ -266,8 +274,8 @@ apply_config() {
TAKERAMOUNT=$(echo $AMOUNT $MAKER_RATE | awk '{ printf "%.8f\n", $1 * $2 }')
OB_AMOUNT=$AMOUNT
INCREMENT=$(echo $OB_AMOUNT | awk '{ printf "%.4f", $1 / 10 }')
echo -e "Outgoing: $red2$AMOUNT $yourcoin$nc2"
echo -e "Incoming: $grn2~$TAKERAMOUNT $theircoin$nc2"
printf "Outgoing: $red2$AMOUNT $yourcoin$nc2\n"
printf "Incoming: $grn2~$TAKERAMOUNT $theircoin$nc2\n"
sed -i -z "s/AMOUNT/$TAKERAMOUNT/g" $taker
sed -i -z "s/RATE/$TAKER_RATE/" $taker
sed -i -z "s/RATE/$RATE/" $maker
@ -284,28 +292,24 @@ revert_config() {
check_bids() {
# oneshot. Check for matching offers before posting one
revert_config
apply_config
FOUNDBID=$(python createoffers.py --configfile $taker --statefile $state --port=$PORT --oneshot --debug | grep "New bid")
FOUNDBID=$(python3 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
printf "Checking for a matching offer\n"
printf "No matching offers found $red2:@ !!!$nc2\nBid quantity too$red2 low$nc2 to post to order book.\nTrying again in 30 seconds\n"
sleep 30
$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")
ORDERPLACED=$(python3 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\nOffer expires in 4hrs\n";$nc
else
revert_config
$red"Placing Order failed. Try again$nc2\n"
fi
fi
@ -328,8 +332,8 @@ recheck_bids() {
coin
coin_prompt_sell
echo -e "Buying: $grn2$theircapital$nc2"
echo -e "Selling: $red2$yourcapital$nc2"
printf "\nBuying: $grn2$theircapital$nc2"
printf "\nSelling: $red2$yourcapital$nc2\n"
#2. Set rates
# Pull Market rate

View file

@ -1,10 +1,10 @@
#!/bin/bash
## Prompt for user input
echo -e "\n\nThe following coins can be disabled (case sensitive)\nbitcoin\ndash\ndecred\nfiro\nlitecoin\nmonero\npivx\nwownero\n"
printf "\n\nThe following coins can be disabled (case sensitive)\nbitcoin\ndash\ndecred\nfiro\nlitecoin\nmonero\npivx\nwownero\n\n"
read -p 'Full name of coin to disable [example: wownero] ' disablecoin
## Confirm
echo -e "\nDisable $disablecoin on your BasicSwap install, correct? Press any key to continue. CTRL-C to exit"
printf "\nDisable $disablecoin on your BasicSwap install, correct? Press any key to continue. CTRL-C to exit\n"
read
## Disable the coin
basicswap-prepare --datadir=$SWAP_DATADIR --disablecoin=$disablecoin

View file

@ -1,9 +1,9 @@
#!/bin/bash
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \e[0m"
## Clone basicswap git
cd $SWAP_DATADIR
@ -12,12 +12,12 @@ cd $SWAP_DATADIR/basicswap
## Macos
if [[ $MACOS ]]; then
$SWAP_DATADIR/venv/bin/pip install certifi
$SWAP_DATADIR/venv/bin/pip3 install certifi
fi
## Install basicswap, coincurve, and pip dependencies
$SWAP_DATADIR/venv/bin/pip install -r requirements.txt --require-hashes
$SWAP_DATADIR/venv/bin/pip install .
$SWAP_DATADIR/venv/bin/pip3 install -r requirements.txt --require-hashes
$SWAP_DATADIR/venv/bin/pip3 install .
## Decide a source for Monero's restore height
if [[ "$xmrrestoreheight" ]]; then
@ -53,12 +53,12 @@ elif [[ "$monerod_addr" ]]; then
# Setup new install and use a remote monero node
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
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor
else
# Setup new install using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
$red"\n\nMake note of your seed above\n"; $nocolor
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor
fi

View file

@ -1,9 +1,9 @@
#!/bin/bash
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \e[0m"
## Clone basicswap git
cd $SWAP_DATADIR
@ -12,12 +12,12 @@ cd $SWAP_DATADIR/basicswap
## Macos
if [[ $MACOS ]]; then
$SWAP_DATADIR/venv/bin/pip install certifi
$SWAP_DATADIR/venv/bin/pip3 install certifi
fi
## Install basicswap, coincurve, and pip dependencies
torsocks $SWAP_DATADIR/venv/bin/pip install -r requirements.txt --require-hashes
torsocks $SWAP_DATADIR/venv/bin/pip install .
torsocks $SWAP_DATADIR/venv/bin/pip3 install -r requirements.txt --require-hashes
torsocks $SWAP_DATADIR/venv/bin/pip3 install .
## Decide a source for Monero's restore height
if [[ "$xmrrestoreheight" ]]; then
@ -53,12 +53,12 @@ elif [[ "$monerod_addr" ]]; then
# Setup new install and use a remote monero node
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
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor
else
# Setup new install using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
$red"\n\nMake note of your seed above\n"; $nocolor
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor
fi

View file

@ -16,8 +16,8 @@ fi
#git checkout master
git pull
$SWAP_DATADIR/venv/bin/pip install -r requirements.txt --require-hashes
$SWAP_DATADIR/venv/bin/pip install .
$SWAP_DATADIR/venv/bin/pip3 install -r requirements.txt --require-hashes
$SWAP_DATADIR/venv/bin/pip3 install .
# Update Coin Cores
$HOME/.local/bin/bsx/auto_coinupd8.sh

View file

@ -2,9 +2,9 @@
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"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \e[0m"
# Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
@ -24,9 +24,9 @@ title="BasicSwapDEX Installer"
COLUMNS=$(tput cols)
title_size=${#title}
span=$(((COLUMNS + title_size) / 2))
printf "%${COLUMNS}s" " " | tr " " "*"
printf "%${COLUMNS}s" " " | tr " " "#"
printf "%${span}s\n" "$title"
printf "%${COLUMNS}s" " " | tr " " "*"
printf "%${COLUMNS}s" " " | tr " " "#"
$nocolor
# Detect Operating system
@ -36,11 +36,11 @@ DEPENDENCY=""
TAILS=""
check_tails() {
if [ $USER == amnesia ]; then
$green"\nDetected Tails\n";$nocolor
if [[ $USER == amnesia ]]; then
$green"\n\nDetected Tails";$nocolor
TAILS=1
else
$green"\nDetected Debian\n";$nocolor
$green"\n\nDetected Debian";$nocolor
fi
}
@ -48,7 +48,7 @@ detect_os_arch() {
if [[ $(uname -s) = "Darwin" ]]; then
# MacOS
export MACOS=1
if type -P brew > /dev/null; then
if type -p brew > /dev/null; then
$green"Homebrew is installed\n";$nc
INSTALL="brew install"
else
@ -56,27 +56,27 @@ detect_os_arch() {
INSTALL="curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | /bin/bash && brew install"
fi
DEPENDENCY="python gnupg pkg-config"
$green"\nDetected MacOS\n";$nocolor
elif type -P apt > /dev/null; then
$green"\n\nDetected MacOS";$nocolor
elif type -p apt > /dev/null; then
check_tails
# Debian / Ubuntu / Mint
INSTALL="sudo apt install"
UPDATE="sudo apt update"
DEPENDENCY="python3-pip python3-venv gnupg pkg-config"
elif type -P dnf > /dev/null; then
elif type -p dnf > /dev/null; then
# Fedora
INSTALL="sudo dnf install"
UPDATE="sudo dnf check-update"
DEPENDENCY="python3-virtualenv python3-pip python3-devel gnupg2 pkgconf"
$green"\nDetected Fedora\n";$nocolor
elif type -P pacman > /dev/null; then
$green"\n\nDetected Fedora";$nocolor
elif type -p pacman > /dev/null; then
# Arch Linux
INSTALL="sudo pacman -S"
UPDATE="sudo pacman -Syu"
DEPENDENCY="python-pipenv gnupg pkgconf base-devel"
$green"\nDetected Arch Linux\n";$nocolor
DEPENDENCY="curl python-pipenv gnupg pkgconf base-devel"
$green"\n\nDetected Arch Linux";$nocolor
else
$red"Failed to detect OS. Unsupported or unknown distribution.\nInstall Failed.";$nocolor
$red"\nFailed to detect OS. Unsupported or unknown distribution.\nInstall Failed.\n";$nocolor
exit
fi
}
@ -84,21 +84,21 @@ detect_os_arch() {
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"
printf "\n\nInstalling dependencies\nPress CTRL-C at password prompt(s) to skip. If skipped, you must install the dependencies manually before proceeding\n\n"
$green"$UPDATE\n$INSTALL $DEPENDENCY curl automake libtool jq\n"; $nocolor
$UPDATE
$INSTALL $DEPENDENCY curl automake libtool jq
$INSTALL $DEPENDENCY automake libtool jq
# Enable tor
echo -e "\n\n[1] Tor ON (requires sudo)\n[2] Tor OFF\n"
printf "\n[1] Tor ON (requires sudo)\n[2] Tor OFF\n"
until [[ "$tor_on" =~ ^[12]$ ]]; do
read -p 'Select an option: [1|2] ' tor_on
case $tor_on in
1)
$green"\nBasicSwapDEX will use Tor";$nocolor
$green"BasicSwapDEX will use Tor\n";$nocolor
;;
2)
$red"\nBasicSwapDEX will NOT use Tor";$nocolor
$red"BasicSwapDEX will NOT use Tor\n";$nocolor
;;
*)
$red"You must answer 1 or 2\n";$nocolor
@ -107,22 +107,22 @@ read -p 'Select an option: [1|2] ' tor_on
done
## Particl restore Seed
echo -e "\n\n[1] New Install (default)\n[2] Restore from Particl Seed\n"
printf "\n[1] New Install (default)\n[2] Restore from Particl Seed\n"
until [[ "$restore" =~ ^[12]$ ]]; do
read -p 'Select an option: [1|2] ' restore
case $restore in
1)
$green"\nInstalling BasicSwapDEX\n"; $nocolor
$green"Installing BasicSwapDEX\n"; $nocolor
;;
2)
until [[ "$wordcount" = "24" ]]; do
read -p $'\nEnter your Particl Seed\n[example: word word word word word...] ' particl_mnemonic
wordcount=$(echo $particl_mnemonic | wc -w)
if [[ $wordcount = 24 ]]; then
echo -e "Restoring BasicSwapDEX"
printf "Restoring BasicSwapDEX\n"
$green"$particl_mnemonic\n";$nocolor
else
$red"Try again. Seed must be 24 words"; $nocolor
$red"Try again. Seed must be 24 words\n"; $nocolor
fi
done
;;
@ -137,13 +137,13 @@ if [[ $particl_mnemonic ]]; then
read -p $'\nEnter a restore height for your BasicSwap XMR wallet? [Y/n] ' height
case $height in
n|N)
$red"\nNot using a custom XMR Restore height";$nocolor
$red"Not using a custom XMR Restore height\n";$nocolor
;;
*)
until [[ "$xmrrestoreheight" =~ ^[0-9]{1,7}$ ]]; do
read -p $'Enter your Monero Restore Height [example: 2548568] ' xmrrestoreheight
if [[ $xmrrestoreheight =~ ^[0-9]{7}$ ]]; then
$green"\nYour XMR Restore height: $xmrrestoreheight"; $nocolor
$green"Your XMR Restore height: $xmrrestoreheight\n"; $nocolor
else
$red"Try again. Must be 1-7 digits\n"; $nocolor
fi
@ -153,7 +153,7 @@ if [[ $particl_mnemonic ]]; then
fi
## Configure Monero
echo -e "\n[1] Connect to a Monero node\n[2] Allow BasicSwapDEX to run a Monero node (+70GB)\n"
printf "\n[1] Connect to a Monero node\n[2] Allow BasicSwapDEX to run a Monero node (+70GB)\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
case $l in
@ -161,16 +161,16 @@ read -p 'Select an option [1|2]: ' l
until [[ $checknode ]]; do
read -p 'Enter Address of Monero node [example: 192.168.1.123] ' monerod_addr
read -p 'Enter RPC Port for the Monero node [example: 18081] ' monerod_port
checknode=$(curl -sk http://$monerod_addr:$monerod_port/get_info)
checknode=$(curl -sk http://$monerod_addr:$monerod_port/get_info | jq .height)
if [[ $checknode ]]; then
$green"\nSuccessfully connected to the XMR node @ $monerod_addr:$monerod_port"; $nocolor
$green"Successfully connected to the XMR node @ $monerod_addr:$monerod_port\n"; $nocolor
else
$red"\nThe node at $monerod_addr:$monerod_port is not accessible. Try again\n\n"; $nocolor
$red"The node at $monerod_addr:$monerod_port is not accessible. Try again\n"; $nocolor
fi
done
;;
2)
$green"\nBasicSwapDEX will run the Monero node for you."; $nocolor
$green"BasicSwapDEX will run the Monero node for you.\n"; $nocolor
;;
*)
$red"You must answer 1 or 2\n"; $nocolor
@ -179,7 +179,7 @@ read -p 'Select an option [1|2]: ' l
done
## Begin Install
echo -e "\n\nInstalling BasicSwapDEX"
printf "\nInstalling BasicSwapDEX\n"
read -p 'Press Enter to continue, or CTRL-C to exit.'
# Quest to make trasher happy