Skip to content
Decentralized, peer-to-peer, cross-chain swaps made easy.
Go Dockerfile Other
Branch: master
Clone or download
ChrisCates Fully functional gRPC API
Update Dockerfile

Update README
Latest commit daad3a3 Oct 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Full command line functionality Oct 21, 2019
bin Fully functional gRPC API Oct 21, 2019
dist Initial project scaffolding Sep 24, 2019
docker Fully functional gRPC API Oct 21, 2019
src Fully functional gRPC API Oct 21, 2019
test Full command line functionality Oct 21, 2019
.atomicswap.json
.gitignore gRPC Configuration and endpoints Oct 21, 2019
.gitkeep Initial project scaffolding Sep 24, 2019
.travis.yml Initial project scaffolding Sep 24, 2019
Dockerfile Fully functional gRPC API Oct 21, 2019
README.md Fully functional gRPC API Oct 21, 2019
glide.lock gRPC Configuration and endpoints Oct 21, 2019
glide.yaml gRPC Configuration and endpoints Oct 21, 2019
go.mod gRPC Configuration and endpoints Oct 21, 2019
go.sum Fully functional gRPC API Oct 21, 2019

README.md

Atomic Swaps

Go Version License Go Report Card GoDoc Build Status codecov

On chain atomic swaps for Divi, Bitcoin and other cryptocurrencies with gRPC support.

Based off of the original Atomic Swap implementation by Decred. Divi has created a production ready Atomic Swap implementation that is gRPC and HTTP enabled. This enables Atomic Swaps to be workable with mobile and web applications.

Compiling from source

Compilation and Installation

Without Docker

First install the dependencies

curl https://glide.sh/get | sh
glide install

And then compile the project

export GO111MODULE=auto
go build -i -o ./dist/atomicswap ./src/atomicswap.go

With Docker

docker build -t atomicswaps .
docker run atomicswaps
docker attach atomicswaps

Command line usage

A fast and easy way to do atomic swaps for Divi and Bitcoin. Learn more at https://github.com/DiviProject/atomic-swaps

Usage:
  atomicswap [flags]
  atomicswap [command]

Available Commands:
  audit       audit and validate an existing atomic swap contract
  extract     extract the secret for an atomic swap
  help        Help about any command
  initiate    initiate an atomic swap
  participate participate in an atomic swap
  redeem      redeem an atomic swap
  refund      refund an atomic swap
  version     print the version of atomicswap

Flags:
  -c, --config string         the path to the util.Configuration file (default ".atomicswap.json")
      --grpc-port int         the port of the gRPC server (raw tcp) (default 9999)
  -h, --help                  help for atomicswap
  -m, --mainnet               use the mainnet Configuration (default true)
  -r, --regtest               use the regtest Configuration
      --rpc-host string       the host of the wallet RPC server (default "localhost")
  -p, --rpc-password string   the password of the wallet RPC server (default "password")
      --rpc-port int          the port of the wallet RPC server (default 1337)
  -u, --rpc-user string       the user of the wallet RPC server (default "user")
  -s, --server                run as a gRPC server
      --server-port int       the port of the HTTP server (default 9001)
  -t, --testnet               use the testnet Configuration

Use "atomicswap [command] --help" for more information about a command.

Atomic Swap environment files

By default the binary will reference ./.atomicswap.json as an environment file.

You can also define a configuration file with a flag

atomicswap --conf .atomicswap.json

Below is a sample definition of an atomic swap configuration

{
    "rpc-host": "localhost",
    "rpc-port": 1337,
    "rpc-user": "divi",
    "rpc-password": "divi",
    "base-currency": "divi",
    "swap-currency": "bitcoin",
    "mainnet": true,
    "testnet": false,
    "regtest": false,
    "server": false,
    "server-port": 9001,
    "grpc-port": 9999
}

HTTP usage

Run as a HTTP gRPC server

atomicswap --serverport 9001

You can now run JSON RPC HTTP requests to the server. Please refer to API.md to learn how to interact with the RPC HTTP API.

Testing

Running go test will cover unit tests for the project.

In order to test both command line and http functionality. You'll need Node.js.

cd test
yarn # or npm install

# Test HTTP Queries
export SERVER_URL='http://localhost:9001'
yarn test-http

# Test CLI Queries
export BINARY_PATH='../dist/atomicswap'
yarn test-cli

Keep in mind in order to run each respective testing suite. You'll need to specify where the HTTP port is running or where the CLI binary is located.

Issues and Pull Requests

Issues and pull requests are open on this repository. Please try to follow the guidelines specified in .github.

You can’t perform that action at this time.