2019-07-26 13:07:22 +00:00
2022-06-27 20:10:28 +00:00
2024-10-14 08:31:48 +00:00
## Run using Docker
2022-06-27 20:10:28 +00:00
2019-07-26 13:07:22 +00:00
Docker must be installed and started:
2020-12-06 17:34:56 +00:00
2022-06-18 17:28:40 +00:00
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` ...
2020-12-05 11:22:22 +00:00
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/
2024-10-14 08:31:48 +00:00
#### Install dependencies
apt-get install --no-install-recommends git curl jq
#### Get the source code
git clone https://github.com/basicswap/basicswap.git
#### Copy the default environment file
2024-02-12 19:49:24 +00:00
cd basicswap/docker
cp example.env .env
2024-10-14 08:31:48 +00:00
#### (Optional) Set custom coin data path
2019-07-26 13:07:22 +00:00
2024-10-14 08:31:48 +00:00
Coin-related files, such as blockchain and wallet files, are stored in `/var/data/coinswaps` by default. To use a different location, simply modify `COINDATA_PATH` in your `.env` file found within the `/docker` sub-folder.
2024-02-09 16:25:05 +00:00
cd basicswap/docker
nano .env
2024-10-14 08:31:48 +00:00
#### Create the images
2022-06-27 20:10:28 +00:00
2022-06-18 17:28:40 +00:00
cd basicswap/docker
docker-compose build
2019-07-26 13:07:22 +00:00
2023-01-11 20:57:19 +00:00
Depending on your environment, the `docker-compose` command may not work. If that's the case, type `docker compose` instead, without the dash.
2021-02-14 13:06:46 +00:00
2024-10-14 08:31:48 +00:00
#### Prepare the datadir
2021-02-14 13:06:46 +00:00
2020-12-08 22:05:28 +00:00
Set xmrrestoreheight to the current xmr chain height.
2022-06-18 17:28:40 +00:00
2024-09-21 00:03:06 +00:00
CURRENT_XMR_HEIGHT=$(curl -s http://node2.monerodevs.org:18089/get_info | jq .height)
2022-06-18 17:28:40 +00:00
2021-01-05 18:10:33 +00:00
Adjust `--withcoins` and `--withoutcoins` as desired, eg: `--withcoins=monero,bitcoin` . By default only Particl is loaded.
2020-12-05 11:22:22 +00:00
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):
2024-04-28 22:40:50 +00:00
docker-compose run --rm swapclient basicswap-prepare --datadir=/coindata --withcoins=monero --htmlhost="0.0.0.0" --wshost="0.0.0.0" --xmrrestoreheight=$CURRENT_XMR_HEIGHT
2020-12-05 11:22:22 +00:00
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
2024-09-30 22:41:40 +00:00
Set XMR_RPC_HOST and XMR_RPC_PORT to a public XMR node.
docker-compose run --rm -e XMR_RPC_HOST="node.xmr.to" -e XMR_RPC_PORT=18081 swapclient basicswap-prepare --datadir=/coindata --withcoins=monero --htmlhost="0.0.0.0" --wshost="0.0.0.0" --xmrrestoreheight=$CURRENT_XMR_HEIGHT
2022-06-04 20:41:24 +00:00
2022-06-27 20:10:28 +00:00
**Record the mnemonic from the output of the above command.**
2023-07-18 23:19:04 +00:00
**Mnemonics should be stored encrypted and/or air-gapped.**
2022-06-27 20:10:28 +00:00
And the output of `echo $CURRENT_XMR_HEIGHT` for use if you need to later restore your wallet.
2022-06-04 20:41:24 +00:00
2024-10-14 08:31:48 +00:00
#### 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`
2020-12-05 11:22:22 +00:00
2019-07-26 13:07:22 +00:00
2024-10-14 08:31:48 +00:00
#### Start the container
2019-07-26 13:07:22 +00:00
2022-06-18 17:28:40 +00:00
docker-compose up
2019-07-26 13:07:22 +00:00
2020-12-05 11:22: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
2020-12-06 17:34:56 +00:00
### Add a coin
2022-06-18 17:28:40 +00:00
docker-compose stop
2024-04-28 22:40:50 +00:00
docker-compose run --rm swapclient basicswap-prepare --datadir=/coindata --addcoin=bitcoin --usebtcfastsync
2020-12-06 17:34:56 +00:00
You can copy an existing pruned datadir (excluding bitcoin.conf and any wallets) over to `$COINDATA_PATH/bitcoin`
2020-12-08 22:05:28 +00:00
Remove any existing wallets after copying over a pruned chain or the Bitcoin daemon won't start.
2020-12-06 17:34:56 +00:00
2019-07-26 13:07:22 +00:00
2022-12-11 23:30:33 +00:00
With Encryption
2024-04-28 22:40:50 +00:00
docker-compose run --rm -e WALLET_ENCRYPTION_PWD=passwordhere swapclient basicswap-prepare --datadir=/coindata --addcoin=bitcoin --usebtcfastsync
2022-12-11 23:30:33 +00:00
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
2022-06-18 17:28:40 +00:00
sudo apt update
2024-10-14 08:31:48 +00:00
sudo apt install --no-install-recommends git
2021-02-06 08:19:46 +00:00
2021-11-03 21:20:19 +00:00
Download the BasicSwap code:
2024-06-11 07:56:09 +00:00
git clone https://github.com/basicswap/basicswap.git
2022-06-18 17:28:40 +00:00
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.
2024-10-14 08:31:48 +00:00
## Run Without Docker
2019-07-26 13:07:22 +00:00
2024-10-14 08:31:48 +00:00
### Ubuntu Setup
2020-12-30 21:01:21 +00:00
2024-10-14 08:31:48 +00:00
apt-get install --no-install-recommends git python3-venv libpython3-dev gnupg pkg-config gcc libc-dev curl jq
2020-12-30 21:01:21 +00:00
2019-07-26 13:07:22 +00:00
2024-10-14 08:31:48 +00:00
### OSX Setup
2020-12-30 21:01:21 +00:00
2022-06-18 17:28:40 +00:00
Install Homebrew (See https://brew.sh/):
2020-12-30 21:01:21 +00:00
2022-06-18 17:28:40 +00:00
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2020-12-30 21:01:21 +00:00
Dependencies:
2024-10-14 08:31:48 +00:00
brew install python git gnupg pkg-config jq
2022-06-18 17:28:40 +00:00
2022-06-25 20:10:31 +00:00
Close the terminal and open a new one to update the python symlinks.
2020-12-30 21:01:21 +00:00
2024-10-14 08:31:48 +00:00
### Basicswap
2020-12-30 21:01:21 +00:00
2024-09-21 00:03:06 +00:00
export SWAP_DATADIR=$HOME/coinswaps
2022-06-18 17:28:40 +00:00
python3 -m venv "$SWAP_DATADIR/venv"
. $SWAP_DATADIR/venv/bin/activate & & python -V
2019-07-26 13:07:22 +00:00
2022-06-18 17:28:40 +00:00
cd $SWAP_DATADIR
2024-06-11 07:56:09 +00:00
git clone https://github.com/basicswap/basicswap.git
2022-06-18 17:28:40 +00:00
cd $SWAP_DATADIR/basicswap
2022-06-25 20:10:31 +00:00
2023-12-19 09:13:41 +00:00
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
2024-10-10 17:54:15 +00:00
Continue installing dependencies and Basicswap.
2022-06-25 20:10:31 +00:00
2024-10-10 17:54:15 +00:00
pip3 install -r requirements.txt --require-hashes & & pip3 install .
2019-07-26 13:07:22 +00:00
2022-06-25 20:10:31 +00:00
2020-12-05 11:22:22 +00:00
Prepare the datadir:
2024-09-21 00:03:06 +00:00
CURRENT_XMR_HEIGHT=$(curl -s http://node2.monerodevs.org:18089/get_info | jq .height)
2022-06-18 17:28:40 +00:00
2023-12-19 09:13:41 +00:00
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero --xmrrestoreheight=$CURRENT_XMR_HEIGHT
OR using a remote/public XMR daemon (not recommended):
2024-09-30 22:41:40 +00:00
XMR_RPC_HOST="node.xmr.to" XMR_RPC_PORT=18081 basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero --xmrrestoreheight=$CURRENT_XMR_HEIGHT
2020-12-05 11:22:22 +00:00
2020-12-30 21:01:21 +00:00
2020-12-05 11:22:22 +00:00
Record the mnemonic from the output of the above command.
2022-06-18 17:28:40 +00:00
Start Basicswap:
2020-12-05 11:22:22 +00:00
2022-06-18 17:28:40 +00:00
basicswap-run --datadir=$SWAP_DATADIR
2020-12-05 11:22:22 +00:00
2023-12-19 09:13:41 +00:00
2020-12-05 11:22:22 +00:00
Open in browser: `http://localhost:12700`
2020-12-31 12:53:31 +00:00
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):
2022-06-18 17:28:40 +00:00
export SWAP_DATADIR=/Users/$USER/coinswaps
basicswap-prepare --usebtcfastsync --datadir=/$SWAP_DATADIR --addcoin=bitcoin
2020-12-30 21:01:21 +00:00
Start after installed:
2022-06-18 17:28:40 +00:00
export SWAP_DATADIR=/Users/$USER/coinswaps
. $SWAP_DATADIR/venv/bin/activate & & python -V
basicswap-run --datadir=$SWAP_DATADIR