Full Bitcoin library for iOS, implemented on Swift. SPV wallet implementation for Bitcoin, Bitcoin Cash and Dash blockchains.

Overview

BitcoinKit-iOS

Bitcoin, BitcoinCash(ABC) and Dash wallet toolkit for Swift. This is a full implementation of SPV node including wallet creation/restore, synchronization with network, send/receive transactions, and more. The repository includes the main BitcoinCore.swift and BitcoinKit.swift, BitcoinCashKit.swift and DashKit.swift separate pods.

Features

  • Full SPV implementation for fast mobile performance
  • Send/Receive Legacy transactions (P2PKH, P2PK, P2SH)
  • BIP32 hierarchical deterministic wallets implementation.
  • BIP39 mnemonic code for generating deterministic keys.
  • BIP44 multi-account hierarchy for deterministic wallets.
  • BIP21 URI schemes, which include payment address, amount, label and other params

BitcoinKit.swift

  • Send/Receive Segwit transactions (P2WPKH)
  • Send/Receive Segwit transactions compatible with legacy wallets (P2WPKH-SH)
  • base58, bech32

BitcoinCashKit.swift

  • bech32 cashaddr addresses

DashKit.swift

  • Instant send
  • LLMQ lock, Masternodes validation

Usage

On this page, we'll use Kits to refer to one of BitcoinKit.swift, BitcoinCashKit.swift and DashKit.swift kits.

Initialization

Kits requires you to provide mnemonic phrase when it is initialized:

let words = ["word1", ... , "word12"]

Bitcoin

let bitcoinKit = BitcoinKit(withWords: words, walletId: "bitcoin-wallet-id", syncMode: .api, networkType: .mainNet)

Bitcoin Cash

let bitcoinCashKit = BitcoinCashKit(withWords: words, walletId: "bitcoin-cash-wallet-id", syncMode: .api, networkType: .mainNet)

Dash

let dashKit = DashKit(withWords: words, walletId: "dash-wallet-id", syncMode: .api, networkType: .mainNet)

All 3 Kits can be configured to work in .mainNet or .testNet.

syncMode parameter

Kits can restore existing wallet or create a new one. When restoring, it generates addresses for given wallet according to bip44 protocol, then it pulls all historical transactions for each of those addresses. This is done only once on initial sync. syncMode parameter defines where it pulls historical transactions from. When they are pulled, it continues to sync according to SPV protocol no matter which syncMode was used for initial sync. There are 3 modes available:

  • .full: Fully synchronizes from peer-to-peer network starting from the block when bip44 was introduced. This mode is the most private (since it fully complies with SPV protocol), but it takes approximately 2 hours to sync upto now (June 10, 2019).
  • .api: Transactions before checkpoint are pulled from API(currently Insight API or BcoinAPI). Then the rest is synchronized from peer-to-peer network. This is the fastest one, but it's possible for an attacker to learn which addresses you own. Checkpoints are updated with each new release and hardcoded so the blocks validation is not broken.
  • .newWallet: No need to pull transactions.
Additional parameters:
  • confirmationsThreshold: Minimum number of confirmations required for an unspent output in incoming transaction to be spent (default: 6)
  • minLogLevel: Can be configured for debug purposes if required.

Starting and Stopping

Kits require to be started with start command. It will be in synced state as long as it is possible. You can call stop to stop it

bitcoinKit.start()
bitcoinKit.stop()

Getting wallet data

Kits hold all kinds of data obtained from and needed for working with blockchain network

Current Balance

Balance is provided in Satoshi:

bitcoinKit.balance

// 2937096768

Last Block Info

Last block info contains headerHash, height and timestamp that can be used for displaying sync info to user:

bitcoinKit.lastBlockInfo 

// ▿ Optional<BlockInfo>
//  ▿ some : BlockInfo
//    - headerHash : //"00000000000041ae2164b486398415cca902a41214cad72291ee04b212bed4c4"
//    - height : 1446751
//    ▿ timestamp : Optional<Int>
//      - some : 1544097931

Receive Address

Get an address which you can receive coins to. Receive address is changed each time after you actually get a transaction in which you receive coins to that address

bitcoinKit.receiveAddress

// "mgv1KTzGZby57K5EngZVaPdPtphPmEWjiS"

Transactions

Kits have transactions(fromHash: nil, limit: nil) methods which return Single<TransactionInfo>(for BitcoinKit and BitcoinCashKit) and Single<DashTransactionInfo>(for DashKit) RX Single Observers.

TransactionInfo:

//   ▿ TransactionInfo
//     - transactionHash : "0f83c9b330f936dc4a2458b7d3bb06dce6647a521bf6d98f9c9d3cdd5f6d2a73"
//     - transactionIndex : 500000
//     ▿ from : 2 elements
//       ▿ 0 : TransactionAddressInfo
//         - address : "mft8jpnf3XwwqhaYSYMSXePFN85mGU4oBd"
//         - mine : true
//       ▿ 1 : TransactionAddressInfo
//         - address : "mnNS5LEQDnYC2xqT12MnQmcuSvhfpem8gt"
//         - mine : true
//     ▿ to : 2 elements
//       ▿ 0 : TransactionAddressInfo
//         - address : "n43efNftHQ1cXYMZK4Dc53wgR6XgzZHGjs"
//         - mine : false
//       ▿ 1 : TransactionAddressInfo
//         - address : "mrjQyzbX9SiJxRC2mQhT4LvxFEmt9KEeRY"
//         - mine : true
//     - amount : -800378
//     ▿ blockHeight : Optional<Int>
//       - some : 1446602
//    ▿ timestamp : Optional<Int>
//       - some : 1543995972

DashTransactionInfo:

//   ▿ DashTransactionInfo
//     - transactionHash : "0f83c9b330f936dc4a2458b7d3bb06dce6647a521bf6d98f9c9d3cdd5f6d2a73"
//     - transactionIndex : 500000
//     - instantTx : true
//     ▿ from : 2 elements
//       ▿ 0 : TransactionAddressInfo
//         - address : "mft8jpnf3XwwqhaYSYMSXePFN85mGU4oBd"
//         - mine : true
//       ▿ 1 : TransactionAddressInfo
//         - address : "mnNS5LEQDnYC2xqT12MnQmcuSvhfpem8gt"
//         - mine : true
//     ▿ to : 2 elements
//       ▿ 0 : TransactionAddressInfo
//         - address : "n43efNftHQ1cXYMZK4Dc53wgR6XgzZHGjs"
//         - mine : false
//       ▿ 1 : TransactionAddressInfo
//         - address : "mrjQyzbX9SiJxRC2mQhT4LvxFEmt9KEeRY"
//         - mine : true
//     - amount : -800378
//     ▿ blockHeight : Optional<Int>
//       - some : 1446602
//    ▿ timestamp : Optional<Int>
//       - some : 1543995972

Creating new transaction

In order to create new transaction, call send(to: String, value: Int, feeRate: Int) method on Kits

try bitcoinKit.send(to: "mrjQyzbX9SiJxRC2mQhT4LvxFEmt9KEeRY", value: 1000000, feeRate: 10000)

This first validates a given address and amount, creates new transaction, then sends it over the peers network. If there's any error with given address/amount or network, it raises an exception.

Validating transaction before send

One can validate address and fee by using following methods:

try bitcoinKit.validate(address: "mrjQyzbX9SiJxRC2mQhT4LvxFEmt9KEeRY")
try bitcoinKit.fee(for: 1000000, toAddress: "mrjQyzbX9SiJxRC2mQhT4LvxFEmt9KEeRY", senderPay: true, feeRate: 10000)

senderPay parameter defines who pays the fee

Parsing BIP21 URI

You can use parse method to parse a BIP21 URI:

bitcoinKit.parse(paymentAddress: "bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=50&label=Luke-Jr&message=Donation%20for%20project%20xyz")

// ▿ BitcoinPaymentData
//   - address : "175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"
//   - version : nil
//   ▿ amount : Optional<Double>
//     - some : 50.0
//   ▿ label : Optional<String>
//     - some : "Luke-Jr"
//   ▿ message : Optional<String>
//     - some : "Donation for project xyz"
//   - parameters : nil

Subscribing to BitcoinKit data

Kits provide with data like transactions, blocks, balance, kits state in real-time. BitcoinCoreDelegate protocol must be implemented and set to Kits instance to receive that data.

class Manager {

	init(words: [String]) {
		bitcoinKit = BitcoinKit(withWords: words, walletId: "bitcoin-wallet-id")
        bitcoinKit.delegate = self
    }

}

extension Manager: BitcoinCoreDelegate {

    func transactionsUpdated(inserted: [TransactionInfo], updated: [TransactionInfo]) {
    }

    func transactionsDeleted(hashes: [String]) {
    }

    func balanceUpdated(balance: Int) {
    }

    func lastBlockInfoUpdated(lastBlockInfo: BlockInfo) {
    }

    public func kitStateUpdated(state: BitcoinCore.KitState) {
		// BitcoinCore.KitState can be one of 3 following states:
		// .synced
		// .syncing(progress: Double)
		// .notSynced
		// 
		// These states can be used to implement progress bar, etc
    }
    
}

Listener events are run in a dedicated background thread. It can be switched to main thread by setting the delegateQueue property to DispatchQueue.main

bitcoinKit.delegateQueue = DispatchQueue.main

Prerequisites

  • Xcode 10.0+
  • Swift 5+
  • iOS 11+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ 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:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
  pod 'BitcoinCore.swift'
  pod 'BitcoinKit.swift'
  pod 'BitcoinCashKit.swift'
  pod 'DashKit.swift'
end

Then, run the following command:

$ 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.

Dependencies

Dash dependencies

License

The BitcoinKit-iOS toolkit is open source and available under the terms of the MIT License.

Comments
  • API Usage, low level access

    API Usage, low level access

    Hi! I am looking into this library for a project that I am working on and I have two questions.

    First of all... I was looking at the example and I noticed that the library is making calls to http://btc-testnet.horizontalsystems.xyz/apg. Can somebody tell me why and if it is possible to easily remove these calls? If not at least give me some details on what is returned so we can maybe replace it with our own backend.

    The second one is more complicated. Our client is developing a hardware wallet and for us to successfully implement support for that we need to get access to the low level transaction data that we can then send to the device for signature. My question is - how hard would it be to modify this library so it could be initialized without mnemonics/seed (so in "read only" mode) and modify it to get access to the raw transaction data so that the hardware device can provide the signature instead? And of course any tips on where I should look to do this.

    opened by r00li 12
  • Please publish the latest version to CocoaPods, because current one doesn't work with XCode11

    Please publish the latest version to CocoaPods, because current one doesn't work with XCode11

    Bug: When creating or importing wallet on a build created in XCode 11.1 for iOS 13, there is an internal error.

    Logs are:

    2019-10-22 20:29:59.754208+0700 Runner[23362:1875929] *** Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'reversedHeaderHashHex' does not exist on object 'Block''
    *** First throw call stack:
    (
    	0   CoreFoundation                      0x00007fff23baa1ee __exceptionPreprocess + 350
    	1   libobjc.A.dylib                     0x00007fff50864b20 objc_exception_throw + 48
    	2   Realm                               0x000000010d4d7433 +[RLMObjectSchema schemaForObjectClass:] + 4371
    	3   Realm                               0x000000010d5e3d9e _ZL16RLMRegisterClassP10objc_class + 302
    	4   Realm                               0x000000010d5e4807 +[RLMSchema sharedSchemaForClass:] + 119
    	5   Realm                               0x000000010d4cf623 +[RLMObjectBase sharedSchema] + 67
    	6   Realm                               0x000000010d4cce3b _ZL33maybeInitObjectSchemaForUnmanagedP13RLMObjectBase + 123
    	7   Realm                               0x000000010d4ccd5d -[RLMObjectBase init] + 125
    	8   RealmSwift                          0x000000010ea8f061 $s10RealmSwift6ObjectCACycfc + 65
    	9   RealmSwift                          0x000000010ea8f0f3 $s10RealmSwift6ObjectCACycfcTo + 19
    	10  HSBitcoinKit                        0x000000010cd87c94 $s12HSBitcoinKit5BlockCACycfc + 916
    	11  HSBitcoinKit                        0x000000010cd87d43 $s12HSBitcoinKit5BlockCACycfcTo + 19
    	12  HSBitcoinKit                        0x000000010cd872bb $s12HSBitcoinKit5BlockC10withHeaderAcA0cE0CSg_tc33_F6AB7670EFC3EF947452E2B35A3BBCA6LlfC + 155
    	13  HSBitcoinKit                        0x000000010cd87607 $s12HSBitcoinKit5BlockC10withHeader6heightAcA0cE0C_SitcfC + 87
    	14  HSBitcoinKit                        0x000000010cd848c0 $s12HSBitcoinKit14BitcoinTestNetC16validatorFactoryAcA015IBlockValidatorG0_p_tcfc + 800
    	15  HSBitcoinKit                        0x000000010cd8453f $s12HSBitcoinKit14BitcoinTestNetC16validatorFactoryAcA015IBlockValidatorG0_p_tcfC + 63
    	16  HSBitcoinKit                        0x000000010cd767ea $s12HSBitcoinKit07BitcoinB0C9withWords4coin8walletId9newWallet22confirmationsThreshold11minLogLevelACSaySSG_AC4CoinOSSSbSiAA6LoggerC0O0Otcfc + 2522
    	17  HSBitcoinKit                        0x000000010cd75dad $s12HSBitcoinKit07BitcoinB0C9withWords4coin8walletId9newWallet22confirmationsThreshold11minLogLevelACSaySSG_AC4CoinOSSSbSiAA6LoggerC0O0OtcfC + 141
    	18  bitcoin_wallet                      0x000000010f096d59 $s14bitcoin_wallet24SwiftBitcoinWalletPluginC06importE033_567BEF0ED0D1A5D26F8F5D89B0099DFALL5words8testMode0B2IdySaySSG_SbSStF + 329
    	19  bitcoin_wallet                      0x000000010f09887f $s14bitcoin_wallet24SwiftBitcoinWalletPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctF + 5487
    	20  bitcoin_wallet                      0x000000010f09c73b $s14bitcoin_wallet24SwiftBitcoinWalletPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctFTo + 139
    	21  Flutter                             0x000000010ad314fd __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104
    	22  Flutter                             0x000000010accaec0 _ZNK7flutter21PlatformMessageRouter21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 166
    	23  Flutter                             0x000000010acce780 _ZN7flutter15PlatformViewIOS21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 38
    	24  Flutter                             0x000000010ad2bdb3 _ZNSt3__110__function6__funcIZN7flutter5Shell29OnEngineHandlePlatformMessageEN3fml6RefPtrINS2_15PlatformMessageEEEE4$_31NS_9allocatorIS8_EEFvvEEclEv + 57
    	25  Flutter                             0x000000010acdd3f1 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 123
    	26  Flutter                             0x000000010ace2742 _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26
    	27  CoreFoundation                      0x00007fff23b0d994 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    	28  CoreFoundation                      0x00007fff23b0d682 __CFRunLoopDoTimer + 1026
    	29  CoreFoundation                      0x00007fff23b0ccda __CFRunLoopDoTimers + 266
    	30  CoreFoundation                      0x00007fff23b07a4e __CFRunLoopRun + 2238
    	31  CoreFoundation                      0x00007fff23b06e66 CFRunLoopRunSpecific + 438
    	32  GraphicsServices                    0x00007fff38346bb0 GSEventRunModal + 65
    	33  UIKitCore                           0x00007fff47578dd0 UIApplicationMain + 1621
    	34  Runner                              0x000000010a49b0c8 main + 72
    	35  libdyld.dylib                       0x00007fff516ecd29 start + 1
    	36  ???                                 0x0000000000000001 0x0 + 1
    )
    libc++abi.dylib: terminating with uncaught exception of type NSException
    (lldb) 
    

    main point

    Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'reversedHeaderHashHex' does not exist on object 'Block''
    

    Reason: The reason is that Realm old versions don’t work with XCode 11 well.

    Our dependencies list are

    - Alamofire (4.8.2)
    - BigInt (3.1.0):
      - SipHash (~> 1.2)
    - bitcoin_wallet (0.0.1):
      - Flutter
      - HSBitcoinKit
    - Flutter (1.0.0)
    - HSBitcoinKit (0.4.1):
      - Alamofire (~> 4.8.0)
      - BigInt (~> 3.1.0)
      - HSCryptoKit (~> 1.1.0)
      - HSHDWalletKit (~> 1.0.3)
      - ObjectMapper (~> 3.3.0)
      - RealmSwift (~> 3.11.0)
      - RxRealm (~> 0.7.0)
      - RxSwift (~> 4.0)
    - HSCryptoKit (1.1.0)
    - HSHDWalletKit (1.0.3):
      - HSCryptoKit (~> 1.1.0)
    - ObjectMapper (3.3.0)
    - Realm (3.11.2):               <--- PROBLEM
      - Realm/Headers (= 3.11.2)
    - Realm/Headers (3.11.2)
    - RealmSwift (3.11.2):
      - Realm (= 3.11.2)
    - RxRealm (0.7.6):
      - RealmSwift (~> 3.0)
      - RxSwift (~> 4.0)
    - RxSwift (4.5.0)
    - SipHash (1.2.2)
    

    We can see that HSBitcoinKit depends on Realm with wrong version.

    Right Realm version which supports XCode 11 is about 3.18+ (as said here https://github.com/realm/realm-cocoa/issues/6163)

    I checked HSBitcoinKitrepository and didn’t found any Realm dependencies. After some research, I found that it was there but was deleted here https://github.com/horizontalsystems/bitcoin-kit-ios/commit/65a13b21dff97b767c229489ea48639a773d5247#diff-691ea2c5e475d83f07d8cf1313fe74ec, and the fresh version of HSBitcoinKit doesn’t have Realm dependency at all.

    This is strange because we have the latest version of HSBitcoinKit installed. Turns out that version in their repository (0.8.0) differs from the version on CocoaPods (0.4.1.).

    You guys didn’t upload the last version to the pods!
    Could you please do it?

    Thanks a lot!

    opened by airon-tark 3
  • Long syncing issues

    Long syncing issues

    Hi! I was wondering if it is okay that the syncing progress takes long now? it used to be way shorter 2 days ago, did something change? also, it seems when you're trying to send a transaction now, it keeps failing due to it is always getting blocks over and over, until it stabilizes for a little bit and you can send it then it goes back to fetching blocks, which is also something that wasn't happening that constantly 2 days ago, just little observations I've noticed since the last time I've been using the library, I've been pretty much studying the library by looking through your demo project but it also takes longer to sync now and to send transactions it's a little unstable since it always keeps fetching blocks sometimes on your demo project too

    opened by CryoCodex 3
  • M1 arm64 errors and more

    M1 arm64 errors and more

    Hi. Thank you for your work, this is a great project and it will be more than useful if I can implement this to my project. i am having a lot of stupid errors while trying to start the project. I am currently on M1 Pro chip, with Xcode 13.3. I keep getting a lot of errors. And when I fix those, new ones appear. I got other types of errors on an other git NFT Eth project too, I think it has to do something about my MacBook 2021 16inch. I am leaving an image of one of the many errors I get. And I do not use the simulator, I am aware of the arm64 thing. Screenshot 2022-03-28 at 01 34 20 if you have in hand a Mac with m1 chip can you verify that there are no problems with the project and you can download the zip, pod install, and start the app? thank you.

    opened by 13adahan 2
  • Cannot send Bitcoin in TestNet

    Cannot send Bitcoin in TestNet

    Hi

    I cannot send Bitcoin in TestNet

    let transaction = try kit.send(to: wallet, value: 1000, feeRate: 70, sortType: .none) I receive BitcoinCoreErrors.SendValueErrors.singleNoChangeOutputNotFound

    the balance: 0.0005 BTC

    BitcoinKit: 0.15.4 Xcode Version: 13.2 Swift Version: 13.0

    opened by alexj70 2
  • BTC test net incorrect balance

    BTC test net incorrect balance

    Am using BitcoinKit 0.17 in test net. I've sent 0.00083 tBTC to my wallet (https://blockstream.info/testnet/tx/b95235c6c2224f987f2cbb40cf04ba934ba4b2eac3ef42a890f8e2a3c4ca4087). After receiving the tx balance was correct, my receive address changed, but after 3 days all of a sudden my receive address reverted to a previously used for the incoming tx and frameworks shows a wrong balance of the wallet (0). Also TransactionRecord of the incoming tx doesn't recognise the tx output as mine anymore (output.mine is false). BitcoinKit syncing with peers without any noticeable issues. Is there a way to reset kit state, so it's recognise the tx output as mine and got the correct balance? Any suggestions are welcome.

    opened by cuhte3 2
  • Checkpoint caculation

    Checkpoint caculation

    @esen @mNizhurin @ant013 Hi, Awesome @horizontalsystems team! I wanna add some altcoins here. But I wonder how can I define checkpoint files for them. Could you have a chance to tell me?

    opened by proactive-dev 2
  • Balance not fetched after syncing via API

    Balance not fetched after syncing via API

    When loading a wallet from an existing seed, after API syncing, the balance is not recovered (displayed as 0).

    Tested on:

    • network: Testnet
    • coin: BTC
    • address type: Bech32 (.bip84)
    opened by cybercent 2
  • Questions about BIP44

    Questions about BIP44

    Hello! I was wondering if you are able to have multiple accounts in the HDWallet BIP44 implementation (perhaps this question may sound dumb as I'm not 100% sure how things work)

    root -> BIP44 -> coinType 0 -> account 0 -> chain 0 -> then N addresses here

    That'd be to store bitcoin in account 0 right? is it possible to then derivate to account 1 in a way that

    root -> BIP44 -> coinType 0 -> account 1 -> chain 0 -> again N addresses here

    in the library so you would have 2 bitcoin accounts in the HDWallet? is there a way to just get the balances and transactions of account 0, then of account 1 individually I don't know if the question is being asked properly or if is not the way BIP44 is supposed to be intended just wondering if I wanted to have 2 bitcoin wallets I'd have to create another 12 word list mnemonic right? or there is a way to have 2 bitcoin wallets in the same HDWallet? Thanks in advance and I'm sorry if the question wasn't being asked properly, I've been learning a lot about crypto development thanks to all of you. Kudos and have a great day/night!

    opened by CryoCodex 2
  • BTC: initial syncer fails to sync in TEST NET

    BTC: initial syncer fails to sync in TEST NET

    First of all I'd like to thank for your brilliant work on the library! <3

    Am having an issue syncing a new wallet in TEST NET. InitialSyncer return an error on single.subscribe:

    invalidResponse(statusCode: 404, data: Optional({
        error =     {
            message = "Not found.";
        };
    }))
    
    18:40:41.173 ❤️ ERROR  apiSync: invalidResponse(statusCode: 404, data: Optional({
        error =     {
            message = "Not found.";
        };
    }))
    

    Previously created wallets syncing with peers just fine as well as syncing new wallet on MAIN NET. Currently as a workaround I comment out initial syncer and syncing a new wallet with peers, however syncing takes significant more time. Any advices how to sync a new wallet in TEST NET?

    Am using BitcoinCore and BitcoinKit ver 0.17. The issue started no more than couple of weeks ago, previously initial syncer worked without issues.

    Thanks!

    opened by cuhte3 1
  • How to get private key in string value

    How to get private key in string value

    let mnemonic = Mnemonic.seed(mnemonic: words)

    do {
        let bitcoinKit = try BitcoinKit(withWords: words, bip: .bip44, walletId: "bitcoin-wallet-id", syncMode: .api, networkType: .testNet)
        
        print("address", bitcoinKit.receiveAddress())
        //bitcoinKit.start()
        bitcoinData = bitcoinKit
        
        let wallet = HDWallet(seed: mnemonic, coinType: .zero, xPrivKey: .init(), xPubKey: .init())
        let path = "m/44'/1'/0'/0"
        let privateKey = try wallet.privateKey(path: path)
        
        let testKey = try wallet.privateKey(account: .zero, index: .zero, chain: .external)
        print("myPrivateKey1", testKey.raw.base64EncodedString())
        
        let publicKey = try bitcoinKit.receivePublicKey()
        print("publicKey", publicKey)
        
        
    } catch (let err) {
        print("err occ", err)
    }
    

    }

    duplicate 
    opened by rachkumar 1
  • Issues with connecting to Testnet via API

    Issues with connecting to Testnet via API

    Hello, im facing Issues with with connecting to Testnet via Alamofire.

    Error:

    ERROR : API IN: POST https://btc-testnet.horizontalsystems.xyz/api/tx/address
    noResponse(reason: Optional("Session was invalidated without error, so it was likely deinitialized unexpectedly. Be sure to retain a reference to your Session for the duration of your requests."))
    

    Code:

        func checkbalance(){
            
            print("CheckBalance start");
            
            let bitcoinKit: BitcoinKit
        
            let words = [Safety wise]
        
            bitcoinKit = try! BitcoinKit(withWords: words, bip: .bip44, walletId: "bitcoin-wallet-id", syncMode: .api, networkType: .testNet, logger: .none)
    
        
            bitcoinKit.start()
            
            
            print(bitcoinKit.receiveAddress())
            
            print(bitcoinKit.balance)
            
            print(bitcoinKit.statusInfo)
            
            try? bitcoinKit.send(to: "mrjQyzbX9SiJxRC2mQhT4LvxFEmt9KEeRY", value: 1000, feeRate: 10000, sortType: .none)
            
            
            print("BTC session completed!")
            
            
            bitcoinKit.stop()
        
        }
    

    Thanks for Help!

    opened by SurpriseMF3000 2
  • Unknown Address on random transactions.

    Unknown Address on random transactions.

    Does anyone have an idea why this transaction would return Unknown address for the from address.

    I've seeing this behaviour before while running on testnet, and assumed it was related to that. But now I'm seeing this happening on mainnet.

    https://live.blockcypher.com/btc/address/bc1qf0w93ddyuc8l2hc3ls9myxuxqqht375szse502/

    opened by LF4ce 1
  • Dash synchronisation stuck in an infinite loop

    Dash synchronisation stuck in an infinite loop

    I have a Dash wallet that stops the synchronisation when it arrives to this transaction

    https://blockchair.com/es/dash/transaction/3cc6e81dbb258a6fb88fb46e35b0a8e6e6c77fd4699d4a8100b9c700a5a7b3de

    This transaction comes from Dash masternode, and it has a coinbase input, I believe that DashKit doesn't support this type of inputs and it gets stuck in an infinite loop.

    https://dashcore.readme.io/docs/core-ref-transactions-raw-transaction-format#coinbase-input-the-input-of-the-first-transaction-in-a-block

    bug 
    opened by fpcornelis 6
  • URLSessionTask failed with error for syncMode = .api

    URLSessionTask failed with error for syncMode = .api

    Good day

    kit = try BitcoinCashKit( withWords: words, walletId: "bitcoin-cash-wallet-id", syncMode: .api, networkType: networkType, confirmationsThreshold: 1, logger: .init(minLogLevel: .error) )

    in func kitStateUpdated(state: BitcoinCore.KitState) I receive the error

    URLSessionTask failed with error: A server with the specified hostname could not be found.

    opened by alexj70 0
Releases(bitcoin-core-0.13.2)
  • bitcoin-core-0.13.2(Jan 7, 2020)

  • 0.6(Jun 12, 2019)

    Use Swift 5

    • Respectively use GRDB 4, RxSwift 5, etc

    Add LLMQ support to Dash

    • Full support of instant transactions
    • Support protocol version >= 70214

    Full sync optimizations

    • Peer selection optimizations
    • Ability to define sync mode: ** API (historical transactions from API, sync from peers network starting from last checkpoint) ** Full sync (starting from bip44 approval) ** New wallet (from last checkpoint)

    Use P2WPKH(SH) address for receive by default

    Source code(tar.gz)
    Source code(zip)
  • 0.5(May 9, 2019)

    Separate project to sub projects:

    • BitcoinCore is the core project
    • BitcoinKit uses BitcoinCore, only for Bitcoin blockchain
    • BitcoinCashKit uses BitcoinCore, only for Bitcoin Cash blockchain
    • DashKit uses BitcoinCore, only for Dash blockchain

    Switch from Realm to GRDB

    • Extract DB usages to single Interface
    • Switch to GRDB storage

    Dash support

    • Handle Instant transactions
    • Send AutoInstant transactions if possible

    Lots of refactoring, optimizations and bugfixes

    Source code(tar.gz)
    Source code(zip)
  • 0.4.1(Feb 28, 2019)

  • 0.4(Feb 28, 2019)

    Customizable thread for delegate

    Listener events are run in a dedicated background thread. It can be switched to main thread by setting the delegateQueue property to DispatchQueue.main.

    Performance improvements

    • improve threading and transfer heavy tasks to background thread (#237, #244, #245)
    • restore performance improvement (#248, #254)
    • "Double spend risk" on sent transactions is fixed (#247)
    • bug fixes and improvements (#169, #221, #243, #249, #251, #258)
    Source code(tar.gz)
    Source code(zip)
  • 0.3(Feb 13, 2019)

    • transactions list can now be fetched using Rx Single and accepts fromHash and limit parameters (#234)
    • newWallet flag added to BitcoinKit constructor to avoid syncing from API for new wallet (#229)
    • walletId has been added to constructor and used for DB name for security reasons (#217)
    • proof of work verification has been fixed (#224)
    • minor bug fixes and performance improvements (#209, #215, #218, #225)
    Source code(tar.gz)
    Source code(zip)
Owner
Horizontal Systems
Good Ideas Should Be Unstoppable. Design Autonomous Systems That Can't Go Offline.
Horizontal Systems
BitcoinCore for Bitcoin, BitcoinCash(ABC), Litecoin and Dash wallet toolkit for Swift.

BitcoinCore for Bitcoin, BitcoinCash(ABC), Litecoin and Dash wallet toolkit for Swift. This is a full implementation of SPV node including wallet creation/restore, synchronization with network, send/receive transactions, and more.

Horizontal Systems 4 Nov 23, 2022
Bitcoin-price - Application to consult the current price of a Bitcoin in different currencies

bitcoin-price Aplicativo para consultar o preço atual de um Bitcoin em diversas

Bruno Lopes 0 Jan 9, 2022
Ethereum Wallet Toolkit for iOS - You can implement an Ethereum wallet without a server and blockchain knowledge.

Introduction EtherWalletKit is an Ethereum Wallet Toolkit for iOS. I hope cryptocurrency and decentralized token economy become more widely adapted. H

Sung Woo Chang 136 Dec 25, 2022
Fearless Wallet - a mobile wallet designed for the decentralized future on the Kusama and Polkadot networks

Fearless Wallet is a mobile wallet designed for the decentralized future on the Kusama and Polkadot network, with support on iOS and Android platforms. The best user experience, fast performance, and secure storage for your accounts. Development of Fearless Wallet is supported by Kusama Treasury grant.

ソラミツ 68 Dec 14, 2022
Ethereum-wallet: 100% native ethereum wallet, created with iOS version of Geth client

Ethereum-wallet: 100% native ethereum wallet, created with iOS version of Geth client

DE MINING 4 Dec 11, 2022
Wei Wallet - Ethereum wallet app for iOS

Wei Wallet - Ethereum wallet app for iOS Getting Started Download the latest Xcode Clone this repository Install Carthage, Cocoapods Run make bootstra

Popshoot, Inc. 277 Nov 17, 2022
Bitcoin protocol toolkit for Swift

Welcome to BitcoinKit The BitcoinKit library is a Swift implementation of the Bitcoin protocol which support both BCH and BTC. Improving the mobile ec

Yenom - The simplest Bitcoin wallet - 786 Dec 25, 2022
Trust - Ethereum Wallet and Web3 DApp Browser for iOS

Trust - Ethereum Wallet and Web3 DApp Browser for iOS Welcome to Trust's open source iOS app! Getting Started Download the Xcode 9 release. Clone this

Trust Wallet 1.4k Dec 31, 2022
A highly experimental, self-custody Lightning wallet built to work for iOS and macOS.

Surge Surge is a highly experimental, self-custody Lightning wallet built to work for iOS and macOS. Motivation Tools and infrastructure for running a

Jurvis Tan 2 Oct 26, 2022
AlphaWallet - Advanced, Open Source Ethereum Mobile Wallet & dApp Browser for iOS

AlphaWallet - Advanced, Open Source Ethereum Mobile Wallet & dApp Browser for iOS

AlphaWallet 475 Jan 5, 2023
Smart Wallet - iOS application for managing money

This is an iOS application for managing money written in Swift language. Different reports are presented in the application to help the user managing the money and keeping track of it easily.

Soheil Novinfard 53 Dec 26, 2022
IOTA wallet.rs Swift binding

IOTA wallet.rs Swift Binding Swift binding for the official wallet.rs Rust library for IOTA Ledger. The Swift binding links and communicates with the

Pasquale Ambrosini 5 Jun 13, 2022
Swift UI component - Stories instagram, slideshow, crypto wallet intro

SwiftUI and Combine - Stories intro multi-platform widget Features Long tap - pause stories showcase Tap - next story Leeway - pause before start stor

Igor 9 Dec 26, 2022
CryptoSwift - Crypto related functions and helpers for Swift implemented in Swift

CryptoSwift Crypto related functions and helpers for Swift implemented in Swift.

Kushal Shingote 2 Feb 6, 2022
SwiftUI Prototyping Wallet App Interactive UI

Wallet SwiftUI Prototyping Wallet App Interactive UI

Areg Vardanian 0 Dec 18, 2021
Cross-platform 👻 Crypto Wallet Generator in Go

coingrig-go-wallet Cross-platform ?? Crypto Wallet Generator in Go Build Run ./build.sh Artifacts iOS .xcframework is in ios/ directory Android .jar a

Coingrig 2 Feb 26, 2022
Rainbow - 🌈the Ethereum wallet that lives in your pocket

??️ the Ethereum wallet that lives in your pocket! ??️ Available on the iOS App Store. ?? Android Beta available on Google Play Store ??️ Foll

Rainbow 3.2k Jan 3, 2023
An open-source Ethereum wallet built with SwiftUI

lil wallet welcome to lil wallet. it's an open-source Ethereum wallet built with SwiftUI there are two main views - coins and objects. coins are your

Jordan Singer 140 Jan 3, 2023
Encryptr is a zero-knowledge, cloud-based e-wallet / password manager powered by Crypton

Encryptr is a zero-knowledge, cloud-based e-wallet / password manager powered by Crypton

SpiderOak, Inc. 1.6k Jan 4, 2023