Top Related Projects
Bitcoin Core integration/staging tree
An alternative full node bitcoin implementation written in Go (golang)
Open Source implementation of advanced blockchain features extending the Bitcoin protocol
Substrate: The platform for blockchain innovators
Go implementation of the Ethereum protocol
Monero: the secure, private, untraceable cryptocurrency
Quick Overview
Libbitcoin-system is a comprehensive C++ development toolkit for Bitcoin applications. It provides a set of libraries and tools for building Bitcoin-related software, including wallets, exchanges, and other Bitcoin services. The project aims to offer a robust, scalable, and efficient foundation for Bitcoin development.
Pros
- Extensive functionality covering various aspects of Bitcoin development
- High-performance and optimized C++ implementation
- Well-documented and actively maintained
- Modular design allowing for flexible integration into different projects
Cons
- Steep learning curve due to its comprehensive nature
- Requires advanced C++ knowledge for effective use
- May be overkill for simple Bitcoin applications
- Limited cross-platform support compared to some alternatives
Code Examples
- Creating a Bitcoin address:
#include <bitcoin/system.hpp>
int main()
{
bc::system::wallet::ec_private secret;
bc::system::wallet::ec_public public_key(secret);
bc::system::wallet::payment_address address(public_key);
std::cout << "Bitcoin address: " << address.encoded() << std::endl;
return 0;
}
- Parsing a Bitcoin transaction:
#include <bitcoin/system.hpp>
int main()
{
const auto raw_tx = bc::system::base16_literal("01000000...");
bc::system::chain::transaction tx;
tx.from_data(raw_tx);
std::cout << "Transaction hash: " << bc::system::encode_hash(tx.hash()) << std::endl;
return 0;
}
- Generating a mnemonic seed:
#include <bitcoin/system.hpp>
int main()
{
bc::system::data_chunk entropy(16);
bc::system::pseudo_random_fill(entropy);
const auto mnemonic = bc::system::wallet::create_mnemonic(entropy);
std::cout << "Mnemonic: " << bc::system::join(mnemonic) << std::endl;
return 0;
}
Getting Started
-
Install dependencies (on Ubuntu):
sudo apt-get install build-essential autoconf automake libtool pkg-config git
-
Clone the repository:
git clone https://github.com/libbitcoin/libbitcoin-system.git cd libbitcoin-system
-
Build and install:
./autogen.sh ./configure make sudo make install
-
Include in your C++ project:
#include <bitcoin/system.hpp>
-
Compile with:
g++ -std=c++11 your_file.cpp $(pkg-config --cflags libbitcoin-system) $(pkg-config --libs libbitcoin-system) -o your_program
Competitor Comparisons
Bitcoin Core integration/staging tree
Pros of Bitcoin
- Widely adopted and extensively tested in production environments
- Large and active developer community, ensuring regular updates and improvements
- Comprehensive documentation and extensive resources for developers
Cons of Bitcoin
- Complex codebase with a steep learning curve for new contributors
- Slower development cycle due to rigorous review process and consensus requirements
- Less modular architecture, making it harder to use specific components independently
Code Comparison
Bitcoin (C++):
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
if (halvings >= 64)
return 0;
CAmount nSubsidy = 50 * COIN;
return ((nSubsidy >> halvings) * consensusParams.nSubsidyMultiplier) / consensusParams.nSubsidyDivisor;
}
Libbitcoin-system (C++):
uint64_t bitcoin_calculator::initial_block_subsidy()
{
return 50 * bitcoin_to_satoshi(1);
}
uint64_t bitcoin_calculator::block_subsidy(size_t height)
{
auto subsidy = initial_block_subsidy();
subsidy >>= (height / halving_interval);
return subsidy;
}
The code comparison shows that Libbitcoin-system offers a more modular and simplified approach to calculating block subsidies, while Bitcoin's implementation includes additional parameters for consensus rules.
An alternative full node bitcoin implementation written in Go (golang)
Pros of btcd
- Written in Go, offering better performance and concurrency
- More active development and larger community support
- Comprehensive documentation and examples
Cons of btcd
- Less flexible compared to libbitcoin-system's modular architecture
- May have a steeper learning curve for developers not familiar with Go
Code Comparison
btcd (Go):
block := wire.MsgBlock{}
err := block.Deserialize(blockReader)
if err != nil {
return err
}
libbitcoin-system (C++):
chain::block block;
if (!block.from_data(version, data))
{
return false;
}
Additional Notes
Both btcd and libbitcoin-system are full node implementations of the Bitcoin protocol. btcd is written in Go and focuses on performance and ease of use, while libbitcoin-system is written in C++ and emphasizes modularity and flexibility. btcd has a more active development community and better documentation, making it potentially easier for newcomers to get started. However, libbitcoin-system's modular architecture allows for more customization and fine-grained control over various components of the Bitcoin system.
The code comparison shows that both libraries have similar approaches to block deserialization, with btcd using a more Go-idiomatic error handling approach, while libbitcoin-system uses a boolean return value to indicate success or failure.
Open Source implementation of advanced blockchain features extending the Bitcoin protocol
Pros of Elements
- Extends Bitcoin's functionality with advanced features like confidential transactions and issued assets
- Actively maintained with regular updates and improvements
- Supports sidechain technology, allowing for experimentation without affecting the main Bitcoin network
Cons of Elements
- More complex codebase due to additional features, potentially harder to understand and maintain
- May have a steeper learning curve for developers new to blockchain technology
- Smaller community and ecosystem compared to Bitcoin Core-based projects
Code Comparison
Elements (C++):
CConfidentialValue CTxOut::GetAmount() const
{
return nValue;
}
Libbitcoin-system (C++):
uint64_t output::value() const
{
return value_;
}
Key Differences
- Elements focuses on extending Bitcoin's functionality with advanced features
- Libbitcoin-system aims to provide a modular, high-performance Bitcoin library
- Elements is more closely aligned with Bitcoin Core's codebase
- Libbitcoin-system offers a more flexible architecture for building custom Bitcoin applications
Use Cases
- Elements: Ideal for projects requiring advanced Bitcoin features or sidechain experimentation
- Libbitcoin-system: Better suited for developers building custom Bitcoin applications or those who prefer a modular approach
Substrate: The platform for blockchain innovators
Pros of Substrate
- More versatile and flexible for building custom blockchains
- Supports multiple programming languages (Rust, C++, Go)
- Offers a modular architecture for easier customization
Cons of Substrate
- Steeper learning curve due to its complexity
- Larger codebase and potentially higher resource requirements
- Less focused on Bitcoin-specific functionality
Code Comparison
Substrate (Rust):
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::weight(10_000)]
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
let who = ensure_signed(origin)?;
// Function implementation
}
}
Libbitcoin-system (C++):
BC_API transaction_result transaction_organizer::organize(
transaction_const_ptr tx, result_handler handler)
{
// Function implementation
}
The code snippets showcase the different approaches and languages used in each project. Substrate uses Rust with a more declarative style, while Libbitcoin-system employs C++ with a more traditional object-oriented approach.
Go implementation of the Ethereum protocol
Pros of go-ethereum
- More comprehensive Ethereum implementation, supporting full node functionality
- Actively maintained with frequent updates and larger community support
- Better documentation and extensive API for developers
Cons of go-ethereum
- Larger codebase and more complex architecture
- Higher resource requirements for running a full node
- Specific to Ethereum, less flexible for other blockchain implementations
Code Comparison
libbitcoin-system (C++):
#include <bitcoin/system.hpp>
int main() {
bc::system::chain::transaction tx;
// ... transaction operations
}
go-ethereum (Go):
import (
"github.com/ethereum/go-ethereum/core/types"
)
func main() {
tx := types.NewTransaction(nonce, to, amount, gasLimit, gasPrice, data)
// ... transaction operations
}
Key Differences
- libbitcoin-system focuses on Bitcoin, while go-ethereum is Ethereum-specific
- go-ethereum offers a more complete blockchain node implementation
- libbitcoin-system provides a modular library approach, allowing for more flexibility
- go-ethereum has better tooling and ecosystem support for smart contract development
- libbitcoin-system may be more suitable for custom blockchain implementations
Both projects have their strengths, with go-ethereum being more suitable for Ethereum-specific development and libbitcoin-system offering a flexible foundation for various blockchain projects.
Monero: the secure, private, untraceable cryptocurrency
Pros of Monero
- Enhanced privacy features with ring signatures and stealth addresses
- Active development community with frequent updates
- Broader ecosystem support including wallets and exchanges
Cons of Monero
- Larger codebase, potentially more complex to maintain
- Higher resource requirements for running a full node
- Less modular architecture compared to Libbitcoin-system
Code Comparison
Monero (C++):
crypto::public_key derive_subaddress_public_key(
const crypto::public_key& B,
const crypto::key_derivation& derivation,
const std::size_t output_index)
{
crypto::ec_scalar scalar;
derivation_to_scalar(derivation, output_index, scalar);
return rct::rct2pk(rct::addKeys(rct::pk2rct(B), rct::scalarmultBase(rct::sk2rct(scalar))));
}
Libbitcoin-system (C++):
BC_API hash_digest bitcoin_hash(data_slice data)
{
auto first = sha256_hash(data);
return sha256_hash(first);
}
The Monero code snippet showcases its focus on privacy-enhancing features, while the Libbitcoin-system example demonstrates its more streamlined approach to core cryptocurrency functions.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Libbitcoin
The Bitcoin Development Library
Documentation is available on the wiki.
License Overview
All files in this repository fall under the license specified in COPYING. The project is licensed as AGPL with a lesser clause. It may be used within a proprietary project, but the core library and any changes to it must be published online. Source code for this library must always remain free for everybody to access.
About Libbitcoin
The libbitcoin toolkit is a set of cross platform C++ libraries for building bitcoin applications. The toolkit consists of several libraries, most of which depend on the base libbitcoin-system library. Each library's repository can be cloned and built using common automake 1.14+ instructions. There are no packages yet in distribution however each library includes an installation script (described below) which is regularly verified in the automated build.
Installation
The master branch is a staging area for the next major release and should be used only by libbitcoin developers. The current release branch is version3. Detailed installation instructions are provided below.
Autotools (advanced users)
On Linux and macOS libbitcoin is built using Autotools as follows.
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig
A minimal libbitcoin build requires boost and libsecp256k1. The libbitcoin/secp256k1 repository is forked from bitcoin-core/secp256k1 in order to control for changes and to incorporate the necessary Visual Studio build. The original repository can be used directly but recent changes to the public interface may cause build breaks. The --enable-module-recovery
switch is required.
Debian/Ubuntu
Libbitcoin requires a C++11 compiler, currently minimum GCC 4.8.0 or Clang based on LLVM 3.5.
Install the build system (Automake minimum 1.14) and git:
$ sudo apt-get install build-essential autoconf automake libtool pkg-config git
Next download the install script and enable execution:
$ wget https://raw.githubusercontent.com/libbitcoin/libbitcoin/version3/install.sh
$ chmod +x install.sh
Finally install libbitcoin with recommended build options:
$ ./install.sh --prefix=/home/me/myprefix --build-boost --disable-shared
Libbitcoin is now installed in /home/me/myprefix/
.
MacOS
The macOS installation differs from Linux in the installation of the compiler and packaged dependencies. Libbitcoin supports both Homebrew and MacPorts package managers. Both require Apple's Xcode command line tools. Neither requires Xcode as the tools may be installed independently.
Libbitcoin compiles with Clang on macOS and requires C++11 support. Installation has been verified using Clang based on LLVM 3.5. This version or newer should be installed as part of the Xcode command line tools.
To see your Clang/LLVM version:
$ clang++ --version
You may encounter a prompt to install the Xcode command line developer tools, in which case accept the prompt.
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
If required update your version of the command line tools as follows:
$ xcode-select --install
Using Homebrew
First install Homebrew.
Next install the build system (Automake minimum 1.14) and wget:
$ brew install autoconf automake libtool pkgconfig wget
Next download the install script and enable execution:
$ wget https://raw.githubusercontent.com/libbitcoin/libbitcoin/version3/install.sh
$ chmod +x install.sh
Finally install libbitcoin with recommended build options:
$ ./install.sh --prefix=/home/me/myprefix --build-boost --disable-shared
Libbitcoin is now installed in /home/me/myprefix/
.
Using MacPorts
First install MacPorts.
Next install the build system (Automake minimum 1.14) and wget:
$ sudo port install autoconf automake libtool pkgconfig wget
Next download the install script and enable execution:
$ wget https://raw.githubusercontent.com/libbitcoin/libbitcoin/version3/install.sh
$ chmod +x install.sh
Finally install libbitcoin with recommended build options:
$ ./install.sh --prefix=/home/me/myprefix --build-boost --disable-shared
Libbitcoin is now installed in /home/me/myprefix/
.
Build Notes for Linux / macOS
The install script itself is commented so that the manual build steps for each dependency can be inferred by a developer.
You can run the install script from any directory on your system. By default this will build libbitcoin in a subdirectory named build-libbitcoin
and install it to /usr/local/
. The install script requires sudo
only if you do not have access to the installation location, which you can change using the --prefix
option on the installer command line.
The build script clones, builds and installs two unpackaged repositories, namely:
The script builds from the head of their version7
and version3
branches respectively. The master
branch is a staging area for changes. The version branches are considered release quality.
Build Options
Any set of ./configure
options can be passed via the build script, for example:
$ ./install.sh CFLAGS="-Og -g" --prefix=/home/me/myprefix
Compiling with ICU (International Components for Unicode)
Since the addition of BIP-39 and later BIP-38 and Electrum mnemnoic support, libbitcoin conditionally incorporates ICU. To use passphrase normalization for these features libbitcoin must be compiled with the --with-icu
option. Currently libbitcoin-explorer is the only other library that accesses this feature, so if you do not intend to use passphrase normalization this dependency can be avoided.
$ ./install.sh --with-icu --build-icu --build-boost --disable-shared
Building ICU and/or Boost
The installer can download and install these dependencies. ICU is a large package that is not typically preinstalled at a sufficient level. Using these builds ensures compiler and configuration compatibility across all of the build components. It is recommended to use a prefix directory when building these components.
$ ./install.sh --prefix=/home/me/myprefix --with-icu --build-icu --build-boost --disable-shared
Windows
Visual Studio solutions are maintained for all libbitcoin libraries. NuGet packages exist for all dependencies. ICU is integrated into Windows and therefore not required as an additional dependency when using ICU features.
The libbitcoin execution environment supports
Windows XP Service Pack 2
and newer.
Supported Compilers
Libbitcoin requires a C++11 compiler, which means Visual Studio 2013 (with a pre-release compiler update) or later. Download and install one of the following free tools as necessary:
NuGet Repository
Dependencies apart from the libbitcoin libraries are available as NuGet packages:
- Packages maintained by sergey.shandar
- Packages maintained by evoskuil
The packages can be viewed using the NuGet package manager from the libbitcoin solution. The package manager will prompt for download of any missing packages.
The libbitcoin solution files are configured with references to these packages. The location of the NuGet repository is controlled by the nuget.config file repositoryPath
setting and the NuGetPackageRoot
element of each [project].props file.
Build Libbitcoin Projects
After cloning the the repository the libbitcoin build can be performed from within Visual Studio or using the build_all.bat
script provided in the builds\msvc\build\
subdirectory. The script automatically downloads all required NuGet packages.
Tip: The
build_all.bat
script builds all valid configurations for all compilers. The build time can be significantly reduced by disabling all but the desired configuration inbuild_base.bat
andbuild_all.bat
.
The libbitcoin dynamic (DLL) build configurations do not compile, as the exports have not yet been fully implemented. These are currently disabled in the build scripts but you will encounter numerous errors if you build then manually.
Optional: Building External Dependencies
The secp256k1 and libzmq package above are maintained using the same Visual Studio template as all libbitcoin libraries. If so desired these can be built locally, in the same manner as libbitcoin.
This change is properly accomplished by disabling the "NuGet Dependencies" in the Visual Studio properties user interface and then importing secp256k1.import.props
, which references secp256k1.import.xml
and libzmq.import.props
, which references libzmq.import.xml
.
See boost documentation for building boost libraries for Visual C++.
Top Related Projects
Bitcoin Core integration/staging tree
An alternative full node bitcoin implementation written in Go (golang)
Open Source implementation of advanced blockchain features extending the Bitcoin protocol
Substrate: The platform for blockchain innovators
Go implementation of the Ethereum protocol
Monero: the secure, private, untraceable cryptocurrency
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot