Bitspend Client is a WASM based, secure, pluggable, and lightweight Bitcoin payment client that enables applications to natively process Bitcoin payments both on-chain and off-chain. The client requires a WASI-preview2-compliant runtime, such as wasmtime and JCO.
At the core of Bitcoin-WASM is a Neutrino-based Bitcoin Light Client, providing a robust foundation that can be extended with a wide range of pluggable components, referred to as adapters. These adapters enable additional capabilities such as signing, wallet management, the Ark protocol, and Silent Payments.
flowchart TD
A[Core - Neutrino Light Client] <--> B(Adapter 1)
A --> C(Adapter 2)
A Bitcoin Neutrino Light Client is a simplified version of a full Bitcoin node that allows users to interact with the Bitcoin network without downloading and verifying the entire blockchain.
Here's a breakdown of its key features:
-
Lightweight: Neutrino clients only download and store a small portion of the blockchain, making them suitable for devices with limited storage and processing power.
-
Fast Synchronization: Neutrino clients can synchronize with the Bitcoin network much faster than full nodes, allowing users to start interacting with the network quickly.
-
Limited Functionality: While Neutrino clients can verify transactions and block headers, they do not provide full node functionality like mining or running a full archive node.
-
Dependency on Full Nodes: Neutrino clients rely on a network of full nodes to verify the validity of transactions and blocks.
- Key Value Store (Implemented)
- HD wallet (in progress)
- Online Signer (not started)
- Hardware Signer Integration (In Research)
- Ark Protocol (In Research)
Using WebAssembly (Wasm) to create Bitspend-Client has several advantages, especially in contexts where performance, security, and portability are key concerns. Hereβs why Wasm is a great fit for building Bitspend-Client:
Efficient resource usage: Wasm is designed to be compact and fast, meaning plugins written in Wasm can load and execute more quickly, enhancing the user experience.
Sandboxed execution: One of the biggest advantages of WebAssembly for plugins is its secure sandboxing model. Plugins written in Wasm run in an isolated environment with limited access to the host system, reducing the risk of malicious plugins or vulnerabilities.
Memory safety: Wasm offers built-in protections against common security issues like buffer overflows, which are common in low-level languages like C/C++. This memory safety makes it a more secure choice for plugin development.
Plugins as lightweight modules: Wasm allows you to create small, efficient modules that can easily be plugged into larger systems, whether web apps, desktop software, or server applications. These modules can be loaded and executed on-demand, reducing overall application size and improving performance.
Fine-grained control: Plugins developed in WebAssembly can be tightly controlled by the host environment. This includes managing memory, enforcing strict execution limits, and restricting access to system resources. This level of control helps in developing secure, stable plugins that donβt interfere with the host.
The executables are WASM modules which are designed to be embedded within applications using WASI runtime like wasmtime.
We warmly welcome your contributions to Bitcoin Wasm! Whether you're a seasoned developer or just starting out, your help can make a significant impact.
A. Setting Up Your Development Environment
-
Clone the Repository:
$ git clone https://github.com/aruokhai/bitcoin-wasm.git
-
Navigate to the project directory:
$ cd bitcoin-wasm -
Install Cargo Component:
$ cargo install cargo-component
-
Install
wac-cliused for building wasm :$ cargo install wac-cli
B. Running Tests
To run the project's integration tests, follow these steps:
-
Run the integration tests:
$ cd tests $ ./test-runner.sh
bitcoin-wasm
βββ crates
β βββ store
β β βββ src
β β βββ wit
| | | βββworld.wit
| | βββ Cargo.toml
β βββ wallet
β β βββ src
β β βββ wit
| | | βββworld.wit
| | βββ Cargo.toml
βββ Node
β βββ src
β β βββ lib.rs
β β βββ binding.rs
β βββ wit
| | βββworld.wit
β βββ cargo.toml
βββtests
β βββ artifacts
β | βββ src
β β βββ wit
| | | βββworld.wit
| | βββ Cargo.toml
β βββ cli
| βββ runner
β | βββ src
β β βββ wit
| | | βββworld.wit
| | βββ build.rs
βββ Cargo.toml
Here's a breakdown of the key folders:
-
crates: This folder holds adapters such as:
- store: A generic key-value store.
- wallet: The Hierachical Deterministic Wallet.
-
node: This is the core that contains the neutrino light client which uses Compact Block Filtering.
-
test: This folder holds integration tests used to verify the functionality of the project. It contains two subfolders:
- artifacts: This contains various components test logic.
- runner: The main entry point for the integration test.
There is currently one way to build the Bitcoin-Wasm project:
-
Building a specific component: You can build a specific component, like the
web5package, using the following command:$ cargo-component build --package=<package-name>
Replace
package-namewith the actual name of the package you want to build (e.gweb5).
An example of the usage of the Node plugin can be found in the examples folder. Which includes a dummy mobile money CLI application created for the TBDX 2024 Hackathon.
If it's open-source, talk about the community here, ask social media links and other links.
Your contributions are always welcome and appreciated. Following are the things you can do to contribute to this project.
-
Report a bug
If you think you have encountered a bug, and I should know about it, feel free to report it here and I will take care of it. -
Request a feature
You can also request for a feature here, and if it will viable, it will be picked for development. -
Create a pull request
It can't get better then this, your pull request will be appreciated by the community. You can get started by picking up any open issues from here and make a pull request.
If you are new to open-source, make sure to check read more about it here and learn more about creating a pull request here.
I use an agile continuous integration methodology, so the version is frequently updated and development is really fast.
-
stageis the development branch. -
masteris the production branch. -
No other permanent branches should be created in the main repository, you can create feature branches but they should get merged with the master.
Steps to work with feature branch
- To start working on a new feature, create a new branch prefixed with
featand followed by feature name. (ie.feat-FEATURE-NAME) - Once you are done with your changes, you can raise PR.
Steps to create a pull request
- Make a PR to
stagebranch. - Comply with the best practices and guidelines e.g. where the PR concerns visual elements it should have an image showing the effect.
- It must pass all continuous integration checks and get positive reviews.
After this, changes will be merged.
- Follow Rust's style guidelines and best practices.
- Write clear and concise commit messages.
- Ensure your code passes all tests.
- Review and provide feedback on other contributors' pull requests.
- WASM Specification: https://webassembly.org/
- WASI Specification: https://wasi.dev/
- Bitcoin Documentation: https://bitcoin.org/