diff --git a/docs/build.md b/docs/build.md index 24c5de295..0dddf44a4 100644 --- a/docs/build.md +++ b/docs/build.md @@ -2,7 +2,7 @@ ## From source -1. Install Golang +### 1. Install Golang On Ubuntu, the easiest way to keep up-to-date with the latest stable version of Go is with snap: @@ -12,38 +12,67 @@ sudo snap install go --classic On other systems or in docker, use the directions here: https://go.dev/doc/install. Summary for X86-64 Linux (update GO_VERSION below to the latest stable release): ```bash -GO_VERSION=1.20.3 +GO_VERSION=1.20.5 wget "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz echo "export PATH=$PATH:/usr/local/go/bin" >> .profile source .profile ``` -2. Clone the repo: +### 2a. Build without cloning the repo (option 1) + +If this is your first time testing the software and you don't have an up-to-date +installation of `monero-wallet-rpc` in your path, you may want to skip to 2b +(option 2), as the repo has a script, `scripts/install-monero-linux.sh`, for +installing the latest monero tools to a `monero-bin` subfolder. + +Install the atomic swap binaries to a subfolder named `bin`. If you adjust the +install directory to something else, make sure to also adjust documented sample +commands accordingly: +```bash +GOBIN=${PWD}/bin go install -tags=prod github.com/athanorlabs/atomic-swap/cmd/...@latest +``` + +### 2b. Build from a cloned repo (option 2) + +Clone the repo, put it on the commit hash of the most recent release, and build +the binaries: ```bash git clone https://github.com/athanorlabs/atomic-swap.git cd atomic-swap + +# Check out the exact source code of the latest release +git checkout "$(git describe --abbrev=0 --tags)" + +make build-release ``` -3. Finally, build the repo: +Note that `build-release` always builds the latest tagged release, not the +currently checked out code, so the `git checkout` command above is not required +for the correct binaries. If you want to build the checked out code as-is, use +`make build` or `make build-all` (the latter includes the `bootnode` +executable), as you'll see in the next example. + +If you wish to build the bleeding edge code that is not always compatible with +the previous release, do: ```bash +git checkout master && git pull make build ``` -This creates `swapd` and `swapcli` binaries in the `bin` folder. - -Note: if you wish to run a bootnode (see [here](./bootnode.md)), run `make build-all`. - ## Docker -1. Ensure docker is installed on your machine. +### 1. Ensure docker is installed on your machine. + +For the purposes here, using `docker-ce` directly from Ubuntu's `apt` +repositories or from Docker's repositories will work equally well. -2. Build the docker image: +### 2. Build the docker image: ```bash make docker-images ``` -3. For an example of how to run `swapd` with docker on stagenet: +### 3. For an example of how to run `swapd` with docker on stagenet: ```bash ./scripts/docker-swapd/run-docker-image.sh ``` @@ -59,4 +88,3 @@ You can also set command line arguments with environment variables, eg. to run o ```bash SWAPD_ENV=mainnet SWAPD_ETH_ENDPOINT=your-eth-endpoint ./scripts/docker-swapd/run-docker-image.sh ``` - diff --git a/docs/rpc.md b/docs/rpc.md index cbdde03c3..021f956a2 100644 --- a/docs/rpc.md +++ b/docs/rpc.md @@ -45,9 +45,9 @@ curl -s -X POST http://127.0.0.1:5000 -H 'Content-Type: application/json' -d \ Discover peers on the network via DHT that have active swap offers. Parameters: -- `provides` (optional): one of `ETH` or `XMR`, depending on which offer you are searching +- `provides`: (optional) one of `ETH` or `XMR`, depending on which offer you are searching for. **Note**: Currently only `XMR` offers are supported. Default is `XMR`. -- `searchTime` (optional): time in seconds to perform the search. Default is 12s. +- `searchTime`: (optional) time in seconds to perform the search. Default is 12s. Returns: - `peers`: list of lists of peers's multiaddresses. A peer may have multiple multiaddresses, so the nested list pertains to a single peer. @@ -79,9 +79,9 @@ curl -s -X POST http://127.0.0.1:5000 -H 'Content-Type: application/json' -d \ Discover peers on the network via DHT that have active swap offers and gets all their swap offers. Parameters: -- `provides` (optional): one of `ETH` or `XMR`, depending on which offer you are searching +- `provides`: (optional) one of `ETH` or `XMR`, depending on which offer you are searching for. **Note**: Currently only `XMR` offers are supported. Default is `XMR`. -- `searchTime` (optional): duration in seconds for which to perform the search. Default is 12s. +- `searchTime`: (optional) duration in seconds for which to perform the search. Default is 12s. Returns: - `peersWithOffers`: list of peers's multiaddresses and their current offers. @@ -514,6 +514,38 @@ curl -s -X POST http://127.0.0.1:5000 -H 'Content-Type: application/json' -d \ } ``` +### `swap_clearOffers` + +Clears one or more offers if offer IDs are passed, or all offers if no offer IDs +are passed. This method is only for removing offers that have not been taken, +use `swap_cancel` to cancel an active swap. + +Parameters: +- `id`: id of the swap to get the stage of +- `offerIDs`: (optional) Array of offer IDs to clear, or empty to clear all offers + +Returns: +- null + +Example: +```bash +curl -s -X POST http://127.0.0.1:5000 -H 'Content-Type: application/json' -d \ +'{"jsonrpc":"2.0","id":"0","method":"swap_clearOffers", + "params": { + "offerIds": [ + "0xd66041fd63512c18ff6554c8b4c608be40c8eaa95e29e08af08cf632c7040595" + ] + } +}' | jq +``` +```json +{ + "jsonrpc": "2.0", + "result": null, + "id": "0" +} +``` + ### `swap_suggestedExchangeRate` Returns the current mainnet exchange rate expressed as the XMR/ETH price ratio. diff --git a/scripts/docker-bootnode/Dockerfile b/scripts/docker-bootnode/Dockerfile index 2c7d4b6bc..ff8b07e85 100644 --- a/scripts/docker-bootnode/Dockerfile +++ b/scripts/docker-bootnode/Dockerfile @@ -6,7 +6,7 @@ RUN go install -tags=prod \ github.com/athanorlabs/atomic-swap/cmd/swapcli@"${VERSION}" RUN /go/bin/bootnode --version -FROM debian:bullseye-slim +FROM debian:bookworm-slim RUN apt-get update && apt-get install -y ca-certificates gosu COPY --from=builder /go/bin/ /usr/local/bin/ diff --git a/scripts/docker-swapd/Dockerfile b/scripts/docker-swapd/Dockerfile index f2acf2c91..916df2175 100644 --- a/scripts/docker-swapd/Dockerfile +++ b/scripts/docker-swapd/Dockerfile @@ -14,7 +14,7 @@ RUN go install -tags=prod \ github.com/athanorlabs/atomic-swap/cmd/swapcli@"${VERSION}" RUN /go/bin/swapd --version -FROM debian:bullseye-slim +FROM debian:bookworm-slim RUN apt-get update && apt-get install -y ca-certificates gosu # /usr/local/bin has swapd, swapcli, monero-wallet-rpc and