Foreign language bindings for BDK (bdk-ffi)
This repository contains source code for generating foreign language bindings for the rust library bdk for the Bitcoin Dev Kit (BDK) project.
Supported target languages and platforms
| Language | Platform | Status | 
|---|---|---|
| Kotlin | JVM | WIP | 
| Kotlin | Android | WIP | 
| Swift | iOS | WIP | 
Getting Started
This project uses rust. A basic knowledge of the rust ecosystem is helpful.
General
- Install uniffi-bindgencargo install uniffi_bindgen
- See the UniFFI User Guide for more info
Kotlin Bindings for JVM (OSX / Linux)
- Install required targets
rustup target add x86_64-apple-darwin x86_64-unknown-linux-gnu
- Build kotlin (JVM) bindings
./build.sh -k
- Generated kotlin bindings are available at /bindings/bdk-kotlin/
- A demo app is available at /bindings/bdk-kotlin/demo/. It uses stdin for inputs and can be run from gradle.cd bindings/bdk-kotlin ./gradlew :demo:run
Kotlin bindings for Android
- Install required targets
rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android
- Install Android SDK and Build-Tools for API level 30+
- Setup $ANDROID_NDK_HOMEand$ANDROID_SDK_ROOTpath variables (which are required by the build scripts)
- Build kotlin (Android) bindings
./build.sh -a
- A demo android app is available at notmandatory/bdk-sample-app
Swift bindings for iOS
- Install the latest version of xcode, download and install the advanced tools.
- Ensure Swift is installed
- Install required targets
rustup target add aarch64-apple-ios x86_64-apple-ios
- Build swift (iOS) bindings
./build.sh -s
- Example iOS app can be found in /examples/iOSwhich can be run by xcode.
Notes
Adding new structs and functions
See the UniFFI User Guide
For pass by value objects
- create new rust struct with only fields that are supported UniFFI types
- update mapping bdk.udlfile with newdictionary
For pass by reference values
- create wrapper rust struct/impl with only fields that are Sync + Send
- update mapping bdk.udlfile with newinterface
Goals
- Language bindings should feel idiomatic in target languages/platforms
- Adding new targets should be easy
- Getting up and running should be easy
- Contributing should be easy
- Get it right, then automate
Thanks
This project is made possible thanks to the wonderful work on mozilla/uniffi-rs
					Languages
				
				
								
								
									Rust
								
								64.6%
							
						
							
								
								
									Kotlin
								
								18.1%
							
						
							
								
								
									Swift
								
								9.5%
							
						
							
								
								
									Python
								
								4.6%
							
						
							
								
								
									Shell
								
								2.2%
							
						
							
								
								
									Other
								
								1%