Skip to content
Atomic Swap Android library for Bitcoin (BTC) and Bitcoin Cash (BCH) swaps in decentralized manner. Implemented on Kotlin.
Kotlin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
atomicswapbitcoin
atomicswapcore
gradle/wrapper
.gitignore
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Overview

This is the android library that allows Atomic Swap, decentralized crypto currency exchange, between 2 parties. The implementation based on Hash Time Locked Contracts.

Usage

Initialization

The primary class to use is SwapKit.

val swapKit = SwapKit(context)

swapKit.registerSwapBlockchainCreator("BTC", BitcoinSwapBlockchainCreator(bitcoinKit))
swapKit.registerSwapBlockchainCreator("BCH", BitcoinSwapBlockchainCreator(bitcoinCashKit))

It takes context as constructor parameter. The supported coins should be registered to SwapKit.

Exchanging crypto-curencies

There are 2 sides that take part in the process: Initiator and Responder. The process consists of the following steps:

Request for a swap

Initiator creates swap request:

val swapRequest = swapKit.createSwapRequest(coinHave, coinWant, rate, amount)

Response to a swap

Responder creates response for this request:

val swapResponse = swapKit.createSwapResponse(swapRequest)

Creating response also starts the swap process in the Responder side.

Initiate swap

Initiator takes response and starts the swap

swapKit.initiateSwap(swapResponse)

Initiator and Responder Communication

The Swap Request and Swap Response are the simple data objects. They can be easily serialized into/parsed from strings and interchanged via standard apps, like messenger or email.

Prerequisites

  • JDK >= 1.8
  • Android 6 (minSdkVersion 23) or greater

Installation

Add the JitPack to module build.gradle

repositories {
    maven { url 'https://jitpack.io' }
}

Add the following dependency to your build.gradle file:

dependencies {
    implementation 'com.github.horizontalsystems:atomic-swap-kit-android:master-SNAPSHOT'
}

Example App

All features of the library are used in example project. It can be referred as a starting point for usage of the library.

Dependencies

  • Bitcoin Kit Android - Full SPV wallet toolkit implementation for Bitcoin, Bitcoin Cash and Dash blockchains

License

The Atomic Swap Kit is open source and available under the terms of the MIT License

You can’t perform that action at this time.