#!/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