mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-05-03 15:24:53 -04:00
refactor(docs): move source for doc pages here (#119)
* docs: move dev docs to dev-docs folder * docs: move source for doc pages here * docs: improve docs
This commit is contained in:
parent
5341587dfa
commit
bfc82c0534
46 changed files with 6307 additions and 0 deletions
6
dev-docs/README.md
Normal file
6
dev-docs/README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Documentation
|
||||
|
||||
This directory hosts various pieces of documentation.
|
||||
|
||||
- [`swap` CLI](./cli/README.md)
|
||||
- [`asb` service](./asb/README.md)
|
205
dev-docs/asb/README.md
Normal file
205
dev-docs/asb/README.md
Normal file
|
@ -0,0 +1,205 @@
|
|||
# Automated Swap Backend (ASB)
|
||||
|
||||
## Quick Start
|
||||
|
||||
From version `0.6.0` onwards the software default to running on `mainnet`.
|
||||
It is recommended to try the software on testnet first, which can be achieved by providing the `--testnet` flag.
|
||||
This quickstart guide assumes that you are running the software on testnet (i.e. Bitcoin testnet3 and Monero stagenet):
|
||||
|
||||
1. Download [latest release](https://github.com/comit-network/xmr-btc-swap/releases/latest) of the `asb` binary
|
||||
2. Ensure that you have the Monero Wallet RPC running with `--wallet-dir` and `--disable-rpc-login`:
|
||||
1. `monero-wallet-rpc --stagenet --daemon-host STAGENET-NODE-URL --rpc-bind-port STAGENET-NODE-PORT --disable-rpc-login --wallet-dir PATH/TO/WALLET/DIR`
|
||||
3. Run the ASB in terminal: `./asb --testnet start`
|
||||
4. Follow the setup wizard in the terminal
|
||||
|
||||
Public Monero nodes for running the Monero Wallet RPC can be found [here](https://community.rino.io/nodes.html).
|
||||
|
||||
Run `./asb --help` for more information.
|
||||
|
||||
### Running on mainnet
|
||||
|
||||
For running the ASB on mainnet you will have to change you `monero-wallet-rpc` setup to mainnet.
|
||||
|
||||
It is recommended that you run your own Monero and Bitcoin node when running on mainnet.
|
||||
It is possible to plug into public blockchain nodes but be aware that you might lose some privacy doing so.
|
||||
Public Monero mainnet nodes can be found [here](https://moneroworld.com/#nodes).
|
||||
Public Electrum mainnet nodes can be found [here](https://1209k.com/bitcoin-eye/ele.php?chain=btc).
|
||||
|
||||
## ASB Details
|
||||
|
||||
The ASB is a long running daemon that acts as the trading partner to the swap CLI.
|
||||
The CLI user is buying XMR (i.e. receives XMR, sends BTC), the ASB service provider is selling XMR (i.e. sends XMR, receives BTC).
|
||||
The ASB can handle multiple swaps with different peers concurrently.
|
||||
The ASB communicates with the CLI on various [libp2p-based](https://libp2p.io/) network protocols.
|
||||
|
||||
Both the ASB and the CLI can be run by anybody.
|
||||
The CLI is designed to run one specific swap against an ASB.
|
||||
The ASB is designed to run 24/7 as a daemon that responds to CLIs connecting.
|
||||
Since the ASB is a long running task we specify the person running an ASB as service provider.
|
||||
|
||||
### ASB discovery
|
||||
|
||||
The ASB daemon supports the libp2p [rendezvous-protocol](https://github.com/libp2p/specs/tree/master/rendezvous).
|
||||
Usage of the rendezvous functionality is entirely optional.
|
||||
|
||||
You can configure one or more rendezvous points in the `[network]` section of your config file.
|
||||
For the registration to be successful, you also need to configure the externally reachable addresses within the `[network]` section.
|
||||
For example:
|
||||
|
||||
```toml
|
||||
[network]
|
||||
rendezvous_point = [
|
||||
"/dns4/discover.unstoppableswap.net/tcp/8888/p2p/12D3KooWA6cnqJpVnreBVnoro8midDL9Lpzmg8oJPoAGi7YYaamE",
|
||||
"/dns4/eratosthen.es/tcp/7798/p2p/12D3KooWAh7EXXa2ZyegzLGdjvj1W4G3EXrTGrf6trraoT1MEobs",
|
||||
]
|
||||
external_addresses = ["/dns4/example.com/tcp/9939"]
|
||||
```
|
||||
|
||||
For more information on the concept of multiaddresses, check out the libp2p documentation [here](https://docs.libp2p.io/concepts/addressing/).
|
||||
In particular, you may be interested in setting up your ASB to be reachable via a [`/dnsaddr`](https://github.com/multiformats/multiaddr/blob/master/protocols/DNSADDR.md) multiaddress.
|
||||
`/dnsaddr` addresses provide you with flexibility over the port and also allow you to register two addresses with transports (with and without websockets for example) under the same name.
|
||||
|
||||
### Setup Details
|
||||
|
||||
In order to understand the different components of the ASB and CLI better here is a component diagram showcasing the ASB and CLI setup using public Bitcoin and Monero infrastructure:
|
||||
|
||||

|
||||
|
||||
Contrary, here is a diagram that showcases a service provider running it's own blockchain infrastructure for the ASB:
|
||||
|
||||

|
||||
|
||||
The diagram shows that the `asb` group (representing the `asb` binary) consists of three components:
|
||||
|
||||
1. Monero Wallet
|
||||
2. Bitcoin Wallet
|
||||
3. ASB
|
||||
|
||||
The `ASB` depicted in the diagram actually consists of multiple components (protocol impl, network communication, ...) that sums up the functionality to execute concurrent swaps in the role of Alice.
|
||||
|
||||
#### Monero Wallet Setup
|
||||
|
||||
The ASB uses the running Monero wallet RPC to create / open Monero wallets.
|
||||
Currently you cannot connect to an existing Monero wallet, but the ASB will create the wallet `asb-wallet` upon intial startup.
|
||||
In order to accept trades with a CLI you will have to send XMR to that wallet.
|
||||
The wallet's address is printed upon startup of the ASB.
|
||||
Currently the `asb-wallet` does not have a password.
|
||||
|
||||
Upon startup of the ASB the `asb-wallet` is opened in the wallet RPC.
|
||||
You can then interact with the wallet RPC for basic wallet management as well.
|
||||
|
||||
#### Bitcoin Wallet Setup
|
||||
|
||||
The ASB has an internally managed Bitcoin wallet.
|
||||
The Bitcoin wallet is created upon initial startup and stored in the data folder of the ASB (configured through initial startup wizard).
|
||||
|
||||
#### Market Making
|
||||
|
||||
For market making the ASB offers the following parameters in the config:
|
||||
|
||||
```toml
|
||||
[maker]
|
||||
min_buy_btc = 0.0001
|
||||
max_buy_btc = 0.0001
|
||||
ask_spread = 0.02
|
||||
price_ticker_ws_url = "wss://ws.kraken.com"
|
||||
```
|
||||
|
||||
The minimum and maximum amount as well as a spread, that is added on top of the price fetched from a central exchange, can be configured.
|
||||
|
||||
In order to be able to trade, the ASB must define a price to be able to agree on the amounts to be swapped with a CLI.
|
||||
The `XMR<>BTC` price is currently determined by the price from the central exchange Kraken.
|
||||
Upon startup the ASB connects to the Kraken price websocket and listens on the stream for price updates.
|
||||
You can plug in a different price ticker websocket using the `price_ticker_ws_url` configuration option.
|
||||
You will have to make sure that the format returned is the same as the format used by Kraken.
|
||||
|
||||
Currently, we use a spot-price model, i.e. the ASB dictates the price to the CLI.
|
||||
A CLI can connect to the ASB at any time and request a quote for buying XMR.
|
||||
The ASB then returns the current price and the minimum and maximum amount tradeable.
|
||||
|
||||
#### Swap Execution
|
||||
|
||||
Swap execution within the ASB is automated.
|
||||
Incoming swaps request will be automatically processed, and the swap will execute automatically.
|
||||
Swaps where Bob does not act, so Alice cannot redeem, will be automatically refunded or punished.
|
||||
If the ASB is restarted unfinished swaps will be resumed automatically.
|
||||
|
||||
The refund scenario is a scenario where the CLI refunds the Bitcoin.
|
||||
The ASB can then refund the Monero which will be automatically transferred back to the `asb-wallet`.
|
||||
|
||||
The punish scenario is a scenario where the CLI does not refund and hence the ASB cannot refund the Monero.
|
||||
After a second timelock expires the ASB will automatically punish the CLI user by taking the Bitcoin.
|
||||
|
||||
More information about the protocol in this [presentation](https://youtu.be/Jj8rd4WOEy0) and this [blog post](https://comit.network/blog/2020/10/06/monero-bitcoin).
|
||||
|
||||
All claimed Bitcoin ends up in the internal Bitcoin wallet of the ASB.
|
||||
The ASB offers a commands to withdraw Bitcoin and check the balance, run `./asb --help` for details.
|
||||
|
||||
If the ASB has insufficient Monero funds to accept a swap the swap setup is rejected.
|
||||
Note that there is currently no notification service implemented for low funds.
|
||||
The ASB provider has to monitor Monero funds to make sure the ASB still has liquidity.
|
||||
|
||||
#### Tor and hidden services
|
||||
|
||||
The ASB supports Tor and will automatically create a Tor hidden service if the Tor control port can be found.
|
||||
By default, the ASB will look for the control port under `localhost:9051`.
|
||||
To allow the ASB to create a hidden service, enable the control port and authentication in your torrc file:
|
||||
|
||||
```
|
||||
ControlPort 9051
|
||||
CookieAuthentication 1
|
||||
CookieAuthFileGroupReadable 1
|
||||
```
|
||||
|
||||
It is important that the user running the ASB has the correct user rights, i.e. is in the same group as the user running Tor.
|
||||
E.g. if running on debian and having Tor install via apt, add your user to the following group:
|
||||
`sudo adduser $(whoami) debian-tor`.
|
||||
When configured correctly, your ASB will print the created onion addresses upon startup:
|
||||
|
||||
```bash
|
||||
./bin/asb start
|
||||
May 01 01:31:27.602 INFO Initialized tracing with level: debug
|
||||
...
|
||||
May 01 01:32:05.018 INFO Tor found. Setting up hidden service.
|
||||
May 01 01:32:07.475 INFO /onion3/z4findrdwtfbpoq64ayjtmxvr52vvxnsynerlenlfkmm52dqxsl4deyd:9939
|
||||
May 01 01:32:07.476 INFO /onion3/z4findrdwtfbpoq64ayjtmxvr52vvxnsynerlenlfkmm52dqxsl4deyd:9940
|
||||
```
|
||||
|
||||
### Exporting the Bitcoin wallet descriptor
|
||||
|
||||
First use `swap` or `asb` with the `export-bitcoin-wallet` subcommand.
|
||||
|
||||
Output example:
|
||||
|
||||
```json
|
||||
{
|
||||
"descriptor": "wpkh(tprv8Zgredacted.../84'/1'/0'/0/*)",
|
||||
"blockheight": 2415616,
|
||||
"label": "asb-testnet"
|
||||
}
|
||||
```
|
||||
|
||||
The wallet can theoretically be directly imported into
|
||||
[bdk-cli](https://bitcoindevkit.org/bdk-cli/installation/) but it is easier to
|
||||
use Sparrow Wallet.
|
||||
|
||||
Sparrow wallet import works as follows:
|
||||
|
||||
- File -> New wallet -> Give it a name
|
||||
- Select "New or Imported Software Wallet"
|
||||
- Click "Enter Private Key" for "Master Private Key (BIP32)"
|
||||
- Enter the `xprv...` or `tprv...` part of the descriptor (example above is `tprv8Zgredacted...`:
|
||||
|
||||

|
||||
|
||||
- Click "Import"
|
||||
- Leave the derivation path as `m/84'/0'/0'` and click "Import Keystore" button
|
||||
- Click "Apply" and then supply password
|
||||
|
||||

|
||||
|
||||
- Click Transactions tab
|
||||
- ???
|
||||
- Profit!
|
||||
|
||||

|
57
dev-docs/asb/diagrams/cli-asb-components-asb-pub-nodes.puml
Normal file
57
dev-docs/asb/diagrams/cli-asb-components-asb-pub-nodes.puml
Normal file
|
@ -0,0 +1,57 @@
|
|||
@startuml
|
||||
|
||||
package "User Host" {
|
||||
component [Monero Wallet RPC\n(auto installed)] as CliMonRpc
|
||||
() RPC as MonRpcCli
|
||||
component "swap" {
|
||||
component [CLI] as CLI
|
||||
component [Bitcoin Wallet] as CliBitWal
|
||||
}
|
||||
CliMonRpc - MonRpcCli
|
||||
CLI - CliBitWal
|
||||
MonRpcCli - CLI
|
||||
}
|
||||
|
||||
package "Public Monero Server" {
|
||||
component "monerod" as Monerod
|
||||
}
|
||||
|
||||
package "Public Bitcoin Server" {
|
||||
component "Electrum Server" as Electrum
|
||||
component "bitcoind" as Bitcoind
|
||||
() "RPC" as BitRPC
|
||||
BitRPC -- Electrum
|
||||
Electrum - Bitcoind
|
||||
}
|
||||
|
||||
package "Service Provider Host" {
|
||||
component [Monero Wallet RPC] as AsbMonRpc
|
||||
() RPC as MonRpcAsb
|
||||
component "asb" {
|
||||
component [ASB] as ASB
|
||||
component [Bitcoin Wallet] as AsbBitWal
|
||||
}
|
||||
AsbMonRpc - MonRpcAsb
|
||||
ASB - AsbBitWal
|
||||
MonRpcAsb - ASB
|
||||
}
|
||||
|
||||
package "Public Price Server" {
|
||||
component [CEX Price Ticker] as CEX
|
||||
() "websocket" as Ticker
|
||||
Ticker - CEX
|
||||
Ticker -- ASB
|
||||
}
|
||||
|
||||
CliBitWal -- BitRPC
|
||||
CliMonRpc -- Monerod
|
||||
|
||||
AsbMonRpc -- Monerod
|
||||
AsbBitWal -- BitRPC
|
||||
|
||||
() "libp2p" as Libp2p
|
||||
Libp2p -- CLI
|
||||
ASB -- Libp2p
|
||||
|
||||
footer XMR<>BTC swap CLI & ASB overview (public nodes)\nRendered with PlantUML version %version()
|
||||
@enduml
|
|
@ -0,0 +1,67 @@
|
|||
@startuml
|
||||
|
||||
package "User Host" {
|
||||
component [Monero Wallet RPC\n(auto installed)] as CliMonRpc
|
||||
() RPC as MonRpcCli
|
||||
component "swap" {
|
||||
component [CLI] as CLI
|
||||
component [Bitcoin Wallet] as CliBitWal
|
||||
}
|
||||
CliMonRpc - MonRpcCli
|
||||
CLI - CliBitWal
|
||||
MonRpcCli - CLI
|
||||
}
|
||||
|
||||
package "Public Monero Server" {
|
||||
component "monerod" as Monerod
|
||||
}
|
||||
|
||||
package "Public Bitcoin Server" {
|
||||
component "Electrum Server" as Electrum
|
||||
component "bitcoind" as Bitcoind
|
||||
() "RPC" as BitRPC
|
||||
BitRPC -- Electrum
|
||||
Electrum - Bitcoind
|
||||
}
|
||||
|
||||
package "Service Provider Host" {
|
||||
component [Monero Wallet RPC] as AsbMonRpc
|
||||
() RPC as MonRpcAsb
|
||||
component "asb" {
|
||||
component [ASB] as ASB
|
||||
component [Bitcoin Wallet] as AsbBitWal
|
||||
}
|
||||
AsbMonRpc - MonRpcAsb
|
||||
|
||||
component "monerod" as AsbMonerod
|
||||
component "Electrum Server" as AsbElectrum
|
||||
component "bitcoind" as AsbBitcoind
|
||||
|
||||
AsbMonRpc -- AsbMonerod
|
||||
|
||||
() "RPC" as AsbBitRPC
|
||||
|
||||
AsbBitWal -- AsbBitRPC
|
||||
AsbBitRPC -- AsbElectrum
|
||||
AsbElectrum - AsbBitcoind
|
||||
|
||||
ASB - AsbBitWal
|
||||
ASB -- MonRpcAsb
|
||||
}
|
||||
|
||||
package "Public Price Server" {
|
||||
component [CEX Price Ticker] as CEX
|
||||
() "websocket" as Ticker
|
||||
Ticker - CEX
|
||||
Ticker -- ASB
|
||||
}
|
||||
|
||||
CliBitWal -- BitRPC
|
||||
CliMonRpc -- Monerod
|
||||
|
||||
() "libp2p" as Libp2p
|
||||
Libp2p -- CLI
|
||||
ASB -- Libp2p
|
||||
|
||||
footer XMR<>BTC swap CLI & ASB overview\nRendered with PlantUML version %version()
|
||||
@enduml
|
34
dev-docs/asb/diagrams/cli-asb-overview.puml
Normal file
34
dev-docs/asb/diagrams/cli-asb-overview.puml
Normal file
|
@ -0,0 +1,34 @@
|
|||
@startuml
|
||||
|
||||
package "Service Provider 1" {
|
||||
|
||||
rectangle CLI as cli01
|
||||
rectangle CLI as cli02
|
||||
rectangle CLI as cli03
|
||||
|
||||
|
||||
rectangle ASB as asb01
|
||||
note right of asb01
|
||||
Service provider
|
||||
advertising to
|
||||
multiple users.
|
||||
end note
|
||||
|
||||
cli01 -> asb01
|
||||
cli02 --> asb01
|
||||
asb01 <-- cli03
|
||||
|
||||
}
|
||||
|
||||
package "Service Provider 2" {
|
||||
rectangle CLI as cli04
|
||||
rectangle ASB as asb02
|
||||
note right of asb02
|
||||
Service provider
|
||||
advertising to
|
||||
one single users.
|
||||
end note
|
||||
|
||||
cli04 -> asb02
|
||||
}
|
||||
@enduml
|
BIN
dev-docs/asb/enter-master-private-key.png
Normal file
BIN
dev-docs/asb/enter-master-private-key.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
BIN
dev-docs/asb/import-keystore.png
Normal file
BIN
dev-docs/asb/import-keystore.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 182 KiB |
BIN
dev-docs/asb/transactions-tab.png
Normal file
BIN
dev-docs/asb/transactions-tab.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 109 KiB |
141
dev-docs/cli/README.md
Normal file
141
dev-docs/cli/README.md
Normal file
|
@ -0,0 +1,141 @@
|
|||
# Swap CLI
|
||||
|
||||
The CLI defaults to **mainnet** (from version 0.6.0 onwards).
|
||||
For testing and to familiarise yourself with the tool, we recommend you to try it on testnet first.
|
||||
To do that, pass the `--testnet` flag with the actual command:
|
||||
|
||||
```shell
|
||||
swap --testnet <SUBCOMMAND>
|
||||
```
|
||||
|
||||
Take note that applying `--testnet` results in transacting on Bitcoin testnet and on Monero stagenet, not on Monero testnet.
|
||||
|
||||
The two main commands of the CLI are:
|
||||
|
||||
- `buy-xmr`: for swapping BTC to XMR with a particular seller
|
||||
- `list-sellers`: for discovering available sellers through a rendezvous point
|
||||
|
||||
Running `swap --help` gives us roughly the following output:
|
||||
|
||||
```
|
||||
swap 0.8.0
|
||||
The COMIT guys <hello@comit.network>
|
||||
CLI for swapping BTC for XMR
|
||||
|
||||
USAGE:
|
||||
swap [FLAGS] [OPTIONS] <SUBCOMMAND>
|
||||
|
||||
FLAGS:
|
||||
--debug Activate debug logging
|
||||
-h, --help Prints help information
|
||||
-j, --json Outputs all logs in JSON format instead of plain text
|
||||
--testnet Swap on testnet and assume testnet defaults for data-dir and the blockchain related parameters
|
||||
-V, --version Prints version information
|
||||
|
||||
OPTIONS:
|
||||
--data-base-dir <data> The base data directory to be used for mainnet / testnet specific data like database, wallets etc
|
||||
|
||||
SUBCOMMANDS:
|
||||
buy-xmr Start a BTC for XMR swap
|
||||
list-sellers Discover and list sellers (i.e. ASB providers)
|
||||
|
||||
cancel Try to cancel an ongoing swap (expert users only)
|
||||
help Prints this message or the help of the given subcommand(s)
|
||||
history Show a list of past, ongoing and completed swaps
|
||||
refund Try to cancel a swap and refund the BTC (expert users only)
|
||||
resume Resume a swap
|
||||
```
|
||||
|
||||
## Swapping BTC for XMR
|
||||
|
||||
Running `swap buy-xmr --help` gives us roughly the following output:
|
||||
|
||||
```
|
||||
swap-buy-xmr 0.8.0
|
||||
Start a BTC for XMR swap
|
||||
|
||||
USAGE:
|
||||
swap buy-xmr [FLAGS] [OPTIONS] --change-address <bitcoin-change-address> --receive-address <monero-receive-address> --seller <seller>
|
||||
|
||||
FLAGS:
|
||||
-h, --help Prints help information
|
||||
--testnet Swap on testnet and assume testnet defaults for data-dir and the blockchain related parameters
|
||||
-V, --version Prints version information
|
||||
|
||||
OPTIONS:
|
||||
--change-address <bitcoin-change-address> The bitcoin address where any form of change or excess funds should be sent to
|
||||
--receive-address <monero-receive-address> The monero address where you would like to receive monero
|
||||
--seller <seller> The seller's address. Must include a peer ID part, i.e. `/p2p/`
|
||||
|
||||
--electrum-rpc <bitcoin-electrum-rpc-url> Provide the Bitcoin Electrum RPC URL
|
||||
--bitcoin-target-block <bitcoin-target-block> Estimate Bitcoin fees such that transactions are confirmed within the specified number of blocks
|
||||
--monero-daemon-address <monero-daemon-address> Specify to connect to a monero daemon of your choice: <host>:<port>
|
||||
--tor-socks5-port <tor-socks5-port> Your local Tor socks5 proxy port [default: 9050]
|
||||
```
|
||||
|
||||
This command has three core options:
|
||||
|
||||
- `--change-address`: A Bitcoin address you control. Will be used for refunds of any kind. You can also omit this flag which will refund any change to the internal wallet.
|
||||
- `--receive-address`: A Monero address you control. This is where you will receive the Monero after the swap.
|
||||
- `--seller`: The multiaddress of the seller you want to swap with.
|
||||
|
||||
## Discovering sellers
|
||||
|
||||
Running `swap list-sellers --help` gives us roughly the following output:
|
||||
|
||||
```
|
||||
swap-list-sellers 0.8.0
|
||||
Discover and list sellers (i.e. ASB providers)
|
||||
|
||||
USAGE:
|
||||
swap list-sellers [FLAGS] [OPTIONS]
|
||||
|
||||
FLAGS:
|
||||
-h, --help Prints help information
|
||||
--testnet Swap on testnet and assume testnet defaults for data-dir and the blockchain related parameters
|
||||
-V, --version Prints version information
|
||||
|
||||
OPTIONS:
|
||||
--rendezvous-point <rendezvous-point> Address of the rendezvous point you want to use to discover ASBs
|
||||
--tor-socks5-port <tor-socks5-port> Your local Tor socks5 proxy port [default: 9050]
|
||||
```
|
||||
|
||||
Running `swap --testnet list-sellers --rendezvous-point /dns4/discover.unstoppableswap.net/tcp/8888/p2p/12D3KooWA6cnqJpVnreBVnoro8midDL9Lpzmg8oJPoAGi7YYaamE` will give you something like:
|
||||
|
||||
```
|
||||
Connected to rendezvous point, discovering nodes in 'xmr-btc-swap-testnet' namespace ...
|
||||
Discovered peer 12D3KooWPZ69DRp4wbGB3wJsxxsg1XW1EVZ2evtVwcARCF3a1nrx at /dns4/ac4hgzmsmekwekjbdl77brufqqbylddugzze4tel6qsnlympgmr46iid.onion/tcp/8765
|
||||
+----------------+----------------+----------------+--------+----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| PRICE | MIN_QUANTITY | MAX_QUANTITY | STATUS | ADDRESS |
|
||||
+====================================================================================================================================================================================================+
|
||||
| 0.00665754 BTC | 0.00010000 BTC | 0.00100000 BTC | Online | /dns4/ac4hgzmsmekwekjbdl77brufqqbylddugzze4tel6qsnlympgmr46iid.onion/tcp/8765/p2p/12D3KooWPZ69DRp4wbGB3wJsxxsg1XW1EVZ2evtVwcARCF3a1nrx |
|
||||
+----------------+----------------+----------------+--------+----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
```
|
||||
|
||||
or this if a node is not reachable:
|
||||
|
||||
```
|
||||
Connected to rendezvous point, discovering nodes in 'xmr-btc-swap-testnet' namespace ...
|
||||
Discovered peer 12D3KooWPZ69DRp4wbGB3wJsxxsg1XW1EVZ2evtVwcARCF3a1nrx at /dns4/ac4hgzmsmekwekjbdl77brufqqbylddugzze4tel6qsnlympgmr46iid.onion/tcp/8765
|
||||
+-------+--------------+--------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| PRICE | MIN_QUANTITY | MAX_QUANTITY | STATUS | ADDRESS |
|
||||
+============================================================================================================================================================================================+
|
||||
| ??? | ??? | ??? | Unreachable | /dns4/ac4hgzmsmekwekjbdl77brufqqbylddugzze4tel6qsnlympgmr46iid.onion/tcp/8765/p2p/12D3KooWPZ69DRp4wbGB3wJsxxsg1XW1EVZ2evtVwcARCF3a1nrx |
|
||||
+-------+--------------+--------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
```
|
||||
|
||||
## Automating discover and swapping
|
||||
|
||||
The `buy-xmr` and `list-sellers` command have been designed to be composed.
|
||||
[This script](./discover_and_take.sh) is example of what can be done.
|
||||
Deciding on the seller to use is non-trivial to automate which is why it is not implemented as part of the tool.
|
||||
|
||||
## Tor
|
||||
|
||||
By default, the CLI will look for Tor at the default socks port `9050` and automatically route all traffic with a seller through Tor.
|
||||
This allows swapping with sellers that are only reachable with an onion address.
|
||||
|
||||
Disclaimer:
|
||||
Communication with public blockchain explorers (Electrum, public XMR nodes) currently goes through clearnet.
|
||||
For complete anonymity it is recommended to run your own blockchain nodes.
|
||||
Use `swap buy-xmr --help` to see configuration options.
|
39
dev-docs/cli/discover_and_take.sh
Normal file
39
dev-docs/cli/discover_and_take.sh
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This is a utility script to showcase how the swap CLI can discover sellers and then trigger a swap using the discovered sellers
|
||||
#
|
||||
# 1st param: Path to the "swap" binary (aka the swap CLI)
|
||||
# 2nd param: Multiaddress of the rendezvous node to be used for discovery
|
||||
# 3rd param: Your Monero stagenet address where the XMR will be received
|
||||
# 4th param: Your bech32 Bitcoin testnet address that will be used for any change output (e.g. refund scenario or when swapping an amount smaller than the transferred BTC)
|
||||
#
|
||||
# Example usage:
|
||||
# discover_and_take.sh "PATH/TO/swap" "/dns4/discover.unstoppableswap.net/tcp/8888/p2p/12D3KooWA6cnqJpVnreBVnoro8midDL9Lpzmg8oJPoAGi7YYaamE" "YOUR_XMR_STAGENET_ADDRESS" "YOUR_BECH32_BITCOIN_TESTNET_ADDRESS"
|
||||
|
||||
CLI_PATH=$1
|
||||
RENDEZVOUS_POINT=$2
|
||||
YOUR_MONERO_ADDR=$3
|
||||
YOUR_BITCOIN_ADDR=$4
|
||||
|
||||
CLI_LIST_SELLERS="$CLI_PATH --testnet --json --debug list-sellers --rendezvous-point $RENDEZVOUS_POINT"
|
||||
echo "Requesting sellers with command: $CLI_LIST_SELLERS"
|
||||
echo
|
||||
|
||||
BEST_SELLER=$($CLI_LIST_SELLERS | jq -s -c 'min_by(.status .Online .price)' | jq -r '.multiaddr, (.status .Online .price), (.status .Online .min_quantity), (.status .Online .max_quantity)')
|
||||
read ADDR PRICE MIN MAX < <(echo $BEST_SELLER)
|
||||
|
||||
echo
|
||||
|
||||
echo "Seller with best price:"
|
||||
echo " multiaddr : $ADDR"
|
||||
echo " price : $PRICE sat"
|
||||
echo " min_quantity: $MIN sat"
|
||||
echo " max_quantity: $MAX sat"
|
||||
|
||||
echo
|
||||
|
||||
CLI_SWAP="$CLI_PATH --testnet --debug buy-xmr --receive-address $YOUR_MONERO_ADDR --change-address $YOUR_BITCOIN_ADDR --seller $ADDR"
|
||||
|
||||
echo "Starting swap with best seller using command $CLI_SWAP"
|
||||
echo
|
||||
$CLI_SWAP
|
Loading…
Add table
Add a link
Reference in a new issue