Awesome Bitcoin toolkit for ObjC and Swift
C Objective-C C++ Swift Other
Latest commit de3a6d8 Jan 31, 2016 @oleganza Merge pull request #78 from votosocial/select_scanner_camera
Enable camera selection (back or front) on BTCQRCode
Permalink
Failed to load latest commit information.
CoreBitcoin.xcodeproj Merge pull request #75 from amacneil/bitcode Jan 15, 2016
CoreBitcoin renamed to a neater API name as suggested Jan 30, 2016
CoreBitcoinIOS copyrights update Feb 23, 2014
CoreBitcoinIOSlib iOS framework and static library, changed build directory Nov 14, 2013
CoreBitcoinOSX copyrights update Feb 23, 2014
CoreBitcoinOSXlib static library for OSX Nov 15, 2013
CoreBitcoinTestsOSX Changed format of some tests that the crash compiler so they don't cr… Dec 8, 2015
UnitTests BTCCurrencyConverter average calculation fix and unit testing May 4, 2015
openssl/include/openssl removed old binaries and generated files Nov 19, 2013
.gitignore Ignore openssl.bak May 16, 2015
CoreBitcoin.podspec bumped v to 0.6.8.1 to make cocoapods pusher happy Jan 16, 2016
GLOSSARY.md link to new location of the glossary Mar 3, 2015
INSTALLATION.txt frameworks with the same name Dec 4, 2013
LICENSE.txt updated license info in a minor way Nov 5, 2014
MEME_GLOSSARY.md more memes Oct 21, 2014
README.md link to arcbit homepage rather then app store Jul 19, 2015
ReleaseNotes.md various links and references to new features Mar 30, 2015
ScriptStringRepresentation.md wip on script parsing Sep 25, 2013
build_libraries.sh header processing in frameworks Feb 23, 2014
openssl-1.0.1e.tar.gz fixes to openssl bundling Nov 27, 2013
postprocess_openssl_includes_in_framework.rb header processing in frameworks Feb 23, 2014
update_headers.rb added BTC256 for holding hashes in fixed-length buffers Mar 15, 2014
update_openssl.sh Use xcode command line tools to get developer path and SKD versions Mar 17, 2015

README.md

CoreBitcoin

CoreBitcoin implements Bitcoin protocol in Objective-C and provides many additional APIs to make great apps.

CoreBitcoin deliberately implements as much as possible directly in Objective-C with limited dependency on OpenSSL. This gives everyone an opportunity to learn Bitcoin on a clean codebase and enables all Mac and iOS developers to extend and improve Bitcoin protocol.

Note that "Bitcoin Core" (previously known as BitcoinQT or "Satoshi client") is a completely different project.

Projects using CoreBitcoin

Features

See also Release Notes.

Currency Tools

  • Bitcoin currency formatter with support for BTC, mBTC, bits (BTCNumberFormatter).
  • Currency converter (not linked to any exchange) with support for various methods to calculate exchange rate (BTCCurrencyConverter).
  • Various price sources and abstract interface for adding new ones (BTCPriceSource with support for Winkdex, Coindesk, Coinbase, Paymium).

Advanced Features

  • Deterministic RFC6979-compliant ECDSA signatures.
  • Script evaluation machine to actually validate individual transactions (BTCScriptMachine).
  • Blind signatures implementation (BTCBlindSignature).
  • Math on elliptic curves: big numbers, curve points, conversion between keys, numbers and points (BTCBigNumber, BTCCurvePoint).
  • Various cryptographic primitives like hash functions and AES encryption (see BTCData.h).

On the roadmap

See all todo items.

  • Complete support for blocks and block headers.
  • SPV mode and P2P communication with other nodes.
  • Full blockchain verification procedure and storage.
  • Importing BitcoinQT, Electrum and Blockchain.info wallets.
  • Support for libsecp256k1 in addition to OpenSSL.
  • Eventual support for libconsensus as it gets more mature and feature-complete.

The goal is to implement everything useful related to Bitcoin and organize it nicely in a single powerful library. Pull requests are welcome.

Starting points

To encode/decode addresses see BTCAddress.

To perform cryptographic operations, use BTCKey, BTCBigNumber and BTCCurvePoint. BTCKeychain implements BIP32 (hierarchical deterministic wallet).

To fetch unspent coins and broadcast transactions use one of the 3rd party APIs: BTCBlockchainInfo (blockchain.info) or Chain-iOS (recommended).

For full wallet workflow see BTCTransaction+Tests.m (fetch unspent outputs, compose a transaction, sign inputs, verify and broadcast).

For multisignature scripts usage see BTCScript+Tests.m: compose and unlock multisig output.

All other files with +Tests in their name are worth checking out as they contain useful sample code.

Using CoreBitcoin CocoaPod (recommended)

Add this to your Podfile:

pod 'CoreBitcoin', :podspec => 'https://raw.github.com/oleganza/CoreBitcoin/master/CoreBitcoin.podspec'

Run in Terminal:

$ pod install

Include headers:

#import <CoreBitcoin/CoreBitcoin.h>

If you'd like to use categories, include different header:

#import <CoreBitcoin/CoreBitcoin+Categories.h>

Using CoreBitcoin.framework

Clone this repository and build all libraries:

$ ./update_openssl.sh
$ ./build_libraries.sh

Copy iOS or OS X framework located in binaries/iOS or binaries/OSX to your project.

Include headers:

#import <CoreBitcoin/CoreBitcoin.h>

There are also raw universal libraries (.a) with headers located in binaries/include, if you happen to need them for some reason. Frameworks and binary libraries have OpenSSL built-in. If you have different version of OpenSSL in your project, consider using CocoaPods or raw sources of CoreBitcoin.

Swift

We love Swift and design the code to be compatible with Swift. That means using modern enums, favoring initializers over factory methods, avoiding obscure C features etc. You are welcome to try using CoreBitcoin from Swift, please file bugs if you have problems.

Swift is awesome to write crypto in it (due to explicit optionals, generics and first-class structs) and we would love to rewrite the entire CoreBitcoin and even relevant portions of OpenSSL in it. Unfortunately, for a year or two it's just out of the question due to instability. And then, using Swift-only features on the API level would mean that Objective-C code wouldn't be able to use CoreBitcoin. Given that, in the medium term we will focus solely on Objective-C implementation compatible with Swift. When everyone jumps exclusively on Swift, we'll make a complete rewrite.

Contribute

Feel free to open issues, drop us pull requests or contact us to discuss how to do things.

Follow existing code style and use 4 spaces instead of tabs. Methods have opening braces on a new line. There's no line width limit.

Email: oleganza@gmail.com

Twitter: @oleganza

To publish on CocoaPods:

$ pod trunk push --verbose --use-libraries

Donate

Please send your donations here: 1CBtcGivXmHQ8ZqdPgeMfcpQNJrqTrSAcG.

All funds will be used only for bounties.

You can also donate to a specific bounty. The amount will be reserved for that bounty and listed above. Contact Oleg to arrange that.

License

Released under WTFPL (except for OpenSSL). Have a nice day.