Integrate a coin
What a blockchain needs before BasicSwap can support it, such as script support, timelocks and watch-only wallets, and how earlier coin integrations were built.
BasicSwap adds coins through open-source contributions, so anyone can write an integration and propose it as a pull request on GitHub. Once the maintainers merge and release it, every BasicSwap that updates can trade the coin. There's no template that fits every chain, though. Every integration has to fit the coin's own node software, wallet and transaction format, so it helps to know what BasicSwap needs before starting.
What a coin needs
The usual case is a UTXO coin whose node descends from Bitcoin Core. Such a coin can take part in secret-hash swaps, and with the right features in adaptor-signature swaps too, if it has:
- UTXO scripts, so a swap can lock coins under conditions.
- A timelock, either CheckLockTimeVerify (CLTV) or CheckSequenceVerify (CSV), so each side can get its coins back from a failed swap.
- Watch-only addresses, so BasicSwap can follow the other trader's lock transaction without holding its keys.
- A wallet that takes its seed from a key, so the coin's wallet comes from the user's one recovery phrase.
Segwit makes integration simpler, but it isn't required, and Dash, PIVX, Firo and Bitcoin Cash all run without it. Coins without scripts, such as Monero and Wownero, can still swap through adaptor signatures, as long as the other coin in the pair has scripts.
Supported coins
| Coin | Core version | Scripts | Segwit | Without a full node |
|---|---|---|---|---|
| Particl (PART) | 27.2.6.0 | Yes | Yes | — |
| Bitcoin (BTC) | 31.1 | Yes | Yes | Electrum |
| Litecoin (LTC) | 0.21.5.8 | Yes | Yes | Electrum |
| Monero (XMR) | 0.18.5.4 | No | — | Remote node |
| Wownero (WOW) | 0.11.3.0 | No | — | Remote node |
| Bitcoin Cash (BCH) | 29.1.0 | Yes | No | — |
| Dash (DASH) | 23.1.8 | Yes | No | — |
| Decred (DCR) | 2.1.7 | Yes | Yes | — |
| Dogecoin (DOGE) | 23.2.1 | Yes | No | — |
| Firo (FIRO) | 0.14.18.2 | Yes | No | — |
| Namecoin (NMC) | 28.0 | Yes | Yes | — |
| PIVX (PIVX) | 5.6.1 | Yes | No | — |
Versions from BasicSwap v0.19.1, read from the code when this page was built.
Earlier integrations
Reading the work behind a similar coin is the best way to start. Dash went in over three commits, the first, the second and the third, while PIVX arrived in a single commit. Decred, Wownero and Firo each have a branch of their own, decred, wow and firo, where you can follow the integration commit by commit.
Each coin's code lives in its own folder under basicswap/interface, with a core.py that downloads and sets up its node alongside a module for its wallet calls. The repository's doc/protocols folder describes the protocols themselves. Before writing code, ask in the BasicSwap Matrix room, where the maintainers can say whether a coin is likely to fit and what it would take.