Rust Bitcoin is a Rust library that provides support for de/serialization, parsing, and executing data-structures and network messages related to Bitcoin.
Rust Bitcoin supports:
For JSONRPC interaction with Bitcoin Core, it is recommended to use rust-bitcoincore-rpc.
The complete documentation for Rust Bitcoin is available on docs.rs/bitcoin.
This library must not be used for consensus code (i.e., fully validating blockchain data). It supports this technically, but there are many deviations between this library and the Bitcoin Core reference implementation. In a consensus-based cryptocurrency like Bitcoin, it is critical that all parties use the same rules to validate data. Given the complexity of both C++ and Rust, it is unlikely this will ever be fully fixed, and there are no plans to do so. However, patches to fix specific consensus incompatibilities are welcome.
16-bit pointer sizes are not supported, and we can't promise they will be. If you care about this, please let us know to gauge interest and possibly decide to support it.
To build the library, run:
To run tests:
For more detailed instructions, refer to the cargo documentation.
Rust Bitcoin should compile with any combination of features on Rust 1.56.1. To build with the MSRV, you might need to pin several dependencies. See ./contrib/test.sh
for the current list.
Rust Bitcoin integrates with several external libraries, most notably serde
. These are available via feature flags. We provide two lock files to ensure compatibility and MSRV stability: Cargo-minimal.lock
containing minimal versions of dependencies and Cargo-recent.lock
containing recent versions tested in our CI.
Rust can be installed using your package manager of choice or rustup.rs. Using your package manager is generally more secure, but the Rust version might be outdated. Rust Bitcoin supports much older versions than the current stable one, so this is typically not a problem.
Rust Bitcoin does not support any altcoins. Supporting Bitcoin properly is already challenging, and adding support for other coins would increase maintenance burden and decrease API stability. The code is public domain, so feel free to fork it and adapt it for other coins.