Compare commits

...

38 commits

Author SHA1 Message Date
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
nahuhh
10e81c85d1 remove python-is-python3, use python3 2024-10-18 16:06:13 +00:00
nahuhh
a2e989a1ef add: bsx-placeorder 2024-10-18 03:45:54 +00:00
nahuhh
92bdd39b76 update: add fix for updates from v0.12.7 2024-10-17 23:07:13 +00:00
nahuhh
9709cb4ae8 readme: remove bsx-upgrade-coins 2024-10-17 23:07:13 +00:00
nahuhh
a48c687a60 fix $PATH detection 2024-10-17 23:06:30 +00:00
nahuhh
4364fa99cc bump: v0.14.1 2024-10-17 17:31:26 +00:00
nahuhh
6d2ab45cbd install: fix .local/bin detection 2024-10-17 17:03:13 +00:00
nahuhh
9991176e0e bsx-update: only update once 2024-10-16 14:52:16 +00:00
nahuhh
97a5d1215e setup: add newline 2024-10-16 02:16:24 +00:00
nahuhh
61b8618e90 core_versions: dash v0.21.1.0 2024-10-09 20:43:24 +00:00
nahuhh
318cdf7c6a friendly update coincurve 2024-10-09 20:43:24 +00:00
nahuhh
1a85e5b6fe rename xmr variable 2024-10-09 20:43:24 +00:00
nahuhh
40fecdc214 untested macos 2024-10-09 20:39:41 +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
nahuhh
acc3702c50 fix restore from seed 2024-09-16 18:38:10 +00:00
nahuhh
4d46146657 update cores 2024-09-16 01:18:26 +00:00
nahuhh
e9a84cf72f install: xfce .profile use in .xsessionrc 2024-09-05 22:07:40 +00:00
nahuhh
1531ba9034 wownero master 2024-06-21 21:04:21 -05:00
nahuhh
32d5003c43 fix upgrade paths 2024-06-12 12:33:16 -05:00
nahuhh
48ee19de36 switch to basicswap/basicswap repo 2024-06-11 15:32:34 -05:00
nahuhh
116a5a68c7 add curl dependency, reword password prompt 2024-06-06 07:34:49 -05:00
nahuhh
07cc24b204 use $HOME/.local/bin 2024-06-05 17:33:11 -05:00
nahuhh
96fad3fcdd support password protected installs 2024-06-04 21:14:17 -05:00
nahuhh
d3b442b7f7 check that remote node actually works 2024-06-04 19:31:08 -05:00
nahuhh
7ae1eb55b2 remove protobuf, update README 2024-06-04 08:59:33 -05:00
26 changed files with 1039 additions and 169 deletions

View file

@ -1,16 +1,33 @@
# basicswap-bash
A BasicSwapDEX bash installer for Debian/Ubuntu
A suite of bash scripts to install and manage
BasicSwapDEX on Windows(WSL)/Debian/Ubuntu/Arch/Fedora
### Installation
### New Installation
```bash
wget https://github.com/nahuhh/basicswap-bash/releases/latest/download/basicswap-bash.tar.gz
tar xvf basicswap-bash.tar.gz
git clone https://github.com/nahuhh/basicswap-bash
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
cd basicswap-bash
mkdir -p $HOME/.local/bin
rm -r $HOME/.local/bin/bsx
mv -f basic* bsx* $HOME/.local/bin/
cd .. && rm -rf basicswap-bash
bsx-update
```
### Running BasicSwapDEX
```
basicswap-bash
```
#### Update BSX core and Coin cores
```
bsx-update
```
#### Enable/Disable Tor [post install]
```
@ -20,19 +37,19 @@ bsx-enabletor
bsx-disabletor
```
#### Add coins
#### Add/remove coins
```
bsx-addcoin
```
#### Update blockchains
```
bsx-upgrade-coins
```
#### Update BSX core
```
bsx-update
bsx-removecoin
```
### BONUS placeorders
This is a POC for placing new orders. YMMV
```
bsx-placeorder
```
A small donation goes a long way. Thanks
- ofrnxmr

View file

@ -1,5 +1,21 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
python3 -m venv "$SWAP_DATADIR/venv"
. $SWAP_DATADIR/venv/bin/activate && python -V
/usr/local/bin/bsx/startup.sh
# 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
$HOME/.local/bin/bsx/startup.sh

View file

@ -1,4 +1,46 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
/usr/local/bin/bsx/addcoin.sh
# Colors
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=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
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
1)
until [[ $pass1 ]] && [[ $pass1 == $pass2 ]]; do
read -sp 'Enter your BasicSwap password: ' pass1
read -sp $'\nRe-enter your BasicSwap password: ' pass2
if [[ $pass1 == $pass2 ]]; then
export WALLET_ENCRYPTION_PWD=$pass1
else
$red"\nThe passwords entered don't match. Try again\n\n"; $nocolor
fi
done
;;
2)
$nocolor"\nProceeding without a password\n"
;;
*)
$red"You must answer 1 or 2\n"; $nocolor
;;
esac
done
. $SWAP_DATADIR/venv/bin/activate
$HOME/.local/bin/bsx/addcoin.sh

View file

@ -1,4 +1,46 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
/usr/local/bin/bsx/disabletor.sh
# Colors
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=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
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
1)
until [[ $pass1 ]] && [[ $pass1 == $pass2 ]]; do
read -sp 'Enter your BasicSwap password: ' pass1
read -sp $'\nRe-enter your BasicSwap password: ' pass2
if [[ $pass1 == $pass2 ]]; then
export WALLET_ENCRYPTION_PWD=$pass1
else
$red"\nThe passwords entered don't match. Try again\n\n"; $nocolor
fi
done
;;
2)
$nocolor"\nProceeding without a password\n"
;;
*)
$red"You must answer 1 or 2\n"; $nocolor
;;
esac
done
. $SWAP_DATADIR/venv/bin/activate
$HOME/.local/bin/bsx/disabletor.sh

View file

@ -1,4 +1,46 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
/usr/local/bin/bsx/enabletor.sh
# Colors
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=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
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
1)
until [[ $pass1 ]] && [[ $pass1 == $pass2 ]]; do
read -sp 'Enter your BasicSwap password: ' pass1
read -sp $'\nRe-enter your BasicSwap password: ' pass2
if [[ $pass1 == $pass2 ]]; then
export WALLET_ENCRYPTION_PWD=$pass1
else
$red"\nThe passwords entered don't match. Try again\n\n"; $nocolor
fi
done
;;
2)
$nocolor"\nProceeding without a password\n"
;;
*)
$red"You must answer 1 or 2\n"; $nocolor
;;
esac
done
. $SWAP_DATADIR/venv/bin/activate
$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="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=$(pgrep 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
cp $HOME/.local/bin/bsx/placeorders/* $SWAP_DATADIR/basicswap/scripts/.
cd $SWAP_DATADIR/basicswap/scripts/
./placeorders.sh

View file

@ -1,4 +1,46 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
/usr/local/bin/bsx/disablecoin.sh
# Colors
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=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
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
1)
until [[ $pass1 ]] && [[ $pass1 == $pass2 ]]; do
read -sp 'Enter your BasicSwap password: ' pass1
read -sp $'\nRe-enter your BasicSwap password: ' pass2
if [[ $pass1 == $pass2 ]]; then
export WALLET_ENCRYPTION_PWD=$pass1
else
$red"\nThe passwords entered don't match. Try again\n\n"; $nocolor
fi
done
;;
2)
$nocolor"\nProceeding without a password\n"
;;
*)
$red"You must answer 1 or 2\n"; $nocolor
;;
esac
done
. $SWAP_DATADIR/venv/bin/activate
$HOME/.local/bin/bsx/removecoin.sh

View file

@ -1,4 +1,44 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
/usr/local/bin/bsx/update.sh
# Colors
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=$(pgrep particld | grep $bsx_pid)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is running.\n"; $nocolor
exit
fi
fi
fi
. $SWAP_DATADIR/venv/bin/activate
if [ -f /usr/local/bin/bsx/update.sh ]; then
/usr/local/bin/bsx/update.sh
cd /usr/local/bin
sudo rm -rf basicswap-bash bsx*
else
cd $SWAP_DATADIR/basicswap
# Download updated scripts
echo "Updating basicswap-bash scripts" && sleep 1
git clone https://github.com/nahuhh/basicswap-bash
cd basicswap-bash
# Move scripts
rm -rf $HOME/.local/bin/bsx
mv -f basic* bsx* $HOME/.local/bin/
# Copy core_versions to basicswap folder
mv core_versions $SWAP_DATADIR/basicswap/core_versions
# Update BasicSwap, coincurve and coin cores
$HOME/.local/bin/bsx/update.sh
fi

View file

@ -1,4 +0,0 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
/usr/local/bin/bsx/upgradecoins.sh

View file

@ -1,3 +1,7 @@
#!/bin/bash
. $SWAP_DATADIR/venv/bin/activate && python -V
/usr/local/bin/bsx/setup.sh
. $SWAP_DATADIR/venv/bin/activate
if [[ $TAILS ]]; then
$HOME/.local/bin/bsx/tails_setup.sh
else
$HOME/.local/bin/bsx/setup.sh
fi

View file

@ -1,11 +1,11 @@
#!/bin/bash
## Prompt for user input
echo -e "\n\nThe following coins can be added (case sensitive)\nbitcoin\ndash\nfiro\nlitecoin\npivx\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
echo -e "\nAdd $addcoin to your BasicSwap install, correct? Press any key to continue. CTRL-C to exit"
read
read -p $'\nAdd '$addcoin' to your BasicSwap install, correct? Press ENTER to continue. CTRL-C to exit'
## Add the coin
if [ $addcoin = bitcoin ]; then
read -p 'Use --usebtcfastsync for bitcoin? [Y/n] ' btcfastsync

43
bsx/auto_coinupd8.sh Executable file
View file

@ -0,0 +1,43 @@
#!/bin/bash
#set -x
SWAP_DATADIR=$HOME/coinswaps
BINDIR=$SWAP_DATADIR/bin
echo "Checking for Coin updates" && sleep 1
chain=(
bitcoin
dash
decred
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
done
echo "Updating $list"
if [[ -n $select ]]; then
. $SWAP_DATADIR/venv/bin/activate
basicswap-prepare --datadir=$SWAP_DATADIR --preparebinonly --withcoins=$list
else
echo "Coin Cores are up to date"
fi

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..."
@ -47,18 +69,19 @@ else
$INSTALL tor
fi
# Create HashesControlPassword
echo -e "In the next step you'll choose a password. NOTE: It will be saved in PLAIN TEXT."
# Create HashedControlPassword
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)
enabledcontrol=$(echo "ControlPort 9051")
skipcontrol=$(grep -x "$enabledcontrol" /etc/tor/torrc)
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

@ -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,28 @@
{
"offers": [
{
"enabled": true,
"coin_from": "COIN_TO_SELL",
"coin_to": "COIN_TO_BUY",
"amount": AMOUNT,
"amount_step": INCREMENT,
"minrate": RATE,
"ratetweakpercent": PERCENT,
"amount_variable": true,
"address": "-1",
"name": "GUI Offer",
"min_coin_from_amt": -1,
"min_swap_amount": MIN_SWAP,
"offer_valid_seconds": 14400
}
],
"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
}

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

@ -0,0 +1,346 @@
#!/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="printf \e[36;1m"
cy2="\e[36;1m"
red="printf \e[31;1m"
red2="\e[31;1m"
grn="printf \e[32;1m"
grn2="\e[32;1m"
nc="printf \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=""
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
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() {
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() {
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() {
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 $'\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
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 }')
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 $'\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
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 }')
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
;;
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 }')
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
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
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 }')
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
sed -i -z "s/AMOUNT/$AMOUNT/g" $taker
sed -i -z "s/INCREMENT/$INCREMENT/" $maker
else
TAKERAMOUNT=$(echo $AMOUNT $MAKER_RATE | awk '{ printf "%.8f\n", $1 * $2 }')
OB_AMOUNT=$AMOUNT
INCREMENT=$(echo $OB_AMOUNT | awk '{ printf "%.4f", $1 / 10 }')
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
sed -i -z "s/AMOUNT/$AMOUNT/g" $maker
sed -i -z "s/INCREMENT/$INCREMENT/" $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
revert_config
apply_config
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
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=$(python3 createoffers.py --configfile $maker --statefile $state --port=$PORT --oneshot | grep "New offer")
if [[ $ORDERPLACED ]]; then
$grn"OFFER POSTED! Please check BasicSwapDEX to confirm\nOffer expires in 4hrs\n";$nc
else
$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
printf "\nBuying: $grn2$theircapital$nc2"
printf "\nSelling: $red2$yourcapital$nc2\n"
#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

@ -1,10 +1,10 @@
#!/bin/bash
## Prompt for user input
echo -e "\n\nThe following coins can be disabled (case sensitive)\nbitcoin\ndash\nfiro\nlitecoin\nmonero\npivx\n"
read -p 'Full name of coin to disable [example: litecoin] ' disablecoin
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,28 +1,23 @@
#!/bin/bash
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
## UBUNTU 22.04 FIX upgrade protobuf inside of venv
python -m pip install --upgrade "protobuf<=3.20.1"
## 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
$SWAP_DATADIR/venv/bin/pip install .
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \e[0m"
## Clone basicswap git
cd $SWAP_DATADIR
git clone https://github.com/tecnovert/basicswap.git
git clone https://github.com/basicswap/basicswap
cd $SWAP_DATADIR/basicswap
## Install basicswap
protoc -I=basicswap --python_out=basicswap basicswap/messages.proto
$SWAP_DATADIR/venv/bin/pip install .
## Macos
if [[ $MACOS ]]; then
$SWAP_DATADIR/venv/bin/pip3 install certifi
fi
## Install basicswap, coincurve, and pip dependencies
$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
@ -32,34 +27,40 @@ elif [[ "$monerod_addr" ]]; then
CURRENT_XMR_HEIGHT=$(curl "http://$monerod_addr:$monerod_port/get_info" | jq .height)
else
# Use public node
CURRENT_XMR_HEIGHT=$(curl https://localmonero.co/blocks/api/get_stats | jq .height)
CURRENT_XMR_HEIGHT=$(curl http://node3.monerodevs.org:18089/get_info | jq .height)
fi
# Use Tor if we want
enable_tor() {
if [[ "$tor_on" = 1 ]]; then
/usr/local/bin/bsx-enabletor
$HOME/.local/bin/bsx-enabletor
fi
}
# Use the custom Monero node
# Use the custom Monero node & add wownero because its a small chain
if [[ "$particl_mnemonic" && "$monerod_addr" ]]; then
# Restore seed
PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC"
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=monero --xmrrestoreheight=$CURRENT_XMR_HEIGHT
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
# Restore seed
PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC"
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000 --particl_mnemonic="$PARTICL_MNEMONIC"
enable_tor
elif [[ "$monerod_addr" ]]; then
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero --xmrrestoreheight=$CURRENT_XMR_HEIGHT
$red"\n\nMake note of your seed above\n"; $nocolor
# 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\n"; $nocolor
enable_tor
else
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero --xmrrestoreheight=$CURRENT_XMR_HEIGHT
$red"\n\nMake note of your seed above\n"; $nocolor
# 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\n"; $nocolor
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\n";$nocolor
$red"You may have to logout / login or open a new terminal window for the commands to be detected\n";$nocolor

66
bsx/tails_setup.sh Executable file
View file

@ -0,0 +1,66 @@
#!/bin/bash
# Colors
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \e[0m"
## Clone basicswap git
cd $SWAP_DATADIR
git clone https://github.com/basicswap/basicswap
cd $SWAP_DATADIR/basicswap
## 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 .
## 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
enable_tor() {
if [[ "$tor_on" = 1 ]]; then
$HOME/.local/bin/bsx-enabletor
fi
}
# Use the custom Monero node & add wownero because its a small chain
if [[ "$particl_mnemonic" && "$monerod_addr" ]]; then
# Restore seed
PARTICL_MNEMONIC=$particl_mnemonic
XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port \
torsocks basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000 --particl_mnemonic="$PARTICL_MNEMONIC"
enable_tor
elif [[ "$particl_mnemonic" ]]; then
# Restore seed
PARTICL_MNEMONIC=$particl_mnemonic
torsocks basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000 --particl_mnemonic="$PARTICL_MNEMONIC"
enable_tor
elif [[ "$monerod_addr" ]]; then
# Setup new install and use a remote monero node
XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port \
torsocks basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor
else
# Setup new install using local nodes
torsocks basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor
fi
$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

@ -1,4 +1,26 @@
#!/bin/bash
echo "Updating BasicSwapDEX" && sleep 1
# Delete dangling build folder. Same as --no-cache for docker
rm -rf $SWAP_DATADIR/basicswap/build
# BasicSwap, coincurve, and dependencies
# Switch to new repo: basicswap/basicswap
cd $SWAP_DATADIR/basicswap
git remote set-url origin https://github.com/basicswap/basicswap
# Conflicting messages_pb2.py from v0.12.7
if [[ -f basicswap/messages_pb2.py ]]; then
git restore basicswap/messages_pb2.py
fi
#git checkout master
git pull
$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
# Cleanup
rm -rf basicswap-bash

View file

@ -1,13 +0,0 @@
#!/bin/bash
## Prompt for user input
echo "You can only update coins which you have already added to your install"
echo -e "\n\nList of coins supported by BasicSwapDEX (case sensitive):\nbitcoin\ndash\nfiro\nlitecoin\nmonero\nparticl\npivx\n"
read -p 'Full name of coin to update [example: litecoin] ' updatecoin
## Confirm
read -p $'\nUpdate $updatecoin, correct? Press any key to continue. CTRL-C to exit'
## Update the coin
basicswap-prepare --datadir=$SWAP_DATADIR -preparebinonly --withcoins=$updatecoin
echo "Updated $updatecoin"

9
core_versions Normal file
View file

@ -0,0 +1,9 @@
Bitcoin Core version v26.0.0
dcrd version 1.8.1+release (Go version go1.21.1 linux/amd64)
Dash Core version v21.1.0
Firo Core Daemon version v0.14.14.0-ge0c423805
Litecoin Core version v0.21.3
Particl Core version v23.2.7.0
PIVX Core Daemon version v5.6.1.0-af60f19642
Monero 'Fluorine Fermi' (v0.18.3.4-release)
Wownero 'Kunty Karen' (v0.11.1.0-release)

View file

@ -1,9 +1,22 @@
#/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"
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)
if [[ $bsx_run ]]; then
$red"\nError: BasicSwapDEX is already installed.\n"; $nocolor
exit
fi
fi
fi
# Title Bar
$green "\n"
@ -11,57 +24,81 @@ 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
INSTALL=""
UPDATE=""
DEPENDENCY=""
TAILS=""
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
DEPENDENCY="python gnupg pkg-config"
$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="python-is-python3 python3-pip python3-venv gnupg pkg-config protobuf-compiler"
$green"\nDetected Debian\n";$nocolor
elif type -P dnf > /dev/null; then
DEPENDENCY="python3-pip python3-venv libpython3-dev 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 protobuf-compiler"
$green"\nDetected Fedora\n";$nocolor
elif type -P pacman > /dev/null; then
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="python-pipenv gnupg protobuf pkgconf base-devel"
$green"\nDetected Arch Linux\n";$nocolor
elif type -P brew > /dev/null; then
# MacOS
INSTALL="brew install"
DEPENDENCY="python protobuf gnupg pkg-config"
$green"\nDetected MacOS\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
}
detect_os_arch
## Update & Install dependencies
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 automake libtool jq
# Enable tor
echo -e "\n\n[1] Tor ON\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
@ -70,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
;;
@ -100,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
@ -116,17 +153,24 @@ 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
1)
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
$green"\nLook good? $monerod_addr:$monerod_port"; $nocolor
checknode=$(curl -sk http://$monerod_addr:$monerod_port/get_info | jq .height)
if [[ $checknode ]]; then
$green"Successfully connected to the XMR node @ $monerod_addr:$monerod_port\n"; $nocolor
else
$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
@ -135,22 +179,47 @@ read -p 'Select an option [1|2]: ' l
done
## Begin Install
echo -e "\n\nInstalling dependencies"
printf "\nInstalling BasicSwapDEX\n"
read -p 'Press Enter to continue, or CTRL-C to exit.'
## Update & Install dependencies
$UPDATE
$INSTALL $DEPENDENCY git wget unzip automake libtool jq
# Move scripts to /usr/local/bin
sudo rm -r /usr/local/bin/bsx* /usr/local/bin/basicswap-bash
sudo mv -f -t /usr/local/bin/ basicswap-bash bsx*
# Quest to make trasher happy
addpath='PATH="$HOME/.local/bin:$PATH"'
trasherdk=$(echo $PATH | grep -F '.local/bin')
if [[ ! -d $HOME/.local/bin ]]; then
mkdir -p $HOME/.local/bin
fi
if [[ -z $trasherdk ]]; then
# 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
cp -r basicswap-bash bsx* $HOME/.local/bin/
## 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
mkdir -p "$SWAP_DATADIR/venv"
python -m venv "$SWAP_DATADIR/venv"
export TAILS=$TAILS
python3 -m venv "$SWAP_DATADIR/venv"
## Activate venv
/usr/local/bin/bsx/activate_venv.sh
$HOME/.local/bin/bsx/activate_venv.sh

View file

@ -1,10 +0,0 @@
#/bin/bash
# Download Scripts
curl -LO https://github.com/nahuhh/basicswap-bash/releases/download/beta/basicswap-beta.tar.gz
tar xvf basicswap-beta.tar.gz
cd basicswap-beta
# Install BasicSwapDEX
./install.sh
# Cleanup
cd ..
rm -rf basicswap-beta

View file

@ -1,11 +0,0 @@
#/bin/bash
# Download updated scripts
curl -LO https://github.com/nahuhh/basicswap-bash/releases/download/beta/basicswap-beta.tar.gz
tar xvf basicswap-beta.tar.gz
cd basicswap-beta
# Move scripts
sudo rm -rf /usr/local/bin/bsx
sudo mv -f basic* bsx* /usr/local/bin/
# Cleanup install
cd ..
rm -rf basicswap-beta