basicswap/doc/install.md

217 lines
6.6 KiB
Markdown
Raw Normal View History

2019-07-26 13:07:22 +00:00
## Source code
2019-07-26 13:07:22 +00:00
git clone https://github.com/tecnovert/basicswap.git
2019-07-26 13:07:22 +00:00
## Run Using Docker
2022-06-27 20:10:28 +00:00
Install dependencies:
2022-12-08 15:06:38 +00:00
apt-get install curl jq git
2022-06-27 20:10:28 +00:00
2019-07-26 13:07:22 +00:00
Docker must be installed and started:
docker -v
2019-07-26 13:07:22 +00:00
2021-11-03 21:20:19 +00:00
Should return a line containing `Docker version`...
2022-06-27 20:10:28 +00:00
To install docker engine on your platform see:
https://docs.docker.com/engine/install/#server
It's recommended to setup docker to work without sudo.<br>
Without this step you will need to preface each `docker-compose` command with `sudo`:
2022-05-23 21:51:06 +00:00
https://docs.docker.com/engine/install/linux-postinstall/
2021-02-14 13:06:46 +00:00
#### Create the images:
2019-07-26 13:07:22 +00:00
COINDATA_PATH can be set to your preference but must be exported each time you launch Basicswap.<br>
2022-06-27 20:10:28 +00:00
Consider adding COINDATA_PATH to the `.env` file in the docker directory file so it's always set.
export COINDATA_PATH=/var/data/coinswaps
cd basicswap/docker
docker-compose build
2019-07-26 13:07:22 +00:00
2023-01-11 20:52:46 +00:00
Depending on your environment, the `docker-compose` may not work. If that's the case, type `docker compose` instead, without the dash.
2021-02-14 13:06:46 +00:00
#### Prepare the datadir:
Set xmrrestoreheight to the current xmr chain height.
CURRENT_XMR_HEIGHT=$(curl https://localmonero.co/blocks/api/get_stats | jq .height)
2021-01-05 18:10:33 +00:00
Adjust `--withcoins` and `--withoutcoins` as desired, eg: `--withcoins=monero,bitcoin`. By default only Particl is loaded.
2022-06-27 20:10:28 +00:00
##### FastSync
Append `--usebtcfastsync` to the below command to optionally initialise the Bitcoin datadir with a chain snapshot from btcpayserver FastSync.<br>
[FastSync README.md](https://github.com/btcpayserver/btcpayserver-docker/blob/master/contrib/FastSync/README.md)
Setup with a local Monero daemon (recommended):
export COINDATA_PATH=/var/data/coinswaps
2022-07-31 21:40:58 +00:00
docker run --rm -t --name swap_prepare -v $COINDATA_PATH:/coindata i_swapclient basicswap-prepare --datadir=/coindata --withcoins=monero --htmlhost="0.0.0.0" --wshost="0.0.0.0" --xmrrestoreheight=$CURRENT_XMR_HEIGHT
2021-02-14 13:06:46 +00:00
2022-06-27 20:10:28 +00:00
To instead use Monero public nodes and not run a local Monero daemon<br>(it can be difficult to find reliable public nodes):
2021-02-14 13:06:46 +00:00
2022-06-27 20:10:28 +00:00
Set XMR_RPC_HOST and BASE_XMR_RPC_PORT to a public XMR node.
export COINDATA_PATH=/var/data/coinswaps
2022-07-31 21:40:58 +00:00
docker run --rm -e XMR_RPC_HOST="node.xmr.to" -e BASE_XMR_RPC_PORT=18081 -t --name swap_prepare -v $COINDATA_PATH:/coindata i_swapclient basicswap-prepare --datadir=/coindata --withcoins=monero --htmlhost="0.0.0.0" --wshost="0.0.0.0" --xmrrestoreheight=$CURRENT_XMR_HEIGHT
2022-06-27 20:10:28 +00:00
**Record the mnemonic from the output of the above command.**
And the output of `echo $CURRENT_XMR_HEIGHT` for use if you need to later restore your wallet.
2023-01-11 20:52:46 +00:00
#### Make COINDATA_PATH permanent:
Edit the `.env` file in the docker directory and uncomment COINDATA_PATH line by deleting the hashtag.
#### Set the timezone (optional):
2021-02-14 13:06:46 +00:00
Edit the `.env` file in the docker directory, set TZ to your local timezone.
Valid options can be listed with: `timedatectl list-timezones`
2019-07-26 13:07:22 +00:00
2021-02-14 13:06:46 +00:00
#### Start the container:
2019-07-26 13:07:22 +00:00
export COINDATA_PATH=/var/data/coinswaps
docker-compose up
2019-07-26 13:07:22 +00:00
Open in browser: `http://localhost:12700`
2019-07-26 13:07:22 +00:00
2021-01-05 12:31:02 +00:00
### Add a coin
docker-compose stop
export COINDATA_PATH=/var/data/coinswaps
2022-12-11 23:30:33 +00:00
docker run --rm -t --name swap_prepare -v $COINDATA_PATH:/coindata i_swapclient basicswap-prepare --datadir=/coindata --addcoin=bitcoin --usebtcfastsync
You can copy an existing pruned datadir (excluding bitcoin.conf and any wallets) over to `$COINDATA_PATH/bitcoin`
Remove any existing wallets after copying over a pruned chain or the Bitcoin daemon won't start.
2019-07-26 13:07:22 +00:00
2022-12-11 23:30:33 +00:00
With Encryption
export COINDATA_PATH=/var/data/coinswaps
docker run -e WALLET_ENCRYPTION_PWD=passwordhere --rm -t --name swap_prepare -v $COINDATA_PATH:/coindata i_swapclient basicswap-prepare --datadir=/coindata --addcoin=bitcoin --usebtcfastsync
2021-02-06 08:19:46 +00:00
2021-11-03 21:20:19 +00:00
## Windows
2021-02-06 08:19:46 +00:00
2021-11-03 21:20:19 +00:00
#### Setup WSL 2 and Docker Desktop
2021-01-05 12:31:02 +00:00
[docs.docker.com/docker-for-windows/wsl](https://docs.docker.com/docker-for-windows/wsl/)
2021-11-03 21:20:19 +00:00
Open a wsl terminal
Windows key + R -> "wsl" -> Enter
2021-01-05 12:31:02 +00:00
2021-02-06 08:19:46 +00:00
2021-11-03 21:20:19 +00:00
Install Git:
2021-02-06 08:19:46 +00:00
sudo apt update
sudo apt install git
2021-02-06 08:19:46 +00:00
2021-11-03 21:20:19 +00:00
Download the BasicSwap code:
git clone https://github.com/tecnovert/basicswap.git
cd basicswap/docker/
2021-02-06 08:19:46 +00:00
2021-11-03 21:20:19 +00:00
It's significantly faster to set COINDATA_PATH in the linux filesystem.
You can access it from the windows side at: `\\wsl$\Ubuntu`
2021-02-06 08:19:46 +00:00
Continue from the [Run Using Docker](#run-using-docker) section.
## Run Without Docker:
2019-07-26 13:07:22 +00:00
### Ubuntu Setup:
apt-get install -y wget python3-pip gnupg unzip protobuf-compiler automake libtool pkg-config curl jq
2019-07-26 13:07:22 +00:00
### OSX Setup:
Install Homebrew (See https://brew.sh/):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Dependencies:
2022-06-25 20:10:31 +00:00
brew install wget unzip python git protobuf gnupg automake libtool pkg-config curl jq
2022-06-25 20:10:31 +00:00
Close the terminal and open a new one to update the python symlinks.
### Basicswap:
export SWAP_DATADIR=/Users/$USER/coinswaps
mkdir -p "$SWAP_DATADIR/venv"
python3 -m venv "$SWAP_DATADIR/venv"
. $SWAP_DATADIR/venv/bin/activate && python -V
cd $SWAP_DATADIR
2022-06-29 12:17:57 +00:00
wget -O coincurve-anonswap.zip https://github.com/tecnovert/coincurve/archive/refs/tags/anonswap_v0.1.zip
unzip -d coincurve-anonswap coincurve-anonswap.zip
mv ./coincurve-anonswap/*/{.,}* ./coincurve-anonswap || true
cd $SWAP_DATADIR/coincurve-anonswap
pip3 install .
2019-07-26 13:07:22 +00:00
cd $SWAP_DATADIR
git clone https://github.com/tecnovert/basicswap.git
cd $SWAP_DATADIR/basicswap
2022-06-25 20:10:31 +00:00
If installed on OSX, you may need to install additional root ssl certificates for the ssl module.
From https://pypi.org/project/certifi/
sudo python3 bin/install_certifi.py
Continue installing Basicswap
protoc -I=basicswap --python_out=basicswap basicswap/messages.proto
pip3 install .
2019-07-26 13:07:22 +00:00
2022-06-25 20:10:31 +00:00
Prepare the datadir:
CURRENT_XMR_HEIGHT=$(curl https://localmonero.co/blocks/api/get_stats | jq .height)
XMR_RPC_HOST="node.xmr.to" BASE_XMR_RPC_PORT=18081 basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero --xmrrestoreheight=$CURRENT_XMR_HEIGHT
OR using a local XMR daemon:
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero --xmrrestoreheight=$CURRENT_XMR_HEIGHT
Record the mnemonic from the output of the above command.
Start Basicswap:
basicswap-run --datadir=$SWAP_DATADIR
Open in browser: `http://localhost:12700`
It may take a few minutes to start as the coin daemons are started before the http interface.
2019-07-26 13:07:22 +00:00
2022-06-27 20:10:28 +00:00
Add a coin (Stop basicswap first):
export SWAP_DATADIR=/Users/$USER/coinswaps
basicswap-prepare --usebtcfastsync --datadir=/$SWAP_DATADIR --addcoin=bitcoin
Start after installed:
export SWAP_DATADIR=/Users/$USER/coinswaps
. $SWAP_DATADIR/venv/bin/activate && python -V
basicswap-run --datadir=$SWAP_DATADIR