Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
run: ${{ matrix.install }}
- name: Install basicswap-bash
run: |
./basicswap-install.sh --new --tor --internal --regtest
./basicswap-install.sh --new --tor --fullnode --internal --regtest
- name: Run bsx-update
run: |
if [ -n "${{ matrix.set-path }}" ]; then
Expand All @@ -92,7 +92,7 @@ jobs:
- uses: actions/checkout@v4
- name: Install basicswap-bash
run: |
./basicswap-install.sh --new --tor --internal --regtest
./basicswap-install.sh --new --tor --fullnode --internal --regtest
- name: Run bsx-update
run: |
bsx-update
Expand Down
42 changes: 38 additions & 4 deletions basicswap-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ${PIPX_UV:-}
# Enable tor
echo -e "\n[1] Tor ON (requires sudo)\n[2] Tor OFF"
until [[ "$tor_on" =~ ^[12]$ ]]; do
if [[ "$1 $2 $3" == *"tor"* ]]; then
if [[ "$1 $2 $3 $4" == *"tor"* ]]; then
tor_on=1
else
read -p 'Select an option: [1|2]: ' tor_on
Expand All @@ -75,7 +75,7 @@ done
## Particl restore Seed
echo -e "\n[1] New Install\n[2] Restore from Particl Seed"
until [[ "$restore" =~ ^[12]$ ]]; do
if [[ "$1 $2 $3" == *"new"* ]]; then
if [[ "$1 $2 $3 $4" == *"new"* ]]; then
restore=1
else
read -p 'Select an option: [1|2]: ' restore
Expand Down Expand Up @@ -112,7 +112,7 @@ if [[ $particl_mnemonic ]]; then
*)
until [[ "$xmrrestoreheight" =~ ^[0-9]{1,7}$ ]]; do
read -p $'Enter your Monero Restore Height [example: 2548568] ' xmrrestoreheight
if [[ $xmrrestoreheight =~ ^[0-9]{7}$ ]]; then
if [[ $xmrrestoreheight =~ ^[0-9]{1,7}$ ]]; then
green "Your XMR Restore height: $xmrrestoreheight"
else
red "Try again. Must be 1-7 digits"
Expand All @@ -122,10 +122,43 @@ if [[ $particl_mnemonic ]]; then
esac
fi

# Electrum BTC & LTC
echo -e "\nAdd Electrum (light) wallets for the following coins:"
echo -e "\n[1] BTC \n[2] LTC (no MWEB support)\n[3] Both\n[4] Skip"
until [[ "$electrum" =~ ^[1-4]$ ]]; do
if [[ "$1 $2 $3 $4" == *"electrum"* ]]; then
electrum=3
elif [[ "$1 $2 $3 $4" == *"fullnode"* ]]; then
electrum=4
else
read -p 'Select an option [1-4]: ' electrum
fi
case $electrum in
1)
use_electrum="--btc-mode=electrum --withcoins=bitcoin"
green "Using Electrum for BTC"
;;
2)
use_electrum="--ltc-mode=electrum --withcoins=litecoin"
green "Using Electrum for LTC"
;;
3)
use_electrum="--light --withcoins=bitcoin,litecoin"
green "Using Electrum for BTC and LTC wallets"
;;
4)
echo "Not setting up BTC and LTC"
;;
*)
red "You must answer 1-4"
;;
esac
done

## Configure Monero
echo -e "\n[1] Connect to a Monero node\n[2] Allow BasicSwapDEX to run a Monero node (+90GB)"
until [[ "$node" =~ ^[12]$ ]]; do
if [[ "$1 $2 $3" == *"internal"* ]]; then
if [[ "$1 $2 $3 $4" == *"internal"* ]]; then
node=2
else
read -p 'Select an option [1|2]: ' node
Expand Down Expand Up @@ -217,6 +250,7 @@ fi
cp -r basicswap-bash bsx* $HOME/.local/bin/.

## Make venv and set variables for install
export use_electrum="${use_electrum}"
export monerod_addr="${monerod_addr}"
export monerod_port="${monerod_port}"
export monerod_user="${monerod_user}"
Expand Down
64 changes: 54 additions & 10 deletions bsx/addcoin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,56 @@ fi
local_only=(namecoin litecoin pivx bitcoincash firo)
# coins with separate wallet daemons
wallet_daemon_coins=(monero wownero decred)
# electrum
electrum_capable=(bitcoin litecoin)

manage_daemon_false() {
jq ".chainclients.${addcoin}.manage_daemon = false" \
$SWAP_DATADIR/basicswap.json > basicswap.tmp && mv basicswap.tmp $SWAP_DATADIR/basicswap.json
}

## Remote node
use_electrum() {
jq '.chainclients.'${addcoin}'.connection_type = "electrum"' \
$SWAP_DATADIR/basicswap.json > basicswap.tmp && mv basicswap.tmp $SWAP_DATADIR/basicswap.json
}

existing_config=$(jq .chainclients."${addcoin}" $SWAP_DATADIR/basicswap.json)

## Grab tickers
detect_os_arch
if [[ "${MACOS}" ]]; then
ticker="$(get_coin_ticker "${addcoin}")"
else
ticker="${coin_map[$addcoin]}"
fi

## Electrum
for coin in "${electrum_capable[@]}"; do
if [[ "${coin}" = "${addcoin}" ]]; then
read -p "Use electrum for ${addcoin}? [Y/n]" electrum
if ! [[ "${electrum}" =~ ^[nN]$ ]]; then
skip=1
ticker=$(echo "${ticker,,}")
use_electrum="--${ticker}-mode=electrum"
if [[ "${existing_config}" = null ]]; then
read -p "Use a custom electrum server? [Y/n] " server
if ! [[ "${server}" =~ ^[nN]$ ]]; then
until ! [[ "$confirm_server" =~ ^[nN]$ ]]; do
read -p "Enter server address. Syntax \"address:port\" [example: litecoin.stackwallet.com:20063] " server_address
electrum_server_address="--${ticker}-electrum-server=${server_address}"
green "Is this correct? ${server_address} [Y/n]: "
read -p "" confirm_server
done
green "Using Electrum server @ ${server_address}"
else
echo "Using preset Electrum servers"
fi
fi
fi
fi
done

## Remote node
for coin in "${local_only[@]}"; do
if [[ "${coin}" = "${addcoin}" ]]; then
skip=1
Expand All @@ -31,11 +73,6 @@ done

if ! [[ "${skip}" ]]; then
# Set wallet name
if [[ "${MACOS}" ]]; then
ticker="$(get_coin_ticker "${addcoin}")"
else
ticker="${coin_map[$addcoin]}"
fi
wallet_env="${ticker}_WALLET_NAME"
wallet_name="BSX_${ticker}"

Expand Down Expand Up @@ -89,16 +126,23 @@ fi

## Add the coin
fastsync=""
if [[ ! "${remote_node}" =~ ^[yY]$ ]] && [[ "${addcoin}" = bitcoin ]]; then
read -p 'Use --usebtcfastsync for bitcoin? [Y/n] ' btcfastsync
if [[ ! -d "${SWAP_DATADIR}/bitcoin/blocks" ]] && [[ ! "${remote_node}" =~ ^[yY]$ ]] && [[ "${addcoin}" = bitcoin ]]; then
if [[ -z "${use_electrum}" ]]; then
read -p 'Use --usebtcfastsync for bitcoin? [Y/n] ' btcfastsync
else
echo "Use --usebtcfastsync for bitcoin? This will reduce sync time if you"
read -p 'decide to switch from Electrum to full node in the future. (~20gb) [Y/n] ' btcfastsync
fi
if [[ "${btcfastsync}" =~ ^[nN]$ ]]; then
echo "Not using btcfastsync"
else
echo "Using btcfastsync"
green "Using btcfastsync"
fastsync="--usebtcfastsync"
fi
fi

basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=$addcoin ${fastsync:+$fastsync}
basicswap-prepare --datadir=$SWAP_DATADIR --addcoin=$addcoin ${use_electrum:-} ${electrum_server_address:-} ${fastsync:-}
# if re-enabling coin that is using a remote daemon, disable "manage_daemon"
[[ "${remote_node}" =~ ^[yY]$ ]] && [[ -z "${node_ip}" ]] && manage_daemon_false
# addcoin doesnt respect electrum flags if re-enabling
[[ "${existing_config}" != null ]] && [[ "${use_electrum}" ]] && use_electrum && manage_daemon_false
2 changes: 1 addition & 1 deletion bsx/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enable_tor() {
# Install bsx
[[ $monerod_addr ]] && export XMR_RPC_HOST=$monerod_addr XMR_RPC_PORT=$monerod_port
[[ $monerod_user ]] && export XMR_RPC_USER=$monerod_user XMR_RPC_PWD=$monerod_pass
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 ${particl_mnemonic:+"--particl_mnemonic=\"$particl_mnemonic\""} ${regtest:-} || {
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,wownero --xmrrestoreheight=$xmrrestoreheight --wowrestoreheight=600000 ${particl_mnemonic:+"--particl_mnemonic=\"$particl_mnemonic\""} ${use_electrum:-} ${regtest:-} || {
red "Installation failed. Try again"
exit 1
}
Expand Down
2 changes: 1 addition & 1 deletion bsx/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export BSX_LOCAL_TOR=true # sets host to 127.0.0.1
export BSX_ALLOW_ENV_OVERRIDE=true # required to change the ports

# Network
[[ "${1}${2}${3}${4}" == *"regtest"* ]] && export regtest="--regtest"
[[ "${1}${2}${3}${4}${5}" == *"regtest"* ]] && export regtest="--regtest"

# Colors
red() { echo -e "\e[31;1m$*\e[0m"; }
Expand Down
Loading