diff --git a/README.md b/README.md index d010cd7..ec2f70d 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,24 @@ # basicswap-bash -A BasicSwapDEX bash installer for Debian/Ubuntu +A BasicSwapDEX bash installer for Debian/Ubuntu/Arch/Fedora +User account must have sudo privileges ### 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 -b dev cd basicswap-bash && ./install.sh +cd .. && rm -rf basicswap-bash ``` + + ### Running BasicSwapDEX ``` basicswap-bash ``` +#### Update BSX core +``` +bsx-update +``` #### Enable/Disable Tor [post install] ``` @@ -20,17 +28,17 @@ bsx-enabletor bsx-disabletor ``` -#### Add coins +#### Add/remove coins ``` bsx-addcoin ``` +``` +bsx-removecoin +``` + #### Update blockchains ``` -bsx-upgrade-coins -``` -#### Update BSX core -``` -bsx-update +bsx-upgradecoins ``` diff --git a/bsx-removecoin b/bsx-removecoin index dfba901..674b41c 100755 --- a/bsx-removecoin +++ b/bsx-removecoin @@ -1,4 +1,4 @@ #!/bin/bash export SWAP_DATADIR=$HOME/coinswaps . $SWAP_DATADIR/venv/bin/activate && python -V -/usr/local/bin/bsx/disablecoin.sh +/usr/local/bin/bsx/removecoin.sh diff --git a/bsx/activate_venv.sh b/bsx/activate_venv.sh index 5c67b26..0ef6e55 100755 --- a/bsx/activate_venv.sh +++ b/bsx/activate_venv.sh @@ -1,3 +1,7 @@ #!/bin/bash . $SWAP_DATADIR/venv/bin/activate && python -V +if [[ $TAILS ]]; then +/usr/local/bin/bsx/tails_setup.sh +else /usr/local/bin/bsx/setup.sh +fi diff --git a/bsx/addcoin.sh b/bsx/addcoin.sh index d373bc3..611f217 100755 --- a/bsx/addcoin.sh +++ b/bsx/addcoin.sh @@ -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" +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 ## 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 diff --git a/bsx/removecoin.sh b/bsx/removecoin.sh index 33f08c7..d928b53 100755 --- a/bsx/removecoin.sh +++ b/bsx/removecoin.sh @@ -1,8 +1,8 @@ #!/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 +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 ## Confirm echo -e "\nDisable $disablecoin on your BasicSwap install, correct? Press any key to continue. CTRL-C to exit" read diff --git a/bsx/setup.sh b/bsx/setup.sh index e65b2c7..c73cafb 100755 --- a/bsx/setup.sh +++ b/bsx/setup.sh @@ -5,9 +5,6 @@ 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 @@ -21,7 +18,6 @@ cd $SWAP_DATADIR git clone https://github.com/tecnovert/basicswap.git cd $SWAP_DATADIR/basicswap ## Install basicswap -protoc -I=basicswap --python_out=basicswap basicswap/messages.proto $SWAP_DATADIR/venv/bin/pip install . ## Decide a source for Monero's restore height @@ -32,7 +28,7 @@ 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 @@ -42,22 +38,31 @@ enable_tor() { 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 + # 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 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 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 + # 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 enable_tor else - basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero --xmrrestoreheight=$CURRENT_XMR_HEIGHT + # 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 enable_tor fi diff --git a/bsx/tails_setup.sh b/bsx/tails_setup.sh new file mode 100755 index 0000000..11d7f20 --- /dev/null +++ b/bsx/tails_setup.sh @@ -0,0 +1,73 @@ +#!/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 + +## Clone basicswap git +cd $SWAP_DATADIR +git clone https://github.com/tecnovert/basicswap.git +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) +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 + /usr/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 + 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 + 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 + 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 + 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 + 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 diff --git a/bsx/update.sh b/bsx/update.sh index 69c4c08..ee4be1f 100755 --- a/bsx/update.sh +++ b/bsx/update.sh @@ -1,4 +1,11 @@ #!/bin/bash cd $SWAP_DATADIR/basicswap + +# Delete dangling build folder. Same as --no-cache for docker +rm -rf ~/coinswaps/basicswap/build +# Fix any conflicts from potential force-pushes +git reset HEAD~5 --hard +# Pull repo git pull +# Install $SWAP_DATADIR/venv/bin/pip install . diff --git a/bsx/upgradecoins.sh b/bsx/upgradecoins.sh index e10c3c3..1ceace6 100755 --- a/bsx/upgradecoins.sh +++ b/bsx/upgradecoins.sh @@ -1,13 +1,13 @@ #!/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 +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 $'\nUpdate $updatecoin, correct? Press any key to continue. CTRL-C to exit' +read -p $'\nUpgrade '$upgradecoin', correct? Press any key to continue. CTRL-C to exit' -## Update the coin -basicswap-prepare --datadir=$SWAP_DATADIR -preparebinonly --withcoins=$updatecoin -echo "Updated $updatecoin" +## Upgrade the coin +basicswap-prepare --datadir=$SWAP_DATADIR -preparebinonly --withcoins=$upgradecoin +echo "Upgraded $upgradecoin" diff --git a/install.sh b/install.sh index cc6e065..cb851e2 100755 --- a/install.sh +++ b/install.sh @@ -20,29 +20,40 @@ $nocolor INSTALL="" UPDATE="" DEPENDENCY="" +TAILS="" + +check_tails() { + if [ $USER == amnesia ]; then + $green"\nDetected Tails\n";$nocolor + TAILS=1 + else + $green"\nDetected Debian\n";$nocolor + fi +} + detect_os_arch() { if 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 + DEPENDENCY="python-is-python3 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 protobuf-compiler" + DEPENDENCY="python3-virtualenv python3-pip python3-devel gnupg2 pkgconf" $green"\nDetected Fedora\n";$nocolor elif type -P pacman > /dev/null; then # Arch Linux INSTALL="sudo pacman -S" UPDATE="sudo pacman -Syu" - DEPENDENCY="python-pipenv gnupg protobuf pkgconf base-devel" + 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 protobuf gnupg pkg-config" + DEPENDENCY="python gnupg pkg-config" $green"\nDetected MacOS\n";$nocolor else $red"Failed to detect OS. Unsupported or unknown distribution.\nInstall Failed.";$nocolor @@ -150,6 +161,7 @@ export monerod_port=$monerod_port export particl_mnemonic=$particl_mnemonic export xmrrestoreheight=$xmrrestoreheight export tor_on=$tor_on +export TAILS=$TAILS mkdir -p "$SWAP_DATADIR/venv" python -m venv "$SWAP_DATADIR/venv" ## Activate venv