bdk_dart 1.0.0 copy "bdk_dart: ^1.0.0" to clipboard
bdk_dart: ^1.0.0 copied to clipboard

Dart bindings for bdk-ffi, built on the Bitcoin Dev Kit.

bdk-dart #

Dart bindings for the Bitcoin Dev Kit (BDK) wallet library. The repo contains the sources for generating UniFFI-based bindings (lib/bdk.dart) and the 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
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 use this package you need:

  • Dart SDK >= 3.10 or newer (see pubspec.yaml).
  • Rust toolchain with cargo and the native targets you intend to build. You can install Rust via rustup.
  • Flutter SDK if you plan to use the package in a Flutter app or run the Flutter demo.

Supported targets #

See SUPPORTED_TARGETS.md for the current platform/architecture matrix and support status.

Add to your project #

Via git:

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

Via pub.dev:

dependencies:
  bdk_dart: ^1.0.0

Import the package entrypoint:

import 'package:bdk_dart/bdk_dart.dart';

Usage #

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.
  3. Reveal addresses and persist staged changes.
  4. Optionally sync with Electrum over TLS.

Run it with:

dart run example/main.dart

If you have the Rust toolchain installed, 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 below. The first build can take several minutes depending on your machine and network (subsequent builds are faster). We pin git dependencies to immutable refs for reproducibility. bdk-ffi and uniffi-dart both track upstream release tags.

Development #

For release operations, see PUBDEV_RELEASE_CHECKLIST.md.

Generating bindings #

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

  2. Run the bindings generator script:

    bash ./scripts/generate_bindings.sh
    

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:

dart test

Integration tests #

Integration tests are in test/integration/ and are env-gated by default. Without the env vars below, integration tests are skipped.

Run integration tests with:

BDK_DART_RUN_INTEGRATION=1 \
BDK_DART_ELECTRUM_URL=ssl://electrum.blockstream.info:60002 \
BDK_DART_ESPLORA_URL=https://blockstream.info/testnet/api \
dart test test/integration

Optional env vars:

  • BDK_DART_ELECTRUM_SOCKS5
  • BDK_DART_ESPLORA_PROXY

License #

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 native/Cargo.toml. You may choose either license when using the library in your project.

0
likes
130
points
399
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Dart bindings for bdk-ffi, built on the Bitcoin Dev Kit.

Repository (GitHub)
View/report issues
Contributing

License

unknown (license)

Dependencies

ffi, hooks, native_toolchain_rust

More

Packages that depend on bdk_dart