Parity Bitcoin (pbtc) is a historical Bitcoin client developed by Parity Technologies. Although it is no longer maintained, it serves as an example of implementing the Bitcoin protocol in Rust. This client offers various functionalities for interacting with the Bitcoin network and includes features such as a JSON-RPC interface and the ability to import existing bitcoind databases.
Parity Bitcoin offers several key features:
Despite being unmaintained, the source code is still available for those interested in studying or building upon it. The client can be installed from source and includes detailed instructions for setting up the development environment.
To install pbtc from source, you will need rustc and cargo. Follow these steps:
Install Rust Toolchain:
curl -sSf https://static.rust-lang.org/rustup.sh | shInstall C and C++ Compilers:
sudo apt-get update
sudo apt-get install build-essentialClone and Build pbtc:
git clone https://github.com/paritytech/parity-bitcoin
cd parity-bitcoin
cargo build -p pbtcThe binary will be available at ./target/debug/pbtc or ./target/release/pbtc depending on the build mode.
Parity Bitcoin includes internal unit tests and external integration tests:
Unit Tests:
cargo test --allIntegration Tests:
git submodule update --init
./tools/regtests.shThe JSON-RPC interface is available on port :8332 for mainnet and :18332 for testnet. It provides various methods for interacting with the blockchain, such as adding nodes, querying block information, and managing transactions. Example requests can be made using curl:
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "getbestblockhash", "params": [], "id":1 }' localhost:8332Detailed logging can be enabled by setting the RUST_LOG environment variable. For example, to enable info-level logs for the verification module:
RUST_LOG=verification=info ./target/release/pbtc --btcMultiple modules can be logged simultaneously:
RUST_LOG=sync=trace,p2p=trace,verification=trace,db=trace ./target/release/pbtc --btcThe internal documentation for pbtc can be built locally:
cd parity-bitcoin
./tools/doc.sh
open target/doc/pbtc/index.htmlAlthough Parity Bitcoin is no longer actively maintained, it remains a valuable resource for understanding and implementing the Bitcoin protocol in Rust. Its comprehensive feature set and detailed documentation provide a solid foundation for developers interested in cryptocurrency and blockchain technologies.