Skip to content

Jaboxx/xud

 
 

Repository files navigation

Exchange Union

Gitter chat Build Status Codacy Badge

Exchange Union (XU) is a decentralized exchange layer built on the Lightning and Raiden networks to enable trustless and instant cryptocurrency swaps and order fulfillment between exchanges.

This repo contains the early stages of the Exchange Union Daemon ("xud") which encompasses the following components:

  • Integration with lnd and raiden nodes.
  • Orderbook data stored in a local mysql/mariadb database.
  • Peer-to-peer networking with other XU nodes via TCP.
  • A gRPC API with web proxy to serve other applications, also accessible by command-line interface.

Contributions, feedback, and questions are welcome.

Install

First, clone the repository from GitHub and install dependencies.

git clone https://github.com/ExchangeUnion/xud
cd xud
npm install

Xud uses MySQL or MariaDB. You will have to install one of those and create a user and database grant all permissions for the new database to the new user.

Configuration

An optional configuration file uses TOML and by default should be saved at ~/.xud/xud.conf on Linux or AppData\Local\Xud\xud.conf on Windows. Default settings which can be overridden are shown below.

[rpc]
port = 8886

[db]
username = "xud"
password = ""
database = "xud"
port = 3306
host = "localhost"

[p2p]
listen = true
port = 8885

[lnd]
disable = false
datadir = "~/.lnd"
host = "localhost"

[raiden]
disable = false
host = "localhost"
port = 5001

[orderbook]
internalmatching = true

Starting the Daemon

Launch a new xud process

~/xud $ cd bin
~/xud/bin $ ./xud
2018-6-3 15:14:27 [GLOBAL] info: config loaded
2018-6-3 15:14:27 [DB] info: connected to database. host:localhost port:3306 database:xud dialect:mysql
2018-6-3 15:14:28 [LND] info: LndClient status: CONNECTION_VERIFIED
2018-6-3 15:14:28 [P2P] info: pool server listening on 0.0.0.0:8885
2018-6-3 15:14:28 [RPC] info: GRPC server listening on port 8886

Optional command line arguments to override defaults and settings in the Configuration file for a specific xud instance

~/xud/bin $ ./xud --help
Options:
  --help                        Show help                              [boolean]
  --version                     Show version number                    [boolean]
  --xudir, -x                   Data directory for xud                  [string]
  --db.database                 SQL database name                       [string]
  --db.dialect                  SQL database dialect                    [string]
  --db.host                     Hostname for SQL database               [string]
  --db.port                     Port for SQL database                   [number]
  --db.username                 User for SQL database                   [string]
  --lnd.certpath                Path to the SSL certificate for lnd     [string]
  --lnd.datadir                 Data directory for lnd                  [string]
  --lnd.disable                 Disable lnd integration                [boolean]
  --lnd.host                    Host of the lnd gRPC interface          [string]
  --lnd.macaroonpath            Path of the admin macaroon for lnd      [string]
  --lnd.port                    Port of the lnd gRPC interface          [number]
  --orderbook.internalmatching  OrderBook Internal Matching            [boolean]
  --p2p.listen                  Listen for incoming peers              [boolean]
  --p2p.port, -p                Port to listen for incoming peers       [number]
  --raiden.disable              Disable raiden integration             [boolean]
  --raiden.port                 Port for raiden REST service            [number]
  --rpc.port, -r                RPC service port                        [number]
  --webproxy.disable            Disable web proxy server               [boolean]
  --webproxy.port               Port for web proxy server               [number]

Command-Line Interface

Interact with an xud process, identified by its rpc host and port

~/xud/bin $ ./xucli --help
xucli [command]

Commands:
  xucli connect <host> [port]               connect to an xu node
  xucli getinfo                             get general info from the xud node
  xucli getorders [pair_id] [max_results]   get orders from the orderbook
  xucli getpairs                            get orderbook's available pairs
  xucli placeorder <pair_id> <price>        place an order
  <quantity>
  xucli shutdown                            gracefully shutdown the xud node
  xucli tokenswap <identifier> <role>       perform a raiden token swap
  <sending_amount> <sending_token>
  <receiving_amount> <receiving_token>

Options:
  --help          Show help                                            [boolean]
  --version       Show version number                                  [boolean]
  --rpc.port, -p  The RPC service port                  [number] [default: 8886]
  --rpc.host, -h  The RPC service hostname       [string] [default: "localhost"]

Database Initialization

To initialize the database with default testing data, run the following command:

npm run db:init

Documentation

Read the TypeDoc here.

About

Exchange Union Daemon - Connecting Cryptocurrency Exchanges

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 90.5%
  • TypeScript 9.1%
  • Shell 0.4%