Skip to content

Commit 7155fc3

Browse files
committed
Add project README with setup and usage instructions
Introduces a README.md detailing repository structure, prerequisites, installation steps, usage examples, testing instructions, and licensing for the bdk-dart project.
1 parent f845653 commit 7155fc3

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# bdk-dart
2+
3+
Dart bindings for the [Bitcoin Dev Kit (BDK)](https://bitcoindevkit.org/) wallet library.
4+
The repo packages the generated UniFFI bindings (`lib/bdk.dart`) together with the
5+
compiled `libbdkffi` native library so Dart and Flutter apps can work with descriptor-based
6+
wallets, key management utilities, and blockchain backends from BDK.
7+
8+
## Repository layout
9+
10+
| Path | Purpose |
11+
| ---- | ------- |
12+
| `bdk-ffi/` | Rust sources and build scripts for the underlying `bdk-ffi` crate. |
13+
| `lib/` | Generated Dart bindings (`bdk.dart`) produced by UniFFI-Dart. |
14+
| `examples/` | Standalone Dart examples that exercise common workflows. |
15+
| `test/` | Integration-style tests that cover wallet creation, persistence, and networking. |
16+
| `bdk_demo/` | Flutter sample app you can point at mobile targets once the bindings are built. |
17+
| `scripts/generate_bindings.sh` | Helper used to rebuild the native library and regenerate the Dart bindings. |
18+
19+
## Prerequisites
20+
21+
To build the bindings locally you need:
22+
23+
- Dart SDK 3.2 or newer (see `pubspec.yaml`).
24+
- Rust toolchain with `cargo` and the native targets you intend to build.
25+
- `clang`/`lld` (or equivalent platform toolchain) for producing the shared library.
26+
- Flutter (optional) if you plan to run `bdk_demo`.
27+
28+
Make sure submodules are cloned because the Rust crate lives in `bdk-ffi/`:
29+
30+
```bash
31+
git clone --recurse-submodules https://github.com/bitcoindevkit/bdk-dart.git
32+
cd bdk-dart
33+
```
34+
35+
## Installation
36+
37+
1. Install dependencies:
38+
```bash
39+
dart pub get
40+
```
41+
2. Generate the Dart bindings and native binary:
42+
```bash
43+
./scripts/generate_bindings.sh
44+
```
45+
The script builds `bdk-ffi`, runs the local `uniffi-bindgen` wrapper, and drops the
46+
resulting `libbdkffi.*` alongside the freshly generated `lib/bdk.dart`.
47+
3. Make sure the produced library is discoverable at runtime. For CLI usage you can export
48+
`LD_LIBRARY_PATH`/`DYLD_LIBRARY_PATH` or keep the binary in the same directory as your
49+
Dart entrypoint.
50+
51+
## Usage
52+
53+
After generating the bindings you can run the examples or consume the package from your
54+
own project. For instance, the `examples/network_example.dart` walkthrough shows how to:
55+
56+
1. Create a new mnemonic and derive BIP84 descriptors.
57+
2. Instantiate a wallet backed by the in-memory persister.
58+
3. Reveal addresses and persist staged changes.
59+
4. Optionally sync with Electrum over TLS.
60+
61+
Run it with:
62+
63+
```bash
64+
dart run examples/network_example.dart
65+
```
66+
67+
When embedding in Flutter, add a path or git dependency on this package and ensure the
68+
native library is bundled per target platform (e.g., via `flutter_rust_bridge`-style
69+
build steps or platform-specific build scripts).
70+
71+
## Testing
72+
73+
Once `lib/bdk.dart` and the native library are available you can execute the Dart test
74+
suite, which covers wallet creation, persistence, offline behavior, and descriptor APIs:
75+
76+
```bash
77+
dart test
78+
```
79+
80+
## License
81+
82+
The Rust crate and generated bindings are dual-licensed under MIT or Apache 2.0 per the
83+
`license = "MIT OR Apache-2.0"` entry in `Cargo.toml`. You may choose either license when
84+
using the library in your project.

0 commit comments

Comments
 (0)