Compare commits

...

13 commits

Author SHA1 Message Date
nahuhh
8c50076b09 later 2024-11-11 15:54:25 +00:00
nahuhh
c163ac2ce4 placeorders: use python to check offer size 2024-11-10 14:52:21 +00:00
nahuhh
98da79699c tails: persistent datadir 2024-11-09 20:55:47 +00:00
nahuhh
fc7e543162 base: add error checking 2024-11-09 20:55:40 +00:00
nahuhh
c319bcfcd3 tails: basicswap-prepare 2024-11-09 04:38:18 +00:00
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
nahuhh
e2a574cf9b install: mac/zsh doesn't like cp -t 2024-11-07 17:48:57 +00:00
nahuhh
4b7cbe98b4 install: fix mac detection 2024-11-07 17:08:42 +00:00
nahuhh
b0a83f63a3 autoupd8: use for loop 2024-10-19 11:16:05 +00:00
nahuhh
82fd60cd3c setup: update tails 2024-10-18 23:15:52 +00:00
nahuhh
e9eee1c826 install: cp scripts 2024-10-18 23:15:00 +00:00
16 changed files with 335 additions and 298 deletions

View file

@ -1,5 +1,9 @@
#!/bin/bash #!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
TAILS=1
fi
# Colors # Colors
red="echo -e -n \e[31;1m" red="echo -e -n \e[31;1m"

View file

@ -1,16 +1,19 @@
#!/bin/bash #!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \e[0m"
# Check if basicswap is running # Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid) bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid) bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor $red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit exit
@ -18,7 +21,7 @@ if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
fi fi
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 until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l read -p 'Select an option [1|2]: ' l
case $l in case $l in

View file

@ -1,16 +1,19 @@
#!/bin/bash #!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \e[0m"
# Check if basicswap is running # Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid) bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid) bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor $red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit exit
@ -18,7 +21,7 @@ if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
fi fi
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 until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l read -p 'Select an option [1|2]: ' l
case $l in case $l in

View file

@ -1,16 +1,19 @@
#!/bin/bash #!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \e[0m"
# Check if basicswap is running # Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid) bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid) bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor $red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit exit
@ -18,7 +21,7 @@ if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
fi fi
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 until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l read -p 'Select an option [1|2]: ' l
case $l in case $l in

View file

@ -1,15 +1,18 @@
#!/bin/bash #!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \e[0m"
# Check if basicswap is running # Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid) 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 if ! [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX must be running.\n"; $nocolor $red"\nError: BasicSwapDEX must be running.\n"; $nocolor
exit exit
@ -19,7 +22,7 @@ else
exit exit
fi 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/ cd $SWAP_DATADIR/basicswap/scripts/
./placeorders.sh ./placeorders.sh

View file

@ -1,16 +1,19 @@
#!/bin/bash #!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \e[0m"
# Check if basicswap is running # Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid) bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid) bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor $red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit exit
@ -18,7 +21,7 @@ if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
fi fi
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 until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l read -p 'Select an option [1|2]: ' l
case $l in case $l in

View file

@ -1,16 +1,19 @@
#!/bin/bash #!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \e[0m"
# Check if basicswap is running # Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid) bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid)
if [[ $bsx_pid ]]; then if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid) bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor $red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit exit

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
## Prompt for user input ## 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 read -p 'Full name of coin to add [example: litecoin] ' addcoin
## Confirm ## Confirm
read -p $'\nAdd '$addcoin' to your BasicSwap install, correct? Press ENTER to continue. CTRL-C to exit' read -p $'\nAdd '$addcoin' to your BasicSwap install, correct? Press ENTER to continue. CTRL-C to exit'

View file

@ -1,85 +1,46 @@
#!/bin/bash #!/bin/bash
#set -x #set -x
SWAP_DATADIR=$HOME/coinswaps export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
BINDIR=$SWAP_DATADIR/bin
echo "Checking for Coin updates" && sleep 1 echo "Checking for Coin updates" && sleep 1
if [[ -d $SWAP_DATADIR/bin/bitcoin ]]; then chain=(
BTC=$($SWAP_DATADIR/bin/bitcoin/bitcoind --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) bitcoin
if [[ -z $BTC ]]; then dash
echo "Updating Bitcoin" decred
Bitcoin="bitcoin," firo
litecoin
particl
pivx
monero
wownero
)
list=""
select=""
for coin in "${chain[@]}"; do
if [[ -d $BINDIR/$coin ]]; then
if [[ $coin == decred ]]; then
UPDATE=$($BINDIR/$coin/dcrd --version | head -n 1 | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
else
UPDATE=$($BINDIR/$coin/"$coin"d --version | head -n 1 | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
fi
if [[ -z $UPDATE ]]; then
select+="$coin,"
list=${select%,}
fi
fi fi
fi done
if [[ -d $SWAP_DATADIR/bin/dash ]]; then echo "Updating $list"
DASH=$($SWAP_DATADIR/bin/dash/dashd --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
if [[ -z $DASH ]]; then
echo "Updating Dash"
Dash="dash,"
fi
fi
if [[ -d $SWAP_DATADIR/bin/decred ]]; then if [[ -n $select ]]; then
DCR=$($SWAP_DATADIR/bin/decred/dcrd --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
if [[ -z $DCR ]]; then
echo "Updating Decred"
Decred="decred,"
fi
fi
if [[ -d $SWAP_DATADIR/bin/firo ]]; then
FIRO=$($SWAP_DATADIR/bin/firo/firod --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
if [[ -z $FIRO ]]; then
echo "Updating Firo"
Firo="firo,"
fi
fi
if [[ -d $SWAP_DATADIR/bin/litecoin ]]; then
LTC=$($SWAP_DATADIR/bin/litecoin/litecoind --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
if [[ -z $LTC ]]; then
echo "Updating Litecoin"
Litecoin="litecoin,"
fi
fi
if [[ -d $SWAP_DATADIR/bin/particl ]]; then
PART=$($SWAP_DATADIR/bin/particl/particld --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
if [[ -z $PART ]]; then
echo "Updating Particl"
fi
fi
if [[ -d $SWAP_DATADIR/bin/pivx ]]; then
PIVX=$($SWAP_DATADIR/bin/pivx/pivxd --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
if [[ -z $PIVX ]]; then
echo "Updating PIVX"
Pivx="pivx,"
fi
fi
if [[ -d $SWAP_DATADIR/bin/monero ]]; then
XMR=$($SWAP_DATADIR/bin/monero/monerod --version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
if [[ -z $XMR ]]; then
echo "Updating Monero"
Monero="monero,"
fi
fi
if [[ -d $SWAP_DATADIR/bin/wownero ]]; then
WOW=$($SWAP_DATADIR/bin/wownero/wownerod --version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions)
if [[ -z $WOW ]]; then
echo "Updating Wownero"
Wownero="wownero,"
fi
fi
sleep 1
if [[ -n $Bitcoin ]] || [[ -n $Dash ]] || [[ -n $Decred ]] || [[ -n $Firo ]] || [[ -n $Litecoin ]] || [[ -n $Particl ]] || [[ -n $Pivx ]] || [[ -n $Monero ]] || [[ -n $Wownero ]]; then
. $SWAP_DATADIR/venv/bin/activate . $SWAP_DATADIR/venv/bin/activate
basicswap-prepare --datadir=$SWAP_DATADIR --preparebinonly --withcoins="$Bitcoin$Dash$Decred$Firo$Litecoin$Pivx$Monero$Wownero"particl basicswap-prepare --datadir=$SWAP_DATADIR --preparebinonly --withcoins=$list
else else
echo "Coin Cores are up to date" echo "Coin Cores are up to date"
fi fi

View file

@ -1,36 +1,58 @@
#!/bin/bash #!/bin/bash
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \e[0m"
# Detect Operating system # Detect Operating system
INSTALL="" INSTALL=""
UPDATE="" 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() { 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 # Debian / Ubuntu / Mint
INSTALL="sudo apt install -y" INSTALL="sudo apt install"
UPDATE="sudo apt update" UPDATE="sudo apt update"
$green"\nDetected Debian\n";$nocolor INIT_TOR=$SYSTEMD_TOR
elif type -P dnf > /dev/null; then elif type -p dnf > /dev/null; then
# Fedora # Fedora
INSTALL="sudo dnf install -y" INSTALL="sudo dnf install"
UPDATE="sudo dnf check-update" UPDATE="sudo dnf check-update"
$green"\nDetected Fedora\n";$nocolor INIT_TOR=$SYSTEMD_TOR
elif type -P pacman > /dev/null; then $green"\n\nDetected Fedora";$nocolor
elif type -p pacman > /dev/null; then
# Arch Linux # Arch Linux
INSTALL="sudo pacman -S" INSTALL="sudo pacman -S"
UPDATE="sudo pacman -Syu" UPDATE="sudo pacman -Syu"
$green"\nDetected Arch Linux\n";$nocolor INIT_TOR=$SYSTEMD_TOR
elif type -P brew > /dev/null; then $green"\n\nDetected Arch Linux";$nocolor
# MacOS
INSTALL="brew install"
$green"\nDetected MacOS\n";$nocolor
else 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 exit
fi fi
} }
@ -38,8 +60,8 @@ detect_os_arch() {
detect_os_arch detect_os_arch
# Check for Tor installation # Check for Tor installation
if type -P tor > /dev/null; then if type -p tor > /dev/null; then
echo -e "\nTor is already installed :)" printf "\nTor is already installed :)\n"
else else
# Install and configure tor # Install and configure tor
echo "Installing Tor..." echo "Installing Tor..."
@ -48,7 +70,7 @@ else
fi fi
# Create HashedControlPassword # 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 read -p "Enter a (new) tor control password [example: 123123] " torcontrolpass
# Edit /etc/tor/torrc # Edit /etc/tor/torrc
torhashedpass=$(tor --hash-password $torcontrolpass) torhashedpass=$(tor --hash-password $torcontrolpass)
@ -57,9 +79,9 @@ skipcontrol=$(sudo grep -x "$enabledcontrol" /etc/tor/torrc)
echo "Check torrc for enabled ControlPort" echo "Check torrc for enabled ControlPort"
if [[ $skipcontrol ]]; then if [[ $skipcontrol ]]; then
# Use Existing enabled ControlPort and append HashedControlPassword # 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 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 fi
# Restart tor to apply # Restart tor to apply

View file

@ -26,13 +26,13 @@ MIN_TAKER=""
############################ ############################
# Colors # Colors
cy="echo -e -n \e[36;1m" cy="printf \e[36;1m"
cy2="\e[36;1m" cy2="\e[36;1m"
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
red2="\e[31;1m" red2="\e[31;1m"
grn="echo -e -n \e[32;1m" grn="printf \e[32;1m"
grn2="\e[32;1m" grn2="\e[32;1m"
nc="echo -e -n \e[0m" nc="printf \e[0m"
nc2="\e[0m" nc2="\e[0m"
# Choose Coins # Choose Coins
@ -48,7 +48,7 @@ coin_prompt_sell() {
} }
coin() { coin() {
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 until [[ $coin =~ ^[1-9]$ ]]; do
read -p 'Select an option: ' coin read -p 'Select an option: ' coin
case $coin in case $coin in
@ -88,7 +88,7 @@ coin() {
coinname="Wownero" coinname="Wownero"
coinsymbol="WOW" coinsymbol="WOW"
;; ;;
*) $red "\nYou must answer 1-9\n"; $nc *) $red"\nYou must answer 1-9\n"; $nc
;; ;;
esac esac
done done
@ -126,48 +126,56 @@ book_min() {
} }
set_fiat() { 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 read -p 'Select an option: ' fiat_select
case $fiat_select in case $fiat_select in
1) FIAT=USD 1) FIAT=USD
fiat=usd fiat=usd
echo "USD"
;; ;;
2) FIAT=EUR 2) FIAT=EUR
fiat=eur fiat=eur
echo "EUR"
;; ;;
3) FIAT=CAD 3) FIAT=CAD
fiat=cad fiat=cad
echo "CAD"
;; ;;
4) FIAT=AUD 4) FIAT=AUD
fiat=aud fiat=aud
echo "AUD"
;; ;;
5) read -p 'Please enter the lowecase 3 character currency code [example: jpy] ' FIAT 5) read -p 'Please enter the lowecase 3 character currency code [example: jpy] ' FIAT
fiat=$FIAT fiat=$FIAT
;; ;;
*) FIAT=USD *) FIAT=USD
fiat=usd fiat=usd
echo "USD"
;; ;;
esac esac
} }
coin_price() { coin_price() {
echo -e "\nCurrent Market Rates are.." printf "\n\nCurrent Market Rates are..\n"
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") curl -s "https://api.coingecko.com/api/v3/simple/price?ids=$THEIR_COIN,$YOUR_COIN&vs_currencies=$fiat" > rates.txt
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") 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 }' ) TAKER_RATE=$(echo $THEIR_FIAT $YOUR_FIAT | awk '{ printf "%.8f\n", $1 / $2 }' )
MAKER_RATE=$(echo $TAKER_RATE | awk '{ printf "%.8f\n", 1 / $1 }') 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"$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" $cy"$YOUR_FIAT $FIAT$nc2/$red2$yourcoin$nc2 which is $grn2$MAKER_RATE $theircoin$nc2/$red2$yourcoin$nc2\n"
rm rates.txt
} }
buy_sell() { 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 until [[ $BUYORSELL =~ ^[12]$ ]]; do
read -p 'Select an option: ' BUYORSELL read -p 'Select an option: ' BUYORSELL
case $BUYORSELL in case $BUYORSELL in
1) read -p "How much $theircapital do you want to BUY? [example: 1] " AMOUNT 1) read -p $'\nHow much '"$theircapital"' do you want to BUY? [example: 1] ' AMOUNT
$cy "\nRate you will pay:\n";$nc $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" 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 read -p 'Select an option: ' RATESEL
case $RATESEL in case $RATESEL in
1) read -p $"At what rate would you like to Pay? [example: $TAKER_RATE] " RATE 1) read -p $"At what rate would you like to Pay? [example: $TAKER_RATE] " RATE
@ -191,12 +199,12 @@ buy_sell() {
;; ;;
esac esac
MAKER_RATE=$(echo $RATE | awk '{ printf "%.8f\n", 1 / $1 }') 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)" printf "\nPaying: $red2 $PRICE$FIAT$nc2 which is $red2($RATE $yourcoin$nc2/$grn2$theircoin$nc2)\n"
echo -e "Rate to be paid: $grn2$MAKER_RATE $theircoin$nc2/$red2$yourcoin$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 2) read -p $'\nHow much YOUR '"$yourcapital"' do you want to SELL [example: 1] ' AMOUNT
$cy "\nRate to charge:\n";$nc $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" 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 read -p 'Select an option: ' RATESEL
case $RATESEL in case $RATESEL in
1) read -p $"Enter specific rate to Charge? [example: $MAKER_RATE] " RATE 1) read -p $"Enter specific rate to Charge? [example: $MAKER_RATE] " RATE
@ -220,9 +228,9 @@ buy_sell() {
;; ;;
esac esac
TAKER_RATE=$(echo $RATE | awk '{ printf "%.8f\n", 1 / $1 }') 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 esac
done done
@ -232,7 +240,7 @@ buy_sell() {
split_orders() { split_orders() {
if [ $ALLOW_SPLIT_ORDERS = true ]; then if [ $ALLOW_SPLIT_ORDERS = true ]; then
MIN_SWAP=$(echo $AMOUNT $MAXBIDS | awk '{ printf "%.0f\n", $1 / $2 }') 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 else
MIN_SWAP=$AMOUNT MIN_SWAP=$AMOUNT
$red"One order only. Not Recommended";$nc $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/COIN_TO_BUY/$theircapital/" $taker $maker
sed -i -z "s/PERCENT/$PERCENT/" $maker sed -i -z "s/PERCENT/$PERCENT/" $maker
sed -i -z "s/MAXBIDS/$MAXBIDS/" $taker sed -i -z "s/MAXBIDS/$MAXBIDS/" $taker
echo -e "\nMinumum amt per swap = $grn2$MIN_TAKER $theircoin$nc2" printf "\nMinumum amt per swap = $grn2$MIN_TAKER $theircoin$nc2\n"
echo -e " = $red2$MIN_SWAP $yourcoin$nc2\n" printf " = $red2$MIN_SWAP $yourcoin$nc2\n\n"
if [[ $BUYORSELL = 1 ]]; then if [[ $BUYORSELL = 1 ]]; then
MAKERAMOUNT=$(echo $AMOUNT $MAKER_RATE | awk '{ printf "%.8f\n", $1 / $2 }') MAKERAMOUNT=$(echo $AMOUNT $MAKER_RATE | awk '{ printf "%.8f\n", $1 / $2 }')
OB_AMOUNT=$MAKERAMOUNT OB_AMOUNT=$MAKERAMOUNT
INCREMENT=$(echo $OB_AMOUNT | awk '{ printf "%.4f", $1 / 10 }') INCREMENT=$(echo $OB_AMOUNT | awk '{ printf "%.4f", $1 / 100 }') # TODO make offers repeat
echo -e "Outgoing: $red2$MAKERAMOUNT $yourcoin$nc2" printf "Outgoing: $red2$MAKERAMOUNT $yourcoin$nc2\n"
echo -e "Incoming: $grn2~$AMOUNT $theircoin$nc2" printf "Incoming: $grn2~$AMOUNT $theircoin$nc2\n"
sed -i -z "s/AMOUNT/$MAKERAMOUNT/g" $maker sed -i -z "s/AMOUNT/$MAKERAMOUNT/g" $maker
sed -i -z "s/RATE/$MAKER_RATE/" $maker sed -i -z "s/RATE/$MAKER_RATE/" $maker
sed -i -z "s/RATE/$RATE/" $taker sed -i -z "s/RATE/$RATE/" $taker
@ -265,9 +273,9 @@ apply_config() {
else else
TAKERAMOUNT=$(echo $AMOUNT $MAKER_RATE | awk '{ printf "%.8f\n", $1 * $2 }') TAKERAMOUNT=$(echo $AMOUNT $MAKER_RATE | awk '{ printf "%.8f\n", $1 * $2 }')
OB_AMOUNT=$AMOUNT OB_AMOUNT=$AMOUNT
INCREMENT=$(echo $OB_AMOUNT | awk '{ printf "%.4f", $1 / 10 }') INCREMENT=$(echo $OB_AMOUNT | awk '{ printf "%.4f", $1 / 100 }') # TODO make offers repeat
echo -e "Outgoing: $red2$AMOUNT $yourcoin$nc2" printf "Outgoing: $red2$AMOUNT $yourcoin$nc2\n"
echo -e "Incoming: $grn2~$TAKERAMOUNT $theircoin$nc2" printf "Incoming: $grn2~$TAKERAMOUNT $theircoin$nc2\n"
sed -i -z "s/AMOUNT/$TAKERAMOUNT/g" $taker sed -i -z "s/AMOUNT/$TAKERAMOUNT/g" $taker
sed -i -z "s/RATE/$TAKER_RATE/" $taker sed -i -z "s/RATE/$TAKER_RATE/" $taker
sed -i -z "s/RATE/$RATE/" $maker sed -i -z "s/RATE/$RATE/" $maker
@ -284,28 +292,25 @@ revert_config() {
check_bids() { check_bids() {
# oneshot. Check for matching offers before posting one # oneshot. Check for matching offers before posting one
revert_config
apply_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")
POSTOFFER=$(python3 -c "print($OB_AMOUNT < $OB_MIN)")
if [[ $FOUNDBID ]]; then if [[ $FOUNDBID ]]; then
$grn"Placed bid successfully! Check BasicSwapDEX to confirm\n";$nc $grn"Placed bid successfully! Check BasicSwapDEX to confirm\n";$nc
elif [[ $OB_AMOUNT < $OB_MIN && -z $FOUNDBID ]]; then elif [[ $POSTOFFER == True ]] && [[ -z $FOUNDBID ]]; then
echo -e "Checking for a matching offer" printf "Checking for a matching offer\n"
echo -e "No matching offers found $red2:@ !!!$nc2\nBid quantity too$red2 low$nc2 to post to order book.\nTrying again in 30 seconds" 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 2 sleep 30
revert_config
sleep 28
apply_config
$cy"Rechecking bids\n";$nc $cy"Rechecking bids\n";$nc
recheck_bids recheck_bids
else else
# Post as limit order on the book # Post as limit order on the book
$cy"No matching offers found. Posting to the orderbook\n";$nc $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 if [[ $ORDERPLACED ]]; then
revert_config
$grn"OFFER POSTED! Please check BasicSwapDEX to confirm\nOffer expires in 4hrs\n";$nc $grn"OFFER POSTED! Please check BasicSwapDEX to confirm\nOffer expires in 4hrs\n";$nc
else else
revert_config
$red"Placing Order failed. Try again$nc2\n" $red"Placing Order failed. Try again$nc2\n"
fi fi
fi fi
@ -328,8 +333,8 @@ recheck_bids() {
coin coin
coin_prompt_sell coin_prompt_sell
echo -e "Buying: $grn2$theircapital$nc2" printf "\nBuying: $grn2$theircapital$nc2"
echo -e "Selling: $red2$yourcapital$nc2" printf "\nSelling: $red2$yourcapital$nc2\n"
#2. Set rates #2. Set rates
# Pull Market rate # Pull Market rate

View file

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
## Prompt for user input ## 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 read -p 'Full name of coin to disable [example: wownero] ' disablecoin
## Confirm ## 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 read
## Disable the coin ## Disable the coin
basicswap-prepare --datadir=$SWAP_DATADIR --disablecoin=$disablecoin basicswap-prepare --datadir=$SWAP_DATADIR --disablecoin=$disablecoin

View file

@ -1,34 +1,28 @@
#!/bin/bash #!/bin/bash
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \e[0m"
## Clone basicswap git ## Clone basicswap git
cd $SWAP_DATADIR cd $SWAP_DATADIR
git clone https://github.com/basicswap/basicswap if [[ -d basicswap ]]; then
cd $SWAP_DATADIR/basicswap cd $SWAP_DATADIR/basicswap
git pull || { $red"Failed to pull repo. Installation aborted"; exit; }
else
git clone https://github.com/basicswap/basicswap || { $red"Failed to clone repo. Please run the installer again"; exit; }
cd $SWAP_DATADIR/basicswap
fi
## Macos ## Macos
if [[ $MACOS ]]; then if [[ $MACOS ]]; then
$SWAP_DATADIR/venv/bin/pip install certifi $SWAP_DATADIR/venv/bin/pip3 install certifi
fi fi
## Install basicswap, coincurve, and pip dependencies ## Install basicswap, coincurve, and pip dependencies
$SWAP_DATADIR/venv/bin/pip install -r requirements.txt --require-hashes $SWAP_DATADIR/venv/bin/pip3 install -r requirements.txt --require-hashes
$SWAP_DATADIR/venv/bin/pip install . $SWAP_DATADIR/venv/bin/pip3 install .
## Decide a source for Monero's restore height
if [[ "$xmrrestoreheight" ]]; then
CURRENT_XMR_HEIGHT=$xmrrestoreheight
elif [[ "$monerod_addr" ]]; then
# Use custom Monero node
CURRENT_XMR_HEIGHT=$(curl "http://$monerod_addr:$monerod_port/get_info" | jq .height)
else
# Use public node
CURRENT_XMR_HEIGHT=$(curl http://node3.monerodevs.org:18089/get_info | jq .height)
fi
# Use Tor if we want # Use Tor if we want
enable_tor() { enable_tor() {
@ -42,25 +36,29 @@ if [[ "$particl_mnemonic" && "$monerod_addr" ]]; then
# Restore seed # Restore seed
PARTICL_MNEMONIC=$particl_mnemonic PARTICL_MNEMONIC=$particl_mnemonic
XMR_RPC_HOST=$monerod_addr 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" basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 --particl_mnemonic="$PARTICL_MNEMONIC" || { $red"Installation failed. Try again"; exit; }
$red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
enable_tor enable_tor
elif [[ "$particl_mnemonic" ]]; then elif [[ "$particl_mnemonic" ]]; then
# Restore seed # Restore seed
PARTICL_MNEMONIC=$particl_mnemonic PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000 --particl_mnemonic="$PARTICL_MNEMONIC" basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 --particl_mnemonic="$PARTICL_MNEMONIC" || { $red"Installation failed. Try again"; exit; }
$red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
enable_tor enable_tor
elif [[ "$monerod_addr" ]]; then elif [[ "$monerod_addr" ]]; then
# Setup new install and use a remote monero node # Setup new install and use a remote monero node
XMR_RPC_HOST=$monerod_addr 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 basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 || { $red"Installation failed. Try again"; exit; }
$red"\n\nMake note of your seed above\n"; $nocolor $red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor enable_tor
else else
# Setup new install using local nodes # Setup new install using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000 basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 || { $red"Installation failed. Try again"; exit; }
$red"\n\nMake note of your seed above\n"; $nocolor $red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor enable_tor
fi fi
$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 $green"Install complete.\n\nUse 'basicswap-bash' to run, 'bsx-update' to update, and 'bsx-addcoin' to add a coin\n\n";$nocolor
$red"You may have to logout / login or open a new terminal window for the commands to be detected\n";$nocolor $red"You may have to logout / login or open a new terminal window for the commands to be detected\n";$nocolor

View file

@ -1,36 +1,29 @@
#!/bin/bash #!/bin/bash
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \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
torsocks $SWAP_DATADIR/venv/bin/pip install . # Tails requires torsocks for pip
## Clone basicswap git ## Clone basicswap git
cd $SWAP_DATADIR cd $SWAP_DATADIR
git clone https://github.com/tecnovert/basicswap -b wow if [[ -d basicswap ]]; then
cd $SWAP_DATADIR/basicswap cd $SWAP_DATADIR/basicswap
## Install basicswap git pull || { $red"Failed to pull repo. Installation aborted"; exit; }
torsocks $SWAP_DATADIR/venv/bin/pip install . # Tails requires torsocks for pip
## Decide a source for Monero's restore height
if [[ "$xmrrestoreheight" ]]; then
CURRENT_XMR_HEIGHT=$xmrrestoreheight
elif [[ "$monerod_addr" ]]; then
# Use custom Monero node
CURRENT_XMR_HEIGHT=$(curl "http://$monerod_addr:$monerod_port/get_info" | jq .height)
else else
# Use public node git clone https://github.com/basicswap/basicswap || { $red"Failed to clone repo. Please run the installer again"; exit; }
CURRENT_XMR_HEIGHT=$(curl http://node3.monerodevs.org:18089/get_info | jq .height) cd $SWAP_DATADIR/basicswap
fi fi
## Macos
if [[ $MACOS ]]; then
$SWAP_DATADIR/venv/bin/pip3 install certifi
fi
## Install basicswap, coincurve, and pip dependencies
torsocks $SWAP_DATADIR/venv/bin/pip3 install -r requirements.txt --require-hashes
torsocks $SWAP_DATADIR/venv/bin/pip3 install .
# Use Tor if we want # Use Tor if we want
enable_tor() { enable_tor() {
if [[ "$tor_on" = 1 ]]; then if [[ "$tor_on" = 1 ]]; then
@ -42,32 +35,30 @@ enable_tor() {
if [[ "$particl_mnemonic" && "$monerod_addr" ]]; then if [[ "$particl_mnemonic" && "$monerod_addr" ]]; then
# Restore seed # Restore seed
PARTICL_MNEMONIC=$particl_mnemonic PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC" XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port \
# Add coins and use a remote monero node basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 --particl_mnemonic="$PARTICL_MNEMONIC" || { $red"Installation failed. Try again"; exit; }
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port \ $red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
enable_tor enable_tor
elif [[ "$particl_mnemonic" ]]; then elif [[ "$particl_mnemonic" ]]; then
# Restore seed # Restore seed
PARTICL_MNEMONIC=$particl_mnemonic PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC" basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 --particl_mnemonic="$PARTICL_MNEMONIC" || { $red"Installation failed. Try again"; exit; }
# Add coins using local nodes $red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
enable_tor enable_tor
elif [[ "$monerod_addr" ]]; then elif [[ "$monerod_addr" ]]; then
# Setup new install and use a remote monero node # 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 basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 || { $red"Installation failed. Try again"; exit; }
$red"\n\nMake note of your seed above\n"; $nocolor $red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor enable_tor
else else
# Setup new install using local nodes # Setup new install using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000 basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 || { $red"Installation failed. Try again"; exit; }
$red"\n\nMake note of your seed above\n"; $nocolor $red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor enable_tor
fi 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\n";$nocolor
$red"You may have to logout / login or open a new terminal window for the commands to be detected\n";$nocolor

View file

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

View file

@ -1,16 +1,41 @@
#/bin/bash #/bin/bash
#set -x
export SWAP_DATADIR=$HOME/coinswaps export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# Colors # Colors
red="echo -e -n \e[31;1m" red="printf \e[31;1m"
green="echo -e -n \e[32;1m" green="printf \e[32;1m"
nocolor="echo -e -n \e[0m" nocolor="printf \e[0m"
# Check if bsx is already installedo
chain=(particl monero wownero dash decred firo litecoin bitcoin bitcoincash pivx)
for coin in "${chain[@]}"; do
if [[ -f "${SWAP_DATADIR}/${coin}/${coin}.conf" ]]; then
printf "Existing configuration file found at ${SWAP_DATADIR}/${coin}/${coin}.conf\n"
abort=1
fi
if [[ -f "${SWAP_DATADIR}/${coin}/${coin}d.conf" ]]; then
printf "Existing configuration file found at ${SWAP_DATADIR}/${coin}/${coin}d.conf\n"
abort=1
fi
done
if [[ -f "${SWAP_DATADIR}/basicswap.json" ]]; then
printf "Existing configuration file(s) found at ${SWAP_DATADIR}/basicswap.json.\n"
abort=1
fi
if [[ $abort ]]; then
$red"Aborting install\n"; $nocolor; exit
fi
# Check if basicswap is running # Check if basicswap is running
if [[ -f $SWAP_DATADIR/particl/particl.pid ]]; then if [[ -f ${SWAP_DATADIR}/particl/particl.pid ]]; then
bsx_pid=$(cat $SWAP_DATADIR/particl/particl.pid) bsx_pid=$(cat ${SWAP_DATADIR}/particl/particl.pid)
if [[ $bsx_pid ]]; then if [[ $bsx_pid ]]; then
bsx_run=$(pidof particld | grep $bsx_pid) bsx_run=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is already installed.\n"; $nocolor $red"\nError: BasicSwapDEX is already installed.\n"; $nocolor
exit exit
@ -24,9 +49,9 @@ title="BasicSwapDEX Installer"
COLUMNS=$(tput cols) COLUMNS=$(tput cols)
title_size=${#title} title_size=${#title}
span=$(((COLUMNS + title_size) / 2)) span=$(((COLUMNS + title_size) / 2))
printf "%${COLUMNS}s" " " | tr " " "*" printf "%${COLUMNS}s" " " | tr " " "#"
printf "%${span}s\n" "$title" printf "%${span}s\n" "$title"
printf "%${COLUMNS}s" " " | tr " " "*" printf "%${COLUMNS}s" " " | tr " " "#"
$nocolor $nocolor
# Detect Operating system # Detect Operating system
@ -36,37 +61,19 @@ DEPENDENCY=""
TAILS="" TAILS=""
check_tails() { check_tails() {
if [ $USER == amnesia ]; then if [[ $USER == amnesia ]]; then
$green"\nDetected Tails\n";$nocolor $green"\n\nDetected Tails";$nocolor
TAILS=1 TAILS=1
else else
$green"\nDetected Debian\n";$nocolor $green"\n\nDetected Debian";$nocolor
fi fi
} }
detect_os_arch() { detect_os_arch() {
if type -P apt > /dev/null; then if [[ $(uname -s) = "Darwin" ]]; 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
# 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
# Arch Linux
INSTALL="sudo pacman -S"
UPDATE="sudo pacman -Syu"
DEPENDENCY="python-pipenv gnupg pkgconf base-devel"
$green"\nDetected Arch Linux\n";$nocolor
elif [[ $(uname -s) = "Darwin" ]]; then
# MacOS # MacOS
export MACOS=1 export MACOS=1
if type -P brew > /dev/null; then if type -p brew > /dev/null; then
$green"Homebrew is installed\n";$nc $green"Homebrew is installed\n";$nc
INSTALL="brew install" INSTALL="brew install"
else else
@ -74,9 +81,33 @@ detect_os_arch() {
INSTALL="curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | /bin/bash && brew install" INSTALL="curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | /bin/bash && brew install"
fi fi
DEPENDENCY="python gnupg pkg-config" DEPENDENCY="python gnupg pkg-config"
$green"\nDetected MacOS\n";$nocolor $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
# Fedora
INSTALL="sudo dnf install"
UPDATE="sudo dnf check-update"
DEPENDENCY="python3-virtualenv python3-pip python3-devel gnupg2 pkgconf"
$green"\n\nDetected Fedora";$nocolor
elif type -p pacman > /dev/null; then
# Arch Linux
INSTALL="sudo pacman -S"
UPDATE="sudo pacman -Syu"
DEPENDENCY="curl python-pipenv gnupg pkgconf base-devel"
$green"\n\nDetected Arch Linux";$nocolor
elif type -P apk > /dev/null; then
# Alpine Linux
INSTALL="sudo apk add"
UPDATE="sudo apk update"
DEPENDENCY="py3-virtualenv python3-dev gnupg gcc musl-dev"
$green"\nDetected Alpine Linux";$nocolor
else 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 exit
fi fi
} }
@ -84,21 +115,21 @@ detect_os_arch() {
detect_os_arch detect_os_arch
## Update & Install dependencies ## 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 $green"$UPDATE\n$INSTALL $DEPENDENCY curl automake libtool jq\n"; $nocolor
$UPDATE $UPDATE
$INSTALL $DEPENDENCY curl automake libtool jq $INSTALL $DEPENDENCY automake libtool jq
# Enable tor # 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 until [[ "$tor_on" =~ ^[12]$ ]]; do
read -p 'Select an option: [1|2] ' tor_on read -p 'Select an option: [1|2]: ' tor_on
case $tor_on in case $tor_on in
1) 1)
$green"\nBasicSwapDEX will use Tor";$nocolor $green"BasicSwapDEX will use Tor\n";$nocolor
;; ;;
2) 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 $red"You must answer 1 or 2\n";$nocolor
@ -107,22 +138,22 @@ read -p 'Select an option: [1|2] ' tor_on
done done
## Particl restore Seed ## 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 until [[ "$restore" =~ ^[12]$ ]]; do
read -p 'Select an option: [1|2] ' restore read -p 'Select an option: [1|2]: ' restore
case $restore in case $restore in
1) 1)
$green"\nInstalling BasicSwapDEX\n"; $nocolor $green"Installing BasicSwapDEX\n"; $nocolor
;; ;;
2) 2)
until [[ "$wordcount" = "24" ]]; do until [[ "$wordcount" = "24" ]]; do
read -p $'\nEnter your Particl Seed\n[example: word word word word word...] ' particl_mnemonic read -p $'\nEnter your Particl Seed\n[example: word word word word word...] ' particl_mnemonic
wordcount=$(echo $particl_mnemonic | wc -w) wordcount=$(echo $particl_mnemonic | wc -w)
if [[ $wordcount = 24 ]]; then if [[ $wordcount = 24 ]]; then
echo -e "Restoring BasicSwapDEX" printf "Restoring BasicSwapDEX\n"
$green"$particl_mnemonic\n";$nocolor $green"$particl_mnemonic\n";$nocolor
else else
$red"Try again. Seed must be 24 words"; $nocolor $red"Try again. Seed must be 24 words\n"; $nocolor
fi fi
done done
;; ;;
@ -137,13 +168,13 @@ if [[ $particl_mnemonic ]]; then
read -p $'\nEnter a restore height for your BasicSwap XMR wallet? [Y/n] ' height read -p $'\nEnter a restore height for your BasicSwap XMR wallet? [Y/n] ' height
case $height in case $height in
n|N) 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 until [[ "$xmrrestoreheight" =~ ^[0-9]{1,7}$ ]]; do
read -p $'Enter your Monero Restore Height [example: 2548568] ' xmrrestoreheight read -p $'Enter your Monero Restore Height [example: 2548568] ' xmrrestoreheight
if [[ $xmrrestoreheight =~ ^[0-9]{7}$ ]]; then if [[ $xmrrestoreheight =~ ^[0-9]{7}$ ]]; then
$green"\nYour XMR Restore height: $xmrrestoreheight"; $nocolor $green"Your XMR Restore height: $xmrrestoreheight\n"; $nocolor
else else
$red"Try again. Must be 1-7 digits\n"; $nocolor $red"Try again. Must be 1-7 digits\n"; $nocolor
fi fi
@ -153,7 +184,7 @@ if [[ $particl_mnemonic ]]; then
fi fi
## Configure Monero ## 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 until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l read -p 'Select an option [1|2]: ' l
case $l in case $l in
@ -161,16 +192,23 @@ read -p 'Select an option [1|2]: ' l
until [[ $checknode ]]; do until [[ $checknode ]]; do
read -p 'Enter Address of Monero node [example: 192.168.1.123] ' monerod_addr 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 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 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 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 fi
done done
if [[ -z $xmrrestoreheight ]]; then
xmrrestoreheight="${checknode}"
fi
$green"Monero wallet Restore Height set to ${xmrrestoreheight}\n"; $nocolor
;; ;;
2) 2)
$green"\nBasicSwapDEX will run the Monero node for you."; $nocolor xmrrestoreheight=$(curl -s http://node3.monerodevs.org:18089/get_info | jq .height || { echo "Failed to get Monero blockchain height. Please run the installer again."; exit; })
$green"BasicSwapDEX will run the Monero node for you.\n"; $nocolor
$green"Monero wallet Restore Height set to ${xmrrestoreheight}\n"; $nocolor
;; ;;
*) *)
$red"You must answer 1 or 2\n"; $nocolor $red"You must answer 1 or 2\n"; $nocolor
@ -179,7 +217,7 @@ read -p 'Select an option [1|2]: ' l
done done
## Begin Install ## Begin Install
echo -e "\n\nInstalling BasicSwapDEX" printf "\nInstalling BasicSwapDEX\n"
read -p 'Press Enter to continue, or CTRL-C to exit.' read -p 'Press Enter to continue, or CTRL-C to exit.'
# Quest to make trasher happy # Quest to make trasher happy
@ -211,15 +249,15 @@ fi
if [[ -d $HOME/.local/bin/bsx ]]; then if [[ -d $HOME/.local/bin/bsx ]]; then
rm -r $HOME/.local/bin/bsx* $HOME/.local/bin/basicswap-bash rm -r $HOME/.local/bin/bsx* $HOME/.local/bin/basicswap-bash
fi fi
mv -f -t $HOME/.local/bin/ basicswap-bash bsx* cp -r basicswap-bash bsx* $HOME/.local/bin/
## Make venv and set variables for install ## Make venv and set variables for install
export monerod_addr=$monerod_addr export monerod_addr="${monerod_addr}"
export monerod_port=$monerod_port export monerod_port="${monerod_port}"
export particl_mnemonic=$particl_mnemonic export particl_mnemonic="${particl_mnemonic}"
export xmrrestoreheight=$xmrrestoreheight export xmrrestoreheight="${xmrrestoreheight}"
export tor_on=$tor_on export tor_on="${tor_on}"
export TAILS=$TAILS export TAILS="${TAILS}"
python3 -m venv "$SWAP_DATADIR/venv" python3 -m venv "${SWAP_DATADIR}/venv"
## Activate venv ## Activate venv
$HOME/.local/bin/bsx/activate_venv.sh $HOME/.local/bin/bsx/activate_venv.sh