The taker is the party that initiates the coinswap. It queries the directory server for a list of makers, requests offers from them and selects suitable makers for the swap. It then conducts the swap with the selected makers.
In this tutorial, we will guide you through the process of setting up and running the taker, and conducting a coinswap.
The taker CLI is an application that allows you to perform coinswaps as a taker.
Taker
requires a Bitcoin Core RPC connection running on testnet4 for its operation. To get started, you need to start bitcoind
:
Important:
All apps are designed to run on testnet4 for testing purposes. The DNS server that Taker connects to will also be on testnet4. While you can run these apps on other networks, there won't be any DNS available, so Taker won’t be able to connect to the DNS server fir getting maker's offers and can't do coinswap with makers.
To start bitcoind
:
$ bitcoind
Note: If you don’t have bitcoind
installed or need help setting it up, refer to the bitcoind demo documentation.
Run the taker
command to see the list of available commands and options.
$ ./taker --help
coinswap 0.1.0
Developers at Citadel-Tech
A simple command line app to operate as coinswap client
USAGE:
taker [OPTIONS] <SUBCOMMAND>
OPTIONS:
-a, --USER:PASSWORD <USER:PASSWORD>
Bitcoin Core RPC authentication string. Ex: username:password [default: user:password]
-d, --data-directory <DATA_DIRECTORY>
Optional data directory. Default value : "~/.coinswap/taker"
-h, --help
Print help information
-r, --ADDRESS:PORT <ADDRESS:PORT>
Bitcoin Core RPC address:port value [default: 127.0.0.1:18443]
-v, --verbosity <VERBOSITY>
Sets the verbosity level of debug.log file [default: info] [possible values: off, error,
warn, info, debug, trace]
-V, --version
Print version information
-w, --WALLET <WALLET>
Sets the taker wallet's name. If the wallet file already exists, it will load that
wallet. Default: taker-wallet
SUBCOMMANDS:
do-coinswap Initiate the coinswap process
fetch-offers Update the offerbook with current market offers and display them
get-balance Get the total spendable wallet balance (sats)
get-balance-contract Get the total amount stuck in HTLC contracts (sats)
get-balance-swap Get the total balance received from swaps (sats)
get-new-address Returns a new address
help Print this message or the help of the given subcommand(s)
list-utxo Lists all currently spendable utxos
list-utxo-contract Lists all HTLC utxos (if any)
list-utxo-swap Lists all utxos received in incoming swaps
send-to-address Send to an external wallet address
In order to do a coinswap, we first need to get some coins in our wallet. Let's generate a new address and send some coins to it.
$ taker -r 127.0.0.1:38332 -a user:pass get-new-address
bcrt1qyywgd4we5y7u05lnrgs8runc3j7sspwqhekrdd
Now we can use a testnet4 faucet to send some coins to this address. You can find a testnet4 faucet here.
Once you have some coins in your wallet, you can check your balance by running the following command:
$ taker -r 127.0.0.1:38332 -a user:pass get-balance
10000000 SAT
Now we are ready to initate a coinswap. We are first going to sync the offer book to get a list of available makers.
$ taker -r 127.0.0.1:38332 -a user:pass fetch-offers
This will fetch the list of available makers from the directory server. Now we can initiate a coinswap with the makers.
$ taker -r 127.0.0.1:38332 -a user:pass coinswap
This will initiate a coinswap with the default parameters. This will take some time. You can check swap progress at the log file in data diectory. In an new terminal do tail -f <datadir>/debug.log
.
The taker stores all its data in a data directory. By default, the data directory is located at $HOME/.coinswap/taker
. You can change the data directory by passing the --data-directory
option to the taker
command.
The data directory contains the following files:
config.toml
- The configuration file for the taker.debug.log
- The log file for the taker.wallets
directory - Contains the wallet files for the taker.
The configuration is stored in the config.toml
file. You can edit this file to change the configuration of the taker. The configuration file contains the following fields:
port
- The port via which the Taker listens and serves requests.socks_port
- The port via which the Taker listens and serves requests for the Socks5 proxy.rpc_port
- The port which serves the RPC server.directory_server_address
- The address of the directory server.connection_type
- The connection type to use for the directory server. Possible values areCLEARNET
andTOR
.
The taker uses wallet files to store the wallet data. The wallet files are stored in the wallets
directory. These wallet files should be safely backed up as they contain the private keys to the wallet.