Compare commits

...

49 commits

Author SHA1 Message Date
nahuhh
574fbb2ee7 addcoin: fix variable 2025-02-24 09:10:04 +00:00
nahuhh
82d495b12d addcoin: small cleanup 2025-02-15 15:34:28 +00:00
nahuhh
175b55fbe3 build: add curl and git 2025-02-15 15:29:49 +00:00
nahuhh
519c0b5ce5 tor: use upstream changes 2025-01-14 00:01:54 +00:00
nahuhh
a3b7271fb3 cores: use new updater 2025-01-13 23:42:08 +00:00
nahuhh
6cd8be6926 cores: add doge, update ltc,btc,dash 2025-01-12 22:21:42 +00:00
nahuhh
954e293043 add/remove: allow variable 2025-01-12 22:21:33 +00:00
nahuhh
3d51d62b49 update: avoid broken state if cancelling update 2025-01-04 22:59:11 +00:00
nahuhh
4b52312f8f update: pull if baasicswap-bash repo exists 2024-12-27 00:28:37 +00:00
nahuhh
c31fb46387 update: don't update cores unnecessarily 2024-12-27 00:21:09 +00:00
nahuhh
d665889123 update: wownero v0.11.3.0 2024-12-25 11:07:27 +00:00
nahuhh
02a72d77c4 tor: autogenerate passwd 2024-11-30 16:25:40 +00:00
nahuhh
7f8b90fea4 coins: add bitcoincash 2024-11-30 13:10:50 +00:00
nahuhh
b52b7e8c92
Merge pull request from CrynTox/master
Fix shebang in the install script
2024-11-25 15:52:43 +00:00
CrynTox
7ddc595edd fix: fix shebang 2024-11-25 17:30:29 +02:00
nahuhh
00c16d3857 update: cancel update if repo errors 2024-11-19 14:51:11 +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
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
23 changed files with 871 additions and 271 deletions

View file

@ -2,6 +2,14 @@
A suite of bash scripts to install and manage
BasicSwapDEX on Windows(WSL)/Debian/Ubuntu/Arch/Fedora
### Dependencies
You will need::
- curl
- git
`sudo apt install curl git`
Other dependencies vary by distribution and are handled by the installer.
### New Installation
```bash
git clone https://github.com/nahuhh/basicswap-bash
@ -15,7 +23,7 @@ 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/
cp -r basic* bsx* $HOME/.local/bin/
cd .. && rm -rf basicswap-bash
bsx-update
```
@ -24,7 +32,7 @@ bsx-update
```
basicswap-bash
```
#### Update BSX core
#### Update BSX core and Coin cores
```
bsx-update
```
@ -37,7 +45,7 @@ bsx-enabletor
bsx-disabletor
```
#### Add/remove coins
#### Add/disable coins
```
bsx-addcoin
```
@ -45,12 +53,12 @@ bsx-addcoin
bsx-removecoin
```
#### Update blockchains
### BONUS placeorders
This is a POC for placing new orders. YMMV
```
bsx-upgrade-coins
bsx-placeorder
```
A small donation goes a long way. Thanks
- ofrnxmr
```

View file

@ -1,5 +1,25 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
python3 -m venv "$SWAP_DATADIR/venv"
. $SWAP_DATADIR/venv/bin/activate && python -V
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
TAILS=1
fi
# 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,11 +1,27 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# 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"
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
# 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
@ -28,6 +44,7 @@ read -p 'Select an option [1|2]: ' l
;;
esac
done
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
export addcoin="$1"
. $SWAP_DATADIR/venv/bin/activate
$HOME/.local/bin/bsx/addcoin.sh

View file

@ -1,11 +1,27 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# 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"
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
# 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
@ -28,6 +44,6 @@ read -p 'Select an option [1|2]: ' l
;;
esac
done
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
. $SWAP_DATADIR/venv/bin/activate
$HOME/.local/bin/bsx/disabletor.sh

View file

@ -1,11 +1,27 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# 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"
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
# 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
@ -28,6 +44,6 @@ read -p 'Select an option [1|2]: ' l
;;
esac
done
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
. $SWAP_DATADIR/venv/bin/activate
$HOME/.local/bin/bsx/enabletor.sh

28
bsx-placeorder Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# 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,11 +1,27 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# 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"
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
# 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
@ -28,6 +44,7 @@ read -p 'Select an option [1|2]: ' l
;;
esac
done
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
export disablecoin="$1"
. $SWAP_DATADIR/venv/bin/activate
$HOME/.local/bin/bsx/removecoin.sh

View file

@ -1,11 +1,49 @@
#!/bin/bash
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# 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
$HOME/.local/bin/bsx/update.sh
cd $SWAP_DATADIR/basicswap
# Download updated scripts
echo "Updating basicswap-bash scripts" && sleep 1
if [[ -d basicswap-bash ]]; then
cd basicswap-bash
git pull || { $red"Failed to update repo. Cancelling update.\n"; exit; }
else
git clone https://github.com/nahuhh/basicswap-bash || { $red"Failed to clone repo. Cancelling update.\n"; exit; }
cd basicswap-bash
fi
# Move scripts
rm -rf $HOME/.local/bin/bsx $HOME/.local/bin/basicswap-bash
cp -r basic* bsx* $HOME/.local/bin/
# Update BasicSwap, coincurve and coin cores
./bsx/update.sh
fi

View file

@ -1,33 +0,0 @@
#!/bin/bash
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
echo -e "BasicSwapDEX is currently:\n[1] Password protected\n[2] NOT password protected\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
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
export SWAP_DATADIR=$HOME/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
$HOME/.local/bin/bsx/upgradecoins.sh

View file

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

View file

@ -1,12 +1,15 @@
#!/bin/bash
## Prompt for user input
echo -e "\n\nThe following coins can be added (case sensitive)\nbitcoin\ndash\ndecred\nfiro\nlitecoin\npivx\nwownero\n"
read -p 'Full name of coin to add [example: litecoin] ' addcoin
if [[ -z $addcoin ]]; then
printf "\n\nThe following coins can be added (case sensitive)\nbitcoin\nbitcoincash\ndash\ndecred\ndogecoin\nfiro\nlitecoin\npivx\nwownero\n\n"
read -p 'Full name of coin to add [example: litecoin] ' addcoin
fi
## Confirm
read -p $'\nAdd '$addcoin' to your BasicSwap install, correct? Press ENTER to continue. CTRL-C to exit'
## Add the coin
fastsync=""
if [ $addcoin = bitcoin ]; then
read -p 'Use --usebtcfastsync for bitcoin? [Y/n] ' btcfastsync
@ -17,11 +20,9 @@ if [ $addcoin = bitcoin ]; then
if [ $confirmed = yes ]; then
echo "Using btcfastsync"
basicswap-prepare --usebtcfastsync --datadir=$SWAP_DATADIR --addcoin=$addcoin
fastsync="--usebtcfastsync"
else
echo "Not using btcfastsync"
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=$addcoin
fi
else
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=$addcoin
fi
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=$addcoin ${fastsync:+${fastsync}}

3
bsx/auto_coinupd8.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
#set -x
basicswap-prepare --datadir=$SWAP_DATADIR --upgradecores

View file

@ -1,36 +1,58 @@
#!/bin/bash
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
red="printf \e[31;1m"
green="printf \e[32;1m"
nocolor="printf \e[0m"
# Detect Operating system
INSTALL=""
UPDATE=""
INIT_TOR="sudo systemctl restart tor"
INIT_TOR=""
SYSTEMD_TOR="sudo systemctl restart tor"
check_tails() {
if [[ $USER == amnesia ]]; then
$green"\n\nDetected Tails";$nocolor
TAILS=1
else
$green"\n\nDetected Debian";$nocolor
fi
}
detect_os_arch() {
if type -P apt > /dev/null; then
if [[ $(uname -s) = "Darwin" ]]; then
# MacOS
export MACOS=1
if type -p brew > /dev/null; then
$green"Homebrew is installed\n";$nc
INSTALL="brew install"
else
$green"Installing Homebrew\n";$nc
INSTALL="curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | /bin/bash && brew install"
fi
INIT_TOR="pkill tor && tor"
$green"\n\nDetected MacOS";$nocolor
elif type -p apt > /dev/null; then
check_tails
# Debian / Ubuntu / Mint
INSTALL="sudo apt install -y"
INSTALL="sudo apt install"
UPDATE="sudo apt update"
$green"\nDetected Debian\n";$nocolor
elif type -P dnf > /dev/null; then
INIT_TOR=$SYSTEMD_TOR
elif type -p dnf > /dev/null; then
# Fedora
INSTALL="sudo dnf install -y"
INSTALL="sudo dnf install"
UPDATE="sudo dnf check-update"
$green"\nDetected Fedora\n";$nocolor
elif type -P pacman > /dev/null; then
INIT_TOR=$SYSTEMD_TOR
$green"\n\nDetected Fedora";$nocolor
elif type -p pacman > /dev/null; then
# Arch Linux
INSTALL="sudo pacman -S"
UPDATE="sudo pacman -Syu"
$green"\nDetected Arch Linux\n";$nocolor
elif type -P brew > /dev/null; then
# MacOS
INSTALL="brew install"
$green"\nDetected MacOS\n";$nocolor
INIT_TOR=$SYSTEMD_TOR
$green"\n\nDetected Arch Linux";$nocolor
else
$red"Failed to detect OS. Unsupported or unknown distribution.\nInstall Failed.";$nocolor
$red"\nFailed to detect OS. Unsupported or unknown distribution.\nInstall Failed.\n";$nocolor
exit
fi
}
@ -38,8 +60,8 @@ detect_os_arch() {
detect_os_arch
# Check for Tor installation
if type -P tor > /dev/null; then
echo -e "\nTor is already installed :)"
if type -p tor > /dev/null; then
printf "\nTor is already installed :)\n"
else
# Install and configure tor
echo "Installing Tor..."
@ -48,8 +70,7 @@ else
fi
# Create HashedControlPassword
echo -e "In the next step you'll choose a password. NOTE: It will be saved in PLAIN TEXT."
read -p "Enter a (new) tor control password [example: 123123] " torcontrolpass
torcontrolpass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1)
# Edit /etc/tor/torrc
torhashedpass=$(tor --hash-password $torcontrolpass)
enabledcontrol=$(echo "ControlPort 9051")
@ -57,21 +78,16 @@ 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
$INIT_TOR
echo "Waiting for Tor... 5sec" && sleep 5
# lol are we there yet?
TOR_PROXY_HOST=127.0.0.1
basicswap-prepare --datadir=$SWAP_DATADIR --enabletor
BSX_LOCAL_TOR=true basicswap-prepare --datadir=$SWAP_DATADIR --enabletor
# Workaround: Replace torpassword in various config files
oldtorpass=$(cat $SWAP_DATADIR/basicswap.json | jq -r .tor_control_password)
sed -i "s/$oldtorpass/$torcontrolpass/" $SWAP_DATADIR/*/*.conf $SWAP_DATADIR/basicswap.json
# Fix: localhost binding for btc/ltc/part (etc) configs
sed -i -z "s/\nbind=0.0.0.0/\nbind=127.0.0.1/" $SWAP_DATADIR/*/*.conf

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
}

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

@ -0,0 +1,347 @@
#!/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 / 100 }') # TODO make offers repeat
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 / 100 }') # TODO make offers repeat
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")
POSTOFFER=$(python3 -c "print($OB_AMOUNT < $OB_MIN)")
if [[ $FOUNDBID ]]; then
$grn"Placed bid successfully! Check BasicSwapDEX to confirm\n";$nc
elif [[ $POSTOFFER == True ]] && [[ -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,14 @@
#!/bin/bash
## Prompt for user input
echo -e "\n\nThe following coins can be disabled (case sensitive)\nbitcoin\ndash\ndecred\nfiro\nlitecoin\nmonero\npivx\nwownero\n"
read -p 'Full name of coin to disable [example: wownero] ' disablecoin
if [[ -z "$disablecoin" ]]; then
printf "\n\nThe following coins can be disabled (case sensitive)\nbitcoin\nbitcoincash\ndash\ndecred\ndogecoin\nfiro\nlitecoin\nmonero\npivx\nwownero\n\n"
read -p 'Full name of coin to disable [example: wownero] ' disablecoin
fi
## 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,36 +1,29 @@
#!/bin/bash
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
## Download & Install coincurve stuff
cd $SWAP_DATADIR
wget -O coincurve-anonswap.zip https://github.com/tecnovert/coincurve/archive/refs/tags/anonswap_v0.2.zip
unzip -d coincurve-anonswap coincurve-anonswap.zip
mv -f ./coincurve-anonswap/*/{.,}* ./coincurve-anonswap || true
cd $SWAP_DATADIR/coincurve-anonswap
$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/basicswap/basicswap
cd $SWAP_DATADIR/basicswap
## Install basicswap
$SWAP_DATADIR/venv/bin/pip 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)
if [[ -d basicswap ]]; then
cd $SWAP_DATADIR/basicswap
git pull || { $red"Failed to pull repo. Installation aborted"; exit; }
else
# Use public node
CURRENT_XMR_HEIGHT=$(curl http://node3.monerodevs.org:18089/get_info | jq .height)
git clone https://github.com/basicswap/basicswap || { $red"Failed to clone repo. Please run the installer again"; exit; }
cd $SWAP_DATADIR/basicswap
fi
## 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 .
# Use Tor if we want
enable_tor() {
if [[ "$tor_on" = 1 ]]; then
@ -42,29 +35,30 @@ enable_tor() {
if [[ "$particl_mnemonic" && "$monerod_addr" ]]; then
# Restore seed
PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC"
# Add coins and use a remote monero node
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port \
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port \
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
elif [[ "$particl_mnemonic" ]]; then
# Restore seed
PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC"
# Add coins using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
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
elif [[ "$monerod_addr" ]]; then
# Setup new install and use a remote monero node
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port \
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
$red"\n\nMake note of your seed above\n"; $nocolor
XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port \
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 || { $red"Installation failed. Try again"; exit; }
$red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor
else
# Setup new install using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
$red"\n\nMake note of your seed above\n"; $nocolor
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 || { $red"Installation failed. Try again"; exit; }
$red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
$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

View file

@ -1,36 +1,29 @@
#!/bin/bash
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
## Download & Install coincurve stuff
cd $SWAP_DATADIR
wget -O coincurve-anonswap.zip https://github.com/tecnovert/coincurve/archive/refs/tags/anonswap_v0.2.zip
unzip -d coincurve-anonswap coincurve-anonswap.zip
mv -f ./coincurve-anonswap/*/{.,}* ./coincurve-anonswap || true
cd $SWAP_DATADIR/coincurve-anonswap
torsocks $SWAP_DATADIR/venv/bin/pip install . # Tails requires torsocks for pip
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 -b wow
cd $SWAP_DATADIR/basicswap
## Install basicswap
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)
if [[ -d basicswap ]]; then
cd $SWAP_DATADIR/basicswap
git pull || { $red"Failed to pull repo. Installation aborted"; exit; }
else
# Use public node
CURRENT_XMR_HEIGHT=$(curl http://node3.monerodevs.org:18089/get_info | jq .height)
git clone https://github.com/basicswap/basicswap || { $red"Failed to clone repo. Please run the installer again"; exit; }
cd $SWAP_DATADIR/basicswap
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
enable_tor() {
if [[ "$tor_on" = 1 ]]; then
@ -42,32 +35,30 @@ enable_tor() {
if [[ "$particl_mnemonic" && "$monerod_addr" ]]; then
# Restore seed
PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC"
# Add coins and use a remote monero node
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port \
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port \
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
elif [[ "$particl_mnemonic" ]]; then
# Restore seed
PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC"
# Add coins using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
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
elif [[ "$monerod_addr" ]]; then
# Setup new install and use a remote monero node
XMR_RPC_HOST=$monerod_addr BASE_XMR_RPC_PORT=$monerod_port \
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
$red"\n\nMake note of your seed above\n"; $nocolor
XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port \
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 || { $red"Installation failed. Try again"; exit; }
$red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
$red"\n\nMake note of your seed above\n\n"; $nocolor
enable_tor
else
# Setup new install using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
$red"\n\nMake note of your seed above\n"; $nocolor
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 || { $red"Installation failed. Try again"; exit; }
$red"\n\nMonero wallet restore height is ${xmrrestoreheight}"; $nocolor
$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

View file

@ -1,25 +1,26 @@
#!/bin/bash
cd $SWAP_DATADIR/basicswap
# Download updated scripts
echo "Updating basicswap-bash scripts" && sleep 1
git clone https://github.com/nahuhh/basicswap-bash -b dev
cd basicswap-bash
# Move scripts
rm -rf $HOME/.local/bin/bsx
mv -f basic* bsx* $HOME/.local/bin/
# Cleanup install
cd $SWAP_DATADIR/basicswap
rm -rf basicswap-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
# Fix conflicts from force-pushes and rebase
git checkout master
# Pull repo
# 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
# Install
$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 upgrade coins which you have already added to your install"
echo -e "\n\nList of coins supported by BasicSwapDEX (case sensitive):\nbitcoin\ndash\ndecred\nfiro\nlitecoin\nmonero\nparticl\npivx\nwownero\n"
read -p 'Full name of coin to upgrade [example: litecoin] ' upgradecoin
## Confirm
read -p $'\nUpgrade '$upgradecoin', correct? Press any key to continue. CTRL-C to exit'
## Upgrade the coin
basicswap-prepare --datadir=$SWAP_DATADIR -preparebinonly --withcoins=$upgradecoin
echo "Upgraded $upgradecoin"

View file

@ -1,9 +1,47 @@
#/bin/bash
#!/bin/bash
#set -x
export SWAP_DATADIR=$HOME/coinswaps
if [[ $USER == amnesia ]]; then
export SWAP_DATADIR=$HOME/Persistent/coinswaps
fi
# 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 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
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 already installed.\n"; $nocolor
exit
fi
fi
fi
# Title Bar
$green "\n"
@ -11,9 +49,9 @@ title="BasicSwapDEX Installer"
COLUMNS=$(tput cols)
title_size=${#title}
span=$(((COLUMNS + title_size) / 2))
printf "%${COLUMNS}s" " " | tr " " "*"
printf "%${COLUMNS}s" " " | tr " " "#"
printf "%${span}s\n" "$title"
printf "%${COLUMNS}s" " " | tr " " "*"
printf "%${COLUMNS}s" " " | tr " " "#"
$nocolor
# Detect Operating system
@ -23,40 +61,47 @@ DEPENDENCY=""
TAILS=""
check_tails() {
if [ $USER == amnesia ]; then
$green"\nDetected Tails\n";$nocolor
if [[ $USER == amnesia ]]; then
$green"\n\nDetected Tails";$nocolor
TAILS=1
else
$green"\nDetected Debian\n";$nocolor
$green"\n\nDetected Debian";$nocolor
fi
}
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"
elif type -P dnf > /dev/null; then
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
$green"\n\nDetected Fedora";$nocolor
elif type -p pacman > /dev/null; then
# Arch Linux
INSTALL="sudo pacman -S"
UPDATE="sudo pacman -Syu"
DEPENDENCY="python-pipenv gnupg pkgconf base-devel"
$green"\nDetected Arch Linux\n";$nocolor
elif type -P brew > /dev/null; then
# MacOS
INSTALL="brew install"
DEPENDENCY="python 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
}
@ -64,21 +109,21 @@ detect_os_arch() {
detect_os_arch
## Update & Install dependencies
echo -e "\n\nInstalling dependencies\nPress CTRL-C at password prompt(s) to skip. If skipped, you must install the dependencies manually before proceeding"
$green"$UPDATE\n$INSTALL $DEPENDENCY git curl wget unzip automake libtool jq\n"; $nocolor
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 git curl wget unzip automake libtool jq
$INSTALL $DEPENDENCY automake libtool jq
# Enable tor
echo -e "\n\n[1] Tor ON (requires sudo)\n[2] Tor OFF\n"
printf "\n[1] Tor ON (requires sudo)\n[2] Tor OFF\n"
until [[ "$tor_on" =~ ^[12]$ ]]; do
read -p 'Select an option: [1|2] ' tor_on
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
@ -87,22 +132,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
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
;;
@ -117,13 +162,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
@ -133,7 +178,7 @@ if [[ $particl_mnemonic ]]; then
fi
## Configure Monero
echo -e "\n[1] Connect to a Monero node\n[2] Allow BasicSwapDEX to run a Monero node (+70GB)\n"
printf "\n[1] Connect to a Monero node\n[2] Allow BasicSwapDEX to run a Monero node (+70GB)\n"
until [[ "$l" =~ ^[12]$ ]]; do
read -p 'Select an option [1|2]: ' l
case $l in
@ -141,16 +186,23 @@ read -p 'Select an option [1|2]: ' l
until [[ $checknode ]]; do
read -p 'Enter Address of Monero node [example: 192.168.1.123] ' monerod_addr
read -p 'Enter RPC Port for the Monero node [example: 18081] ' monerod_port
checknode=$(curl -sk http://$monerod_addr:$monerod_port/get_info)
checknode=$(curl -sk http://$monerod_addr:$monerod_port/get_info | jq .height)
if [[ $checknode ]]; then
$green"\nSuccessfully connected to the XMR node @ $monerod_addr:$monerod_port"; $nocolor
$green"Successfully connected to the XMR node @ $monerod_addr:$monerod_port\n"; $nocolor
else
$red"\nThe node at $monerod_addr:$monerod_port is not accessible. Try again\n\n"; $nocolor
$red"The node at $monerod_addr:$monerod_port is not accessible. Try again\n"; $nocolor
fi
done
if [[ -z $xmrrestoreheight ]]; then
xmrrestoreheight="${checknode}"
fi
$green"Monero wallet Restore Height set to ${xmrrestoreheight}\n"; $nocolor
;;
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
@ -159,29 +211,47 @@ read -p 'Select an option [1|2]: ' l
done
## Begin Install
echo -e "\n\nInstalling BasicSwapDEX"
printf "\nInstalling BasicSwapDEX\n"
read -p 'Press Enter to continue, or CTRL-C to exit.'
# Quest to make trasher happy
trasherdk=$(echo $PATH | grep $USER/.local/bin)
if ! [[ $trasherdk ]]; then
mkdir -p $HOME/.local/bin
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
if [[ -d $HOME/.local/bin/bsx ]]; then
rm -r $HOME/.local/bin/bsx* $HOME/.local/bin/basicswap-bash
fi
mv -f -t $HOME/.local/bin/ basicswap-bash bsx*
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
export TAILS=$TAILS
mkdir -p "$SWAP_DATADIR/venv"
python -m venv "$SWAP_DATADIR/venv"
export monerod_addr="${monerod_addr}"
export monerod_port="${monerod_port}"
export particl_mnemonic="${particl_mnemonic}"
export xmrrestoreheight="${xmrrestoreheight}"
export tor_on="${tor_on}"
export TAILS="${TAILS}"
python3 -m venv "${SWAP_DATADIR}/venv"
## Activate venv
$HOME/.local/bin/bsx/activate_venv.sh