basicswap-bash/bsx/setup.sh

71 lines
2.6 KiB
Bash
Raw Permalink Normal View History

2024-01-21 22:34:44 +00:00
#!/bin/bash
2024-02-05 02:03:49 +00:00
# Colors
red="echo -e -n \e[31;1m"
green="echo -e -n \e[32;1m"
nocolor="echo -e -n \e[0m"
2024-01-21 22:34:44 +00:00
## 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
2024-02-25 13:28:40 +00:00
mv -f ./coincurve-anonswap/*/{.,}* ./coincurve-anonswap || true
2024-01-21 22:34:44 +00:00
cd $SWAP_DATADIR/coincurve-anonswap
2024-02-25 13:28:40 +00:00
$SWAP_DATADIR/venv/bin/pip install .
2024-01-21 22:34:44 +00:00
## Clone basicswap git
cd $SWAP_DATADIR
2024-06-22 01:48:18 +00:00
git clone https://github.com/basicswap/basicswap
2024-01-21 22:34:44 +00:00
cd $SWAP_DATADIR/basicswap
## Install basicswap
2024-02-25 13:28:40 +00:00
$SWAP_DATADIR/venv/bin/pip install .
2024-01-21 22:34:44 +00:00
2024-02-05 02:03:49 +00:00
## Decide a source for Monero's restore height
if [[ "$xmrrestoreheight" ]]; then
CURRENT_XMR_HEIGHT=$xmrrestoreheight
elif [[ "$monerod_addr" ]]; then
# Use custom Monero node
2024-01-26 10:31:51 +00:00
CURRENT_XMR_HEIGHT=$(curl "http://$monerod_addr:$monerod_port/get_info" | jq .height)
2024-02-05 02:03:49 +00:00
else
# Use public node
2024-06-04 02:20:34 +00:00
CURRENT_XMR_HEIGHT=$(curl http://node3.monerodevs.org:18089/get_info | jq .height)
2024-02-05 02:03:49 +00:00
fi
2024-02-25 13:28:40 +00:00
# Use Tor if we want
enable_tor() {
if [[ "$tor_on" = 1 ]]; then
2024-06-05 18:36:36 +00:00
$HOME/.local/bin/bsx-enabletor
2024-02-25 13:28:40 +00:00
fi
}
2024-06-04 02:20:34 +00:00
# Use the custom Monero node & add wownero because its a small chain
2024-02-25 13:28:40 +00:00
if [[ "$particl_mnemonic" && "$monerod_addr" ]]; then
2024-06-04 02:20:34 +00:00
# Restore seed
2024-02-05 02:03:49 +00:00
PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC"
2024-06-04 02:20:34 +00:00
# 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
2024-02-25 13:28:40 +00:00
enable_tor
2024-02-24 16:24:07 +00:00
elif [[ "$particl_mnemonic" ]]; then
2024-06-04 02:20:34 +00:00
# Restore seed
2024-02-05 02:03:49 +00:00
PARTICL_MNEMONIC=$particl_mnemonic
basicswap-prepare --datadir=$SWAP_DATADIR --particl_mnemonic="$PARTICL_MNEMONIC"
2024-06-04 02:20:34 +00:00
# Add coins using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
2024-02-25 13:28:40 +00:00
enable_tor
elif [[ "$monerod_addr" ]]; then
2024-06-04 02:20:34 +00:00
# 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
2024-02-25 13:28:40 +00:00
$red"\n\nMake note of your seed above\n"; $nocolor
enable_tor
2024-02-05 02:03:49 +00:00
else
2024-06-04 02:20:34 +00:00
# Setup new install using local nodes
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$CURRENT_XMR_HEIGHT --wowrestoreheight=600000
2024-02-05 02:03:49 +00:00
$red"\n\nMake note of your seed above\n"; $nocolor
2024-02-25 13:28:40 +00:00
enable_tor
2024-01-26 10:31:51 +00:00
fi
2024-01-21 22:34:44 +00:00
2024-02-25 13:28:40 +00:00
$green"Install complete.\n\nUse 'basicswap-bash' to run, 'bsx-update' to update, and 'bsx-addcoin' to add a coin\n"; $nocolor