BTCRuby aims at clarity, security and flexibility. The API is designed simultenously with CoreBitcoin (Objective-C library) and polished on real-life applications.
Documentation and Examples
Please see BTCRuby Reference for API documentation and examples.
- Encoding/decoding of addresses, WIF private keys (
- APIs to construct and inspect blocks, transactions and scripts.
- Native BIP32 and BIP44 ("HW Wallets") support (see
- Explicit APIs to handle compressed and uncompressed public keys.
- Explicit APIs to handle mainnet/testnet (see
- Consistent API for data encoding used throughout the library itself (see
- Flexible transaction builder that can work with arbitrary data sources that provide unspent outputs.
- Handy extensions on built-in classes (e.g.
String#to_hex) are optional (see
- Optional attributes on Transaction, TransactionOutput and TransactionInput to hold additional data provided by 3rd party APIs.
- ECDSA signatures are deterministic and normalized according to RFC6979 and BIP62.
- Automatic normalization of existing ECDSA signatures (see
- Rich script analysis and compositing support (see
- Full script interpreter with P2SH and CLTV features.
- Powerful diagnostics API covering the entire library (see
- Canonicality checks for transactions, public keys and script elements.
- Fee computation and signature script simulation for building transactions without signing them.
- Complete OpenAssets implementation: validating OpenAssets transactions, easy to use transaction builder, API for handling Asset Definition.
- We use clear, expressive names for all methods and classes.
- Self-contained implementation. Only external dependency is
ffigem that helps linking directly with OpenSSL and libsecp256k1.
- For efficiency and consistency we use binary strings throughout the library (not the hex strings as in other libraries).
- We do not pollute standard classes with our methods. To use utility extensions like
String#to_hexyou should explicitly
- We use OpenSSL
BIGNUMimplementation where compatibility is critical (instead of the built-in Ruby Bignum).
- We enforces canonical and determinstic ECDSA signatures for maximum compatibility and security using native OpenSSL functions.
- We treat endianness explicitly. Even though most systems are little-endian, it never hurts to show where endianness is important.
The goal is to provide a complete Bitcoin toolkit in Ruby.
How to run tests
$ bundle install $ brew install ./vendor/homebrew/secp256k1.rb $ rake
How to publish a gem
- Edit version.rb to bump the version.
- Commit changes and tag it with new version.
- Generate and publish the gem:
$ git tag VERSION $ git push origin --tags $ gem build btcruby.gemspec $ gem push btcruby-VERSION.gem