Functioning, minimal-viable binaries and libraries to perform a trustless, p2p Maxwell-Belcher Coinswap Protocol.
[!WARNING] This library is currently under beta development and at an experimental stage. There are known and unknown bugs. Mainnet use is strictly NOT recommended.
CoinSwap is a rust implementation of a variant of atomic-swap protocol, using HTLCs on Bitcoin. Read more at:
The repo contains a fully automated integration testing framework on Bitcoin Regtest. The bitcoin binary used for testing is included here.
[!TIP] Delete the bitcoind binary to reduce repo size, if you don't intend to run the integration tests.
The integration tests are the best way to look at a working demonstration of the coinswap protocol, involving multiple makers, a taker and the directory server. All working over Tor by default. No pre-requisite setup is needed, other than rust and cargo.
Run all the integration tests by running:
$ cargo test --features=integration-test -- --nocapture
Each test in the tests folder covers a different edge-case situation and demonstrates how the taker and makers recover from various types of swap failures.
keep an eye on the logs, that's where all the actions are happening.
Play through a single test case, for example, standard_swap
, by running:
$ cargo test --features=integration-test --tests test_standard_coinswap -- --nocapture
The individual test names can be found in the test files.
For in-depth developer documentation on the coinswap protocol and implementation, consult the dev book.
The project is divided into distinct modules, each focused on specific functionalities.
docs/
src/
├─ bin/
├─ maker/
├─ market/
├─ protocol/
├─ taker/
tests/
Directory | Description |
---|---|
doc |
Contains all the project-related docs. The dev-book includes major developer salient points. |
src/taker |
Taker module houses its core logic in src/taker/api.rs and handles both Taker-related behaviors and most of the protocol-related logic. |
src/maker |
Encompasses Maker-specific logic and plays a relatively passive role compared to Taker. |
src/wallet |
Manages wallet-related operations, including storage and blockchain interaction. |
src/market |
Handles market-related logic, where Makers post their offers. |
src/protocol |
Contains utility functions, error handling, and messages for protocol communication. |
tests |
Contains integration tests. Describes behavior of various abort/malice cases. |
[!IMPORTANT] The project currently only compiles in Linux. Mac/Windows is not supported. To compile in Mac/Windows use virtual machines
bitcoind
backend.ContractSigsForRecvrAndSender
. Does not broadcasts the funding txs. Taker and Other Maker recovers. Maker gets banned.ContractSigsForRecvr
after broadcasting funding txs. Taker and other Makers recover. Maker gets banned.HashPreimage
message and doesn't respond back with privkeys. Taker and other Maker recovers. Maker gets banned.Directory Server
. Tor must. This will act as the MVP DNS server.maker
cli app, that spawns the server in the background, and exposes a basic maker wallet API.taker
cli app. This also has basic taker wallet API + do_coinswap()
which spawns a swap process in the background.swap_dns_server
as a stand-alone directory server binary.demo.md
doc to demonstrate a swap process with maker
and taker
and swap_dns_server
in Signet.The project is under active development by a few motivated Rusty Bitcoin devs. Any contribution for features, tests, docs and other fixes/upgrades is encouraged and welcomed. The maintainers will use the PR thread to provide quick reviews and suggestions and are generally proactive at merging good contributions.
Few directions for new contributors:
The list of issues is a good place to look for contributable tasks and open problems.
Issues marked with good first issue
are good places to get started for newbie Rust/Bitcoin devs.
The docs are a good place to start reading up on the protocol.
Reviewing open PRs are a good place to start gathering a contextual understanding of the codebase.
Search for TODO
s in the codebase to find in-line marked code todos and smaller improvements.
The repo contains pre-commit githooks to do auto-linting before commits. Set up the pre-commit hook by running:
ln -s ../../git_hooks/pre-commit .git/hooks/pre-commit
The dev community lurks in a Discord here.
Dev discussions predominantly happen via FOSS best practices, and by using Github as the Community Forum.
The Issues, PRs and Discussions are where all the hard lifting happening.