atomic-swap-kit-ios
所属分类:加密货币
开发工具:Swift
文件大小:539KB
下载次数:0
上传日期:2022-07-22 03:36:05
上 传 者:
sh-1993
说明: Atomic Swap iOS库用于以去中心化方式进行的比特币(BTC)和比特币现金(BCH)交换。在Swift上执行。
(Atomic Swap iOS library for Bitcoin (BTC) and Bitcoin Cash (BCH) swaps in decentralized manner. Implemented on Swift.)
文件列表:
.DS_Store (6148, 2019-07-24)
AtomicSwapBitcoinProvider.swift.podspec (1449, 2019-07-24)
AtomicSwapBitcoinProvider (0, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider.xcodeproj (0, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider.xcodeproj\project.pbxproj (17752, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider (0, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider.h (441, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider\Info.plist (726, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider\Provider (0, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider\Provider\BitcoinBailTransaction.swift (471, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider\Provider\BitcoinRedeemTransaction.swift (313, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider\Provider\BitcoinSwapBlockchain.swift (6734, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider\Provider\BitcoinSwapBlockchainCreator.swift (533, 2019-07-24)
AtomicSwapBitcoinProvider\AtomicSwapBitcoinProvider\Provider\SwapScriptBuilder.swift (1375, 2019-07-24)
AtomicSwapCore.swift.podspec (1159, 2019-07-24)
AtomicSwapCore (0, 2019-07-24)
AtomicSwapCore\AtomicSwapCore.xcodeproj (0, 2019-07-24)
AtomicSwapCore\AtomicSwapCore.xcodeproj\project.pbxproj (32298, 2019-07-24)
AtomicSwapCore\AtomicSwapCore (0, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\AtomicSwapCore.h (386, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core (0, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\Protocols.swift (2708, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\PublicKey.swift (215, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\Swap.swift (4880, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\SwapFactory.swift (5416, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\SwapInitiator.swift (468, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\SwapInitiatorDoer.swift (3397, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\SwapKit.swift (3488, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\SwapResponder.swift (545, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\SwapResponderDoer.swift (3977, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Core\SwapStorage.swift (2982, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Helpers (0, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Helpers\RandomHelper.swift (590, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Info.plist (726, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Logger.swift (5393, 2019-07-24)
AtomicSwapCore\AtomicSwapCore\Messages.swift (2066, 2019-07-24)
AtomicSwapCore\AtomicSwapCoreTests (0, 2019-07-24)
AtomicSwapCore\AtomicSwapCoreTests\Core (0, 2019-07-24)
... ...
## Overview
This is a swift library that allows Atomic Swap, decentralized crypto currency exchange, between 2 parties. The implementation is based on Hash Time Locked Contracts.
## Usage
### Initialization
The primary class to use is `SwapKit`.
```swift
import BitcoinKit
import BitcoinCashKit
import AtomicSwapKit
let swapKit = SwapKit.instance()
swapKit.register(blockchainCreator: BitcoinSwapBlockchainCreator(kit: bitcoinAdapter.bitcoinKit), forCoin: "BTC")
swapKit.register(blockchainCreator: BitcoinSwapBlockchainCreator(kit: bitcoinCashAdapter.bitcoinCashKit), forCoin: "BCH")
swapKit.load()
```
The supported coins should be registered to `SwapKit`. The `load` method resumes atomic swaps previously in progress.
### 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:
```swift
let swapRequest = try swapKit.createSwapRequest(haveCoinCode: "BTC", wantCoinCode: "BCH", rate: 0.2, amount: 0.5)
```
#### Response to a swap
Responder creates response for this request:
```swift
let swapResponse = swapKit.createSwapResponse(from: swapRequest)
```
Creating response also starts the swap process in the Responder side.
#### Initiate swap
Initiator takes response and starts the swap
```swift
swapKit.initiateSwap(from: 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
* Xcode 10.0+
* Swift 5+
* iOS 11+
## Installation
### CocoaPods
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
```bash
$ gem install cocoapods
```
> CocoaPods 1.5.0+ is required to build BitcoinKit.
To integrate BitcoinKit into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!
target '' do
pod 'AtomicSwapCore.swift'
pod 'AtomicSwapBitcoinProvider'
end
```
Then, run the following command:
```bash
$ pod install
```
## Example Project
All features of the library are used in example project. It can be referred as a starting point for usage of the library.
* [Example Project](https://github.com/horizontalsystems/atomic-swap-kit-ios/tree/master/Demo)
## Dependencies
* [HSHDWalletKit](https://github.com/horizontalsystems/hd-wallet-kit-ios) - HD Wallet related features, mnemonic phrase geneartion.
* [HSCryptoKit](https://github.com/horizontalsystems/crypto-kit-ios) - Crypto functions required for working with blockchain.
## License
The `AtomicSwapKit-iOS` toolkit is open source and available under the terms of the [MIT License](https://github.com/horizontalsystems/atomic-swap-kit-ios/blob/master/LICENSE).
近期下载者:
相关文件:
收藏者: