Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
263052c
chore: ignore native binaries and track generated bindings
kumulynja Nov 23, 2025
0a9984d
chore: bump to 2.3.0-alpha.0 with SDK 3.10.0 and code_assets for Nati…
kumulynja Nov 23, 2025
997714c
chore: remove lib/README.md explaining untracked bindings
kumulynja Nov 23, 2025
e169160
chore: upgrade Cargo.toml to uniffi 0.30.0 and kumulynja/uniffi-dart …
kumulynja Nov 23, 2025
a706915
refactor: update uniffi-bindgen for uniffi 0.30.0 compatibility
kumulynja Nov 23, 2025
7fc5ee1
docs: add README.md
kumulynja Nov 23, 2025
e5d7320
refactor: simplify generate_bindings.sh for Native Assets workflow
kumulynja Nov 23, 2025
9f12641
feat: add Native Assets build hook for automatic native compilation
kumulynja Nov 23, 2025
13e8b1a
fix: correct paths for bdk-ffi submodule in generate_bindings.sh
kumulynja Nov 23, 2025
8d0b697
chore: ignore target in automatically copied /native folder
kumulynja Nov 23, 2025
385c02a
chore: exclude /target folder from /native copy
kumulynja Nov 23, 2025
e9f6cbb
chore: run generate_bindings.sh with latest bdk-ffi master
kumulynja Nov 23, 2025
666f688
chore: declare build hook in pubspec.yaml
kumulynja Nov 23, 2025
ca0282a
refactor: update to native assets with build hook
kumulynja Nov 24, 2025
56238fb
Merge branch 'main' into update-to-2.3.0-alpha.0
kumulynja Nov 26, 2025
37a06ae
fix merge conflict + regenerate bindings
kumulynja Nov 26, 2025
9a3fe31
chore: change native_toolchain_rs to new package name native_toolchai…
kumulynja Dec 13, 2025
6784b9f
refactor: avoid hack of copying files in native folder or submodule b…
kumulynja Dec 13, 2025
98bd23f
remove example of cmd line app
kumulynja Dec 13, 2025
2078c99
rename examples folder and file to follow dart package conventions fo…
kumulynja Dec 13, 2025
0eae013
fix: lib name
kumulynja Dec 13, 2025
dba3677
fix merge conflicts
kumulynja Dec 13, 2025
fbe5112
cleanup submodule cmds in justfile + remove scripts that are not nece…
kumulynja Dec 13, 2025
a389abd
update bdk_demo flutter version to work with Native Assets
kumulynja Dec 13, 2025
3abecd5
refactor simple widget test in bdk_demo
kumulynja Dec 13, 2025
c21a2b3
cleanup ci workflow to remove submodule step and use example folder i…
kumulynja Dec 13, 2025
89b5bfd
format files following dart format
kumulynja Dec 13, 2025
9f7fe07
add back accidentally deleted generate_bindings.sh script
kumulynja Dec 14, 2025
2c5cd9c
update relative path of bdk-ffi fork to git url and regenerate bindings
kumulynja Dec 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [ main, "**" ]
branches: [main, "**"]
pull_request:
branches: [ main ]
branches: [main]

jobs:
build-and-test:
Expand All @@ -15,8 +15,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
Expand All @@ -29,7 +27,7 @@ jobs:
- name: Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: "3.9.2"
sdk: "3.10.0"

- name: Install lipo (macOS)
if: matrix.os == 'macos-latest'
Expand All @@ -52,10 +50,10 @@ jobs:
run: flutter pub get

- name: Format check
run: dart format --output=none --set-exit-if-changed lib test examples bdk_demo/lib bdk_demo/test
run: dart format --output=none --set-exit-if-changed lib test example bdk_demo/lib bdk_demo/test

- name: Analyze
run: dart analyze --fatal-infos --fatal-warnings lib test examples
run: dart analyze --fatal-infos --fatal-warnings lib test example

- name: Analyze (bdk_demo)
working-directory: bdk_demo
Expand Down
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Rust
/target
native/target/
**/*.rs.bk
Cargo.lock

Expand Down Expand Up @@ -31,11 +32,8 @@ Thumbs.db
*.log

# Native libs built locally
libbdkffi.*
android/libs
bdk_demo/android/app/src/main/jniLibs
ios/Release/
bdk_demo/ios/ios/
*.dylib
*.so
*.dll
test_output.txt
test output.txt
lib/bdk.dart
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

45 changes: 0 additions & 45 deletions Cargo.toml

This file was deleted.

77 changes: 40 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,48 @@

Dart bindings for the [Bitcoin Dev Kit (BDK)](https://bitcoindevkit.org/) wallet library.
The repo contains the sources for generating UniFFI-based bindings (`lib/bdk.dart`) and the
`libbdkffi` native library, both of which are produced locally (they are gitignored and not
checked into the repository) so Dart and Flutter apps can work with descriptor-based wallets,
`libbdk_dart_ffi` native library, so Dart and Flutter apps can work with descriptor-based wallets,
key management utilities, and blockchain backends from BDK.

## Repository layout

| Path | Purpose |
| ---- | ------- |
| `bdk-ffi/` | Rust sources and build scripts for the underlying `bdk-ffi` crate. |
| `lib/` | Dart bindings (`bdk.dart`) generated locally by UniFFI-Dart. |
| `examples/` | Standalone Dart examples that exercise common workflows. |
| `test/` | Offline/construction/persistence tests (not full integration tests). |
| `bdk_demo/` | Flutter sample app you can point at mobile targets once the bindings are built. |
| `scripts/generate_bindings.sh` | Helper used to rebuild the native library and regenerate the Dart bindings. |
| Path | Purpose |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| `native/` | Rust sources and uniffi-dart build scripts and configs wrapping the underlying `bdk-ffi` crate to be used by the Dart build hook. |
| `lib/` | Dart bindings (`bdk.dart`) generated by UniFFI-Dart. |
| `example/` | Standalone Dart example to showcase, test and play with the bindings. |
| `test/` | Offline/construction/persistence tests (not full integration tests). |
| `bdk_demo/` | Flutter sample app you can point at mobile targets once the bindings are built. |
| `scripts/generate_bindings.sh` | Helper used to rebuild the native library and regenerate the Dart bindings. |

## Prerequisites

To build the bindings locally you need:

- Dart SDK 3.2 or newer (see `pubspec.yaml`).
- Dart SDK >= 3.10 or newer (see `pubspec.yaml`).
- Rust toolchain with `cargo` and the native targets you intend to build.
- `clang`/`lld` (or equivalent platform toolchain) for producing the shared library.
- Flutter (optional) if you plan to run `bdk_demo`.

Make sure submodules are cloned because the Rust crate lives in `bdk-ffi/`:
### Add to your project

```bash
git clone --recurse-submodules https://github.com/bitcoindevkit/bdk-dart.git
cd bdk-dart
**Via git:**

```yaml
dependencies:
bdk_dart:
git:
url: https://github.com/bitcoindevkit/bdk-dart.git
ref: main # or specific tag
```

## Installation
**Via pub.dev:**

1. Install dependencies:
```bash
dart pub get
```
2. Generate the Dart bindings and native binary (requires a macOS or Linux host):
```bash
./scripts/generate_bindings.sh
```
The script builds `bdk-ffi`, runs the local `uniffi-bindgen` wrapper, and drops the
resulting `libbdkffi.*` alongside the freshly generated `lib/bdk.dart`.
3. Make sure the produced library is discoverable at runtime. For CLI usage you can export
`LD_LIBRARY_PATH`/`DYLD_LIBRARY_PATH` or keep the binary in the same directory as your
Dart entrypoint.
COMING SOON: Currently not published on pub.dev yet.

## Usage

After generating the bindings you can run the examples or consume the package from your
own project. For instance, the `examples/network_example.dart` walkthrough shows how to:
Check out the example in `example/main.dart` for a walkthrough of how to use the bindings to:

1. Create a new mnemonic and derive BIP84 descriptors.
2. Instantiate a wallet backed by the in-memory persister.
Expand All @@ -62,14 +53,26 @@ own project. For instance, the `examples/network_example.dart` walkthrough shows
Run it with:

```bash
dart run examples/network_example.dart
dart run example/main.dart
```

When embedding in Flutter, add a path or git dependency on this package and ensure the
native library is bundled per target platform (e.g., via `flutter_rust_bridge`-style
build steps or platform-specific build scripts).
The native library will be automatically built by Dart's Native Assets system.
As a user of the package, you don't need to worry about building the native library or bindings yourself.
Only if you want to contribute to the bindings or modify the native code yourself, you can follow the instructions in [development](#development) below.

## Development

### Generating bindings

1. Modify the native Rust code and configuration files in `native/` as needed.

2. Run the bindings generator script:

```bash
bash ./scripts/generate_bindings.sh
```

## Testing
### Testing

Once you have generated `lib/bdk.dart` and the native library locally you can execute the
Dart test suite, which covers wallet creation, persistence, offline behavior, and descriptor APIs:
Expand All @@ -82,4 +85,4 @@ dart test

The Rust crate and generated bindings are dual-licensed under MIT or Apache 2.0 per the
`license = "MIT OR Apache-2.0"` entry in `Cargo.toml`. You may choose either license when
using the library in your project.
using the library in your project.
1 change: 0 additions & 1 deletion bdk-ffi
Submodule bdk-ffi deleted from c9f11d
2 changes: 1 addition & 1 deletion bdk_demo/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions bdk_demo/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions bdk_demo/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
43 changes: 43 additions & 0 deletions bdk_demo/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Uncomment this line to define a global platform for your project
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
16 changes: 16 additions & 0 deletions bdk_demo/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PODS:
- Flutter (1.0.0)

DEPENDENCIES:
- Flutter (from `Flutter`)

EXTERNAL SOURCES:
Flutter:
:path: Flutter

SPEC CHECKSUMS:
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467

PODFILE CHECKSUM: 251cb053df7158f337c0712f2ab29f4e0fa474ce

COCOAPODS: 1.16.2
Loading