This guide is intended to help developers who want to contribute to xud. Developers who want to build on top of xud, should check out the API Documentation.
Be sure to read the Contribution Guidelines for the repository before starting to work or opening a Pull Request.
The following development environments are known to be compatible with xud and are recommended for developers that are unsure what tools to use.
Visual Studio Code is a cross-platform code editor that's compatible with most popular programming languages and extensible via a large collection of plug-ins.
Consider using the following plugins for working with xud.
- TSLint
- vscode-proto3
- Bracket Pair Colorizer (definitely optional)
Adding the two files from this gist into a .vscode folder within the folder where you've cloned xud will automatically provide debug configurations and general settings that are helpful when developing xud.
Auto restart on every file change under dist folder with nodemon:
nodemon --watch dist -e js bin/xud
With some sample args disabling lndbtc/lndltc:
nodemon --watch dist -e js bin/xud --lndbtc.disable=true --lndltc.disable=true
We recommend to connect the xud instance you are developing on with the xud-simnet. Combined with above restarting mechanism, this lets you instantly see how your changes behave in a real-world trading environment.
- Create the following directory and config file to expose relevant ports for your
xudto connect to:
xud@ubuntu:~$ mkdir -p ~/.xud-docker/simnet/
xud@ubuntu:~$ nano ~/.xud-docker/simnet/simnet.conf
# add these lines to set LNDBTC and LNDLTC to use the Neutrino light client
[lndbtc]
expose-ports = ["30009:10009"]
[lndltc]
expose-ports = ["31009:10009"]
[connext]
expose-ports = ["25040:5040"]
# CTRL+S, CTRL+X.- Start the
xud-simnetwith default settings as described here. - Once
xud-simnetis up and running, exit from the openedxud ctlsession by typingexitor open a second terminal. - Stop the xud container with
docker stop simnet_xud_1. - Copy the simnet lndbtc & lndltc folders into some path that you can easily access. E.g. into your home directory:
sudo cp -R ~/.xud-docker/simnet/data/lndbtc ~/
sudo cp -R ~/.xud-docker/simnet/data/lndltc ~/
- Ensure that you own the copied folders:
sudo chown -R <youruser> ~/lndbtc
sudo chown -R <youruser> ~/lndltc
- Create/change
xud.confin~/.xudto contain the following:
[lnd.BTC]
cltvdelta = 40
disable = false
host = "localhost"
nomacaroons = false
port = 30009
certpath = "/home/<youruser>/lndbtc/tls.cert"
macaroonpath = "/home/<youruser>/lndbtc/data/chain/bitcoin/simnet/admin.macaroon"
[lnd.LTC]
cltvdelta = 576
disable = false
host = "localhost"
nomacaroons = false
port = 31009
certpath = "/home/<youruser>/lndltc/tls.cert"
macaroonpath = "/home/<youruser>/lndltc/data/chain/litecoin/simnet/admin.macaroon"
[connext]
disable = false
host = "localhost"
port = 25040- Now you can start your local
xudinstance and it should connect to the runningxud-simnetdocker environment. You can check that everything works with~/xud/bin$ ./xucli -p 28886 getinfo. Ready to test your changes onxud-simnet!