2022-06-02 13:17:59 +02:00
# Docker setup for running Jam in regtest mode
2021-12-10 15:29:46 +01:00
2022-01-23 14:45:34 +01:00
This setup will help you set up a regtest environment quickly.
2022-06-02 13:17:59 +02:00
It starts multiple JoinMarket containers, hence not only API calls but also actual CoinJoin transactions can be tested.
Communication between these containers is done via Tor (if internet connection is available) and IRC (locally running container).
2022-10-13 14:07:48 +02:00
All containers will have a wallet named `Satoshi.jmdat` with password `test` .
2022-09-09 17:25:52 +02:00
The second container has basic auth enabled (username `joinmarket` and password `joinmarket` ).
2022-06-02 13:17:59 +02:00
## Common flow
2025-06-20 01:19:54 +05:30
2022-06-02 13:17:59 +02:00
```sh
# (optional) once in a while rebuild the images
npm run regtest:rebuild
# start the regtest environment
npm run regtest:up
2022-10-13 14:07:48 +02:00
# fund wallets and start maker in secondary and tertiary container
2022-06-06 11:21:39 +02:00
npm run regtest:init
2022-06-02 13:17:59 +02:00
# mine blocks in regtest periodically
npm run regtest:mine
2022-06-06 11:21:39 +02:00
# start jam in development mode
2024-09-11 13:09:28 +02:00
npm run dev
2022-06-06 11:21:39 +02:00
2022-06-02 13:17:59 +02:00
[...]
# stop the regtest environment
npm run regtest:down
# (optional) wipe all test data and start from scratch next time
npm run regtest:clear
```
2021-12-10 15:29:46 +01:00
2022-01-22 17:09:14 +01:00
## Commands
2022-01-23 14:45:34 +01:00
2022-06-06 11:21:39 +02:00
### Start
2022-01-23 14:45:34 +01:00
2022-03-16 13:49:39 +01:00
Start the regtest environment with:
2021-12-10 15:29:46 +01:00
2022-01-23 14:45:34 +01:00
```sh
2022-03-16 13:49:39 +01:00
npm run regtest:up
2022-06-06 11:21:39 +02:00
2022-10-13 14:07:48 +02:00
# (optional) fund wallets and start maker in secondary and tertiary containers
2022-06-06 11:21:39 +02:00
npm run regtest:init
2021-12-10 15:29:46 +01:00
```
2022-04-27 10:14:40 +02:00
Once the regtest environment is up and running you can start Jam with:
```sh
2024-09-11 13:09:28 +02:00
npm run dev
2022-04-27 10:14:40 +02:00
```
2022-01-22 17:09:14 +01:00
### Stop
2022-01-23 14:45:34 +01:00
```sh
2022-03-16 13:49:39 +01:00
npm run regtest:down
2021-12-10 15:29:46 +01:00
```
2022-03-16 13:49:39 +01:00
If you want to start from scratch (removing all volumes):
2022-01-23 14:45:34 +01:00
```sh
2022-03-16 13:49:39 +01:00
npm run regtest:clear
2022-01-22 17:09:14 +01:00
```
2022-06-06 11:21:39 +02:00
### Mine
2025-06-20 01:19:54 +05:30
2023-02-08 13:44:49 +01:00
Mine regtest blocks in a fixed interval (current default is every 11 seconds).
2022-06-06 11:21:39 +02:00
This is useful for features that await confirmations or need incoming blocks regularly.
e.g. This is necessary for scheduled transactions to execute successfully.
2025-06-20 01:19:54 +05:30
2022-06-06 11:21:39 +02:00
```sh
npm run regtest:mine
```
2022-01-22 17:09:14 +01:00
## Images
2022-09-09 17:25:52 +02:00
The [Docker setup ](dockerfile-deps/joinmarket/latest/Dockerfile ) is an adaption of [jam-standalone ](https://github.com/joinmarket-webui/jam-docker/tree/master/standalone ) with as little adaptations as possible.
2022-01-23 14:45:34 +01:00
It will fetch the latest commit from the [`master` branch of the joinmarket-clientserver repo ](https://github.com/JoinMarket-Org/joinmarket-clientserver/tree/master ).
2022-02-21 14:39:59 +01:00
Keep in mind: Building from `master` is not always reliable. This tradeoff is made to enable testing new features immediately by just rebuilding the images.
2022-01-23 14:45:34 +01:00
2022-09-09 17:25:52 +02:00
The second JoinMarket container is based on `joinmarket-webui/jam-dev-standalone:master` which exposes an UI on port `29080`
2022-02-21 14:39:59 +01:00
(username `joinmarket` and pass `joinmarket` for Basic Authentication).
2022-10-13 14:07:48 +02:00
The third container is a copy of the second one exposed on port `30080` without authentication.
2022-01-22 17:09:14 +01:00
This is useful if you want to perform regression tests.
2022-10-13 14:07:48 +02:00
One additional JoinMarket container acts as [Directory Node ](https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/docs/onion-message-channels.md#directory ) and exists solely to enable communication between peers.
2022-06-02 13:17:59 +02:00
2022-09-09 17:25:52 +02:00
### Build
2025-06-20 01:19:54 +05:30
2022-09-09 17:25:52 +02:00
```sh
# building the images
npm run regtest:build
```
2022-01-23 14:45:34 +01:00
2022-09-09 17:25:52 +02:00
In order to incorporate recent upstream changes (of the `master` branch), simply rebuild the setup from scratch.
2022-01-22 17:09:14 +01:00
2022-01-23 14:45:34 +01:00
```sh
2022-09-09 17:25:52 +02:00
# download and recompile the images from scratch (without using docker cache)
2022-03-16 13:49:39 +01:00
npm run regtest:rebuild
2022-01-22 17:09:14 +01:00
```
## Debugging
2022-01-23 14:45:34 +01:00
2022-01-22 17:09:14 +01:00
### Debug logs
2022-01-23 14:45:34 +01:00
```sh
2022-09-09 17:25:52 +02:00
# logs and follows content of log file in primary joinmarket container
2022-03-16 13:49:39 +01:00
npm run regtest:logs:jmwalletd
2022-01-22 17:09:14 +01:00
```
### Display running JoinMarket version
2022-01-23 14:45:34 +01:00
```sh
2022-01-22 17:09:14 +01:00
docker exec -t jm_regtest_joinmarket git log --oneline -1
```
2021-12-15 10:53:16 +01:00
## Helper scripts
2022-01-22 17:09:14 +01:00
Some helper scripts are included to make recurring tasks and interaction with the containers easier.
2021-12-15 10:53:16 +01:00
2022-01-22 17:09:14 +01:00
### `init-setup.sh`
2022-01-23 14:45:34 +01:00
2022-10-13 14:07:48 +02:00
This script helps in providing JoinMarket containers a wallet with spendable coins and starting the Maker Service in the secondary and tertiary containers.
2022-01-22 17:09:14 +01:00
Its main goal is to make CoinJoin transactions possible in the regtest environment.
It should be run immediately after the Docker setup is successfully started so you can start developing right away.
2022-08-09 12:47:01 +02:00
A wallet named `Satoshi.jmdat` with password `test` will be created if it does not exist.
2021-12-15 10:53:16 +01:00
2022-01-23 14:45:34 +01:00
```sh
2022-10-13 14:07:48 +02:00
# fund wallets and start maker service in secondary and tertiary containers
2022-01-22 17:09:14 +01:00
[user@home regtest]$ ./init-setup.sh
2021-12-15 10:53:16 +01:00
```
2022-01-23 14:45:34 +01:00
```text
2022-01-22 17:09:14 +01:00
[...]
2022-08-09 12:47:01 +02:00
Attempt to start maker for wallet 'Satoshi.jmdat' in secondary container ..
2022-01-22 17:09:14 +01:00
[...]
2022-10-13 14:07:48 +02:00
Successfully started maker for wallet 'Satoshi.jmdat'.
[...]
Attempt to start maker for wallet 'Satoshi.jmdat' in tertiary container ..
[...]
Successfully started maker for wallet 'Satoshi.jmdat'.
2022-01-22 17:09:14 +01:00
[...]
```
### `mine-block.sh`
2022-01-23 14:45:34 +01:00
2022-01-22 17:09:14 +01:00
Mine one or more blocks to an optionally given address.
2022-01-23 14:45:34 +01:00
```sh
2022-01-22 17:09:14 +01:00
[user@home regtest]$ ./mine-block.sh
```
Usage: mine-block.sh [# of blocks] [address]
2022-01-23 14:45:34 +01:00
```sh
2022-01-22 17:09:14 +01:00
# mine a single block
[user@home regtest]$ ./mine-block.sh
2021-12-15 10:53:16 +01:00
2022-01-22 17:09:14 +01:00
# mine 21 blocks
[user@home regtest]$ ./mine-block.sh 21
2021-12-15 10:53:16 +01:00
2022-01-22 17:09:14 +01:00
# mine 42 blocks to given address
[user@home regtest]$ ./mine-block.sh 42 bcrt1qrnz0thqslhxu86th069r9j6y7ldkgs2tzgf5wx
```
This also comes in handy if you want to periodically mine blocks:
2022-01-23 14:45:34 +01:00
```sh
2022-01-22 17:09:14 +01:00
# mine a block every 5 seconds
[user@home regtest]$ watch -n 5 ./mine-block.sh
```
### `fund-wallet.sh`
2022-01-23 14:45:34 +01:00
2022-01-22 17:09:14 +01:00
Funding and/or creating a joinmarket regtest wallet.
See the help page for examples and more usage information:
2022-01-23 14:45:34 +01:00
```sh
2022-01-22 17:09:14 +01:00
[user@home regtest]$ ./fund-wallet.sh --help
2021-12-15 10:53:16 +01:00
```
#### Funding regtest wallet
2022-01-23 14:45:34 +01:00
2022-08-09 12:47:01 +02:00
Executed without parameters the script will create one _spendable_ coinbase output to a wallet named 'Satoshi.jmdat'.
2021-12-15 10:53:16 +01:00
If the wallet does not exist, it will be created. See the following output:
2022-01-23 14:45:34 +01:00
```sh
2022-01-22 17:09:14 +01:00
[user@home regtest]$ ./fund-wallet.sh
2021-12-15 10:53:16 +01:00
```
2022-01-23 14:45:34 +01:00
```text
2022-08-09 12:47:01 +02:00
Trying to fund wallet 'Satoshi.jmdat'..
2021-12-15 10:53:16 +01:00
[...]
Successfully generated 1 blocks with rewards to bcrt1qyz7wql00gghwk25er08re3dhtv66h20h8gtgsp
```
Control various parameters by passing options to the script.
2022-08-09 12:47:01 +02:00
e.g. "Mine 5 blocks to wallet `Satoshi.jmdat` with password `correctbatteryhorsestaple` in mixdepth 3"
2022-01-23 14:45:34 +01:00
```sh
2022-08-09 12:47:01 +02:00
[user@home regtest]$ ./fund-wallet.sh --blocks 5 --wallet-name Satoshi.jmdat --password correctbatteryhorsestaple --mixdepth 3
2021-12-15 10:53:16 +01:00
```
2022-01-23 14:45:34 +01:00
```text
2022-08-09 12:47:01 +02:00
Trying to fund wallet 'Satoshi.jmdat'..
2021-12-15 10:53:16 +01:00
Successfully established connection to jmwalletd
2022-08-09 12:47:01 +02:00
Wallet 'Satoshi.jmdat' does not exist - creating..
Successfully created wallet 'Satoshi.jmdat'.
2021-12-15 10:53:16 +01:00
Write down the seedphrase: abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
2022-08-09 12:47:01 +02:00
Fetching new funding address from wallet 'Satoshi.jmdat' in mixdepth 3
2021-12-15 10:53:16 +01:00
Successfully fetched new funding address bcrt1qs0aqmzxjq96jk8hhmta5jfn339dk4cme074lq3
2022-08-09 12:47:01 +02:00
Locking wallet 'Satoshi.jmdat'
Successfully locked wallet 'Satoshi.jmdat'.
2021-12-15 10:53:16 +01:00
Generating 5 blocks with rewards to bcrt1qs0aqmzxjq96jk8hhmta5jfn339dk4cme074lq3
Successfully generated 5 blocks with rewards to bcrt1qs0aqmzxjq96jk8hhmta5jfn339dk4cme074lq3
```
2022-01-23 14:45:34 +01:00
## Resources
2022-01-22 17:09:14 +01:00
2022-01-23 14:45:34 +01:00
- [JoinMarket Server (GitHub) ](https://github.com/JoinMarket-Org/joinmarket-clientserver )
- [JoinMarket Server Testing Docs (GitHub) ](https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/docs/TESTING.md )