bdk-rn
v1.1.0
Published
React Native language bindings for the bitcoin development kit
Maintainers
Readme
Bitcoin Dev Kit — React Native
React Native language bindings for the Bitcoin Development Kit. Read our documentation for this library here.
The code in this repository is mostly comprised of:
- Build tools and workflows
- CI workflows
- Tests
- Docs
The core Rust code that is exposed to the React Native language bindings actually resides in the bdk-ffi repository. This repo pulls it in as a submodule.
Supported Platforms
The package ships prebuilt native libraries for:
- Android:
arm64-v8a(devices) andx86_64(emulators) - iOS:
arm64devices andarm64simulators (Apple Silicon Macs)
32-bit Android ABIs (armeabi-v7a and x86) are not supported. New React Native apps build all four Android ABIs by default, which produces 32-bit builds that do not contain bdk-rn and would crash on a 32-bit-only device. Restrict your app to the supported ABIs in android/gradle.properties:
reactNativeArchitectures=arm64-v8a,x86_64Exploring the Example Apps
To take a look at the API exposed in this library, you can run our example applications. Read the docs on this here, and find our example apps here.
Building the Library and Running the Tests
Take a look at our docs here for more complete information on building, testing, CI, releases, etc.
You can easily build the library from source for quick development and iteration with only a few prerequisites:
- Rust toolchain (stable 1.91.1)
justCLI tool: https://github.com/casey/justcargo-ndk(cargo install cargo-ndk)- For iOS: CocoaPods >= 1.13: ()
brew install cocoapods)
Build Instructions
# Clone the repo and install prerequisites
git clone [email protected]:bitcoindevkit/bdk-rn.git
cd bdk-rn
# Install compilation targets
rustup target add aarch64-linux-android x86_64-linux-android aarch64-apple-ios aarch64-apple-ios-sim
# Build the library and create tarball (includes both Android and iOS)
just rename-library
# Build both platforms and creates bdk-rn-VERSION.tgz
just build-tarballRunning the Test Suite
The tests/ directory contains a standalone test app that uses the library as a tarball dependency (similar to how end-users would consume it). This app is not part of the workspace and is completely decoupled from the library development.
You can use the following workflow to run the tests locally on an Android emulator, or to develop features on the library by first making changes to the local bdk-ffi repository and then running through the workflow with new/modified tests.
# Build and package the library
just build-android
# Create the tarball bdk-rn-<version>-next.tgz
npm pack
# Install dependencies in the tests
cd tests
# Make sure your package.json file references the ../bdk-rn-<version>-next.tgz
npm install
# To see tests results in your shell, run this prior to starting the app
adb logcat -c && adb logcat -s ReactNativeJS | tee tests.log
# Run the app
npm run androidTest Development Workflow
- Make changes to
bdk-ffior the library code - Build and package:
just build-android && npm pack - Update tests:
cd tests && npm install - Add or modify tests in the tests
- Run the app and verify test results in logcat or in the emulator
