This is the android library that allows Atomic Swap, decentralized crypto currency exchange, between 2 parties. The implementation based on Hash Time Locked Contracts.
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
.
There are 2 sides that take part in the process: Initiator and Responder. The process consists of the following steps:
Initiator creates swap request:
val swapRequest = swapKit.createSwapRequest(coinHave, coinWant, rate, amount)
Responder creates response for this request:
val swapResponse = swapKit.createSwapResponse(swapRequest)
Creating response also starts the swap process in the Responder side.
Initiator takes response and starts the swap
swapKit.initiateSwap(swapResponse)
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.
- JDK >= 1.8
- Android 6 (minSdkVersion 23) or greater
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'
}
All features of the library are used in example project. It can be referred as a starting point for usage of the library.
- Bitcoin Kit Android - Full SPV wallet toolkit implementation for Bitcoin, Bitcoin Cash and Dash blockchains
The Atomic Swap Kit
is open source and available under the terms of the MIT License