• Stars
    star
    699
  • Rank 64,759 (Top 2 %)
  • Language
    C
  • License
    Do What The F*ck ...
  • Created over 11 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Awesome Bitcoin toolkit for ObjC and Swift

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.

Do not confuse this with "Bitcoin Core" (previously known as BitcoinQT or "Satoshi client") โ€” the CoreBitcoin is stylized after Apple frameworks (like CoreAnimation and CoreFoundation), and was named this way in 2013, while Bitcoin-QT was renamed into Bitcoin Core in 2014.

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: [email protected]

Twitter: @oleganza

To publish on CocoaPods:

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

License

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

More Repositories

1

bitcoin-papers

Personal ideas and inventions for Bitcoin
167
star
2

btcruby

Comprehensive Bitcoin and Open Assets toolkit for Ruby
Ruby
70
star
3

bash-settings

My personal bash aliases and settings
Shell
43
star
4

emrpc

Modular ruby RPC library with blocking and evented API (using EventMachine)
Ruby
29
star
5

OAPromise

OAPromise is an API separating async operations and their callbacks, adding consistency and useful features like fall-through errors and progress reports.
Objective-C
27
star
6

io-snippets

Misc snippets in Io programming language (iolanguage.com)
Io
24
star
7

iovm2

iovm2 is an attempt to build optimizing compiler for Io programming language
JavaScript
23
star
8

autogit

AutoGit is an automatic package manager for Ruby (alternative to RubyGems)
Ruby
20
star
9

vkontakte.ruby

Ruby API for vkontakte.ru for syncing personal data with local StrokeDB database
Ruby
20
star
10

strokedb-core

Minimalistic modular engine for StrokeDB
Ruby
19
star
11

iopackage

Io code package manager based on Git repositories
Io
18
star
12

ampoule

git-based todo manager/bugtracker
Ruby
17
star
13

blindsignaturedemo

Bitcoin Blind Signatures Demo
C
14
star
14

bitcoin-duo

Bitcoin Duo: achieving consensus the safe way
C++
11
star
15

web-frameworks-benchmark

Merb, rails and ramaze benchmark
Ruby
10
star
16

gitbox2

Swift
8
star
17

learning-french

My notes and cheatsheets about Franรงais.
8
star
18

OAStateMachine

Little State Machine with nested states, animations and without matrices.
Objective-C
7
star
19

vkontakte-player

Vkontakte audio player for Mac OS X
Ruby
5
star
20

amanda

web-toolkit for the Io language
5
star
21

fullmapper

fullmapper is a purely experimental rewrite of the dm-core core. Or, better say, core core. Of the dm-core.
Ruby
4
star
22

literate

Literate programming for Ruby
Ruby
4
star
23

gitbox

Original source code of Gitbox 2010-2012
C
3
star
24

ristretto-musig2

MuSig2 implementation for ristretto255
3
star
25

Coder

NSCoding-inspired library for encoding object graphs in Ruby. Plus optional formatter/decoder for JavaScript.
Ruby
3
star
26

serials

Scalable serial numbers database (example of TokyoCabinet usage)
Ruby
3
star
27

declarations

Extremely small, perfectly done dynamic inheritable declarations lib for Ruby. You should use it for DSL macros like "has_many", "before_filter" etc.
Ruby
3
star
28

nginx-mirror

Mirror of the official Igor Sysoev's Nginx tarballs
2
star
29

theca

Programming language with strong static typing and dynamic compilation
2
star
30

gem_console

Tool for building custom consoles in gem-like ruby libraries.
2
star
31

OAMixin

True mixin functionality for Objective-C
Objective-C
2
star
32

lol-u-all-suk

U suk, ok?
Ruby
1
star
33

tokyocabinet-wrapper

Friendly OOP-style TokyoCabinet wrapper
Ruby
1
star
34

genconsole

genconsole.rb helps to create an IRb console for your app or library in interactive mode. Replacement for gem_console.
1
star
35

else.ruby

Else is a collection of useful or/and funny code snippets in Ruby.
Ruby
1
star
36

simple-fixtures

Ruby
1
star