by Nigel Drego (@ndrego)

With our developer community growing by the day, the 21 Bitcoin Library is increasingly being put through its paces. To make it even easier to use, we’ve prepared comprehensive documentation for the bitcoin, blockchain, wallet and crypto submodules of the library. This documentation will be kept in sync with each 21 Bitcoin Library update and is the first step towards a portable open source release. Written in Python 3, the library provides the following submodules:

The 21 Bitcoin Library. The main module within the 21 Bitcoin Library (two1.lib.bitcoin) provides functionality for working with major Bitcoin data structures. Specifically, it covers:

Classes for major Bitcoin data structures, like blocks, block headers, transactions, scripts, public and private keys, and digital signatures

Code to consistently serialize and deserialize these data structures to and from raw byte representations

Creation of standard scripts (Pay-to-Public-Key-Hash [P2PKH] and Pay-to-Script-Hash [P2SH]) as well as multi-sig support

Transaction creation, signing, verification, and broadcasting, including for multisig transactions

Standard public/private key generation as well as generation of keys for HD wallets

Utilities for working with Bitcoin’s various idiosyncrasies, from parsing variable length integers to converting difficulties to bits and back

The 21 Blockchain Library. The blockchain module within the 21 Bitcoin Library (two1.lib.blockchain) allows you to request transaction and block data from a blockchain data provider and to submit new transactions to the provider for relay to the network and inclusion in new blocks.

The 21 Machine Wallet. The wallet module within the 21 Bitcoin Library (two1.lib.wallet) provides a fully-functional HD wallet that integrates with the bitcoin mined by a 21 Mining Chip and is optimized for machine-to-machine transactions. The wallet conforms to both BIP-32 and BIP-44. It can be accessed both programmatically and via the command line.

The 21 Crypto Library. The crypto module within the 21 Bitcoin Library (two1.lib.crypto) provides an interface to the low-level cryptographic functions used in Bitcoin to create public keys and signatures using the Elliptic Curve Digital Signature Algorithm (ECDSA) on the secp256k1 curve. Two submodules are provided: an OpenSSL-using module that’s available if OpenSSL is available on the system, and a pure Python module that’s always available and is very portable, but which does not contain as many performance optimizations and has not been as heavily audited as the Bitcoin-related parts of OpenSSL. The OpenSSL module is used by default with the pure Python module used as a backup.

For those of you who have a 21 Bitcoin Computer today, we hope this documentation — in addition to the existing tutorials at 21.co/learn — helps you build even more Bitcoin-enabled applications. We always welcome feedback, so please join us and a growing community of 21 Bitcoin Computer developers at slack.21.co!