2022-11-14 10:54:06 -05:00
# Native language bindings for BDK
< p >
< a href = "https://github.com/bitcoindevkit/bdk-ffi/blob/master/LICENSE" > < img alt = "MIT or Apache-2.0 Licensed" src = "https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg" / > < / a >
< a href = "https://github.com/bitcoindevkit/bdk-ffi/actions?query=workflow%3ACI" > < img alt = "CI Status" src = "https://github.com/bitcoindevkit/bdk-ffi/workflows/CI/badge.svg" > < / a >
< a href = "https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html" > < img alt = "Rustc Version 1.61.0+" src = "https://img.shields.io/badge/rustc-1.61.0%2B-lightgrey.svg" / > < / a >
< a href = "https://discord.gg/d7NkDKm" > < img alt = "Chat on Discord" src = "https://img.shields.io/discord/753336465005608961?logo=discord" > < / a >
2022-12-06 15:17:10 -05:00
< / p >
2022-11-14 10:54:06 -05:00
2023-10-23 11:49:31 -04:00
## 🚨 Warning 🚨
2024-02-01 10:34:59 -05:00
The `master` branch of this repository is being migrated to the [bdk 1.0 API ](https://github.com/bitcoindevkit/bdk ) and is incomplete. For production-ready libraries, use the [`0.31.X` ](https://github.com/bitcoindevkit/bdk-ffi/tree/release/0.30 ) releases.
2023-10-23 11:49:31 -04:00
## Readme
2022-11-15 20:29:58 -05:00
The workspace in this repository creates the `libbdkffi` multi-language library for the Rust-based
2023-03-27 13:39:28 -04:00
[bdk] library from the [Bitcoin Dev Kit] project.
2022-11-14 10:54:06 -05:00
2022-11-15 20:29:58 -05:00
Each supported language and the platform(s) it's packaged for has its own directory. The Rust code in this project is in the bdk-ffi directory and is a wrapper around the [bdk] library to expose its APIs in a uniform way using the [mozilla/uniffi-rs] bindings generator for each supported target language.
2022-11-14 10:54:06 -05:00
## Supported target languages and platforms
2022-11-15 20:29:58 -05:00
The below directories (a separate repository in the case of bdk-swift) include instructions for using, building, and publishing the native language binding for [bdk] supported by this project.
2022-11-14 10:54:06 -05:00
2022-11-15 20:29:58 -05:00
| Language | Platform | Published Package | Building Documentation | API Docs |
| -------- |-----------------------|-------------------------------|------------------------|-----------------------|
| Kotlin | JVM | [bdk-jvm (Maven Central)] | [Readme bdk-jvm] | [Kotlin JVM API Docs] |
| Kotlin | Android | [bdk-android (Maven Central)] | [Readme bdk-android] | [Android API Docs] |
| Swift | iOS, macOS | [bdk-swift (GitHub)] | [Readme bdk-swift] | |
| Python | linux, macOS, Windows | [bdk-python (PyPI)] | [Readme bdk-python] | |
2022-11-14 10:54:06 -05:00
2024-04-01 15:13:04 -04:00
## Building and Testing the Libraries
If you are familiar with the build tools for the specific languages you wish to build the libraries for, you can use their normal build/test workflows. We also include some [just ](https://just.systems/ ) files to simplify the work across different languages. If you have the just tool installed on your system, you can simply call the commands defined in the `justfile` s, for example:
```sh
cd bdk-android
just build
just offlinetests
just publishlocal
```
2023-08-03 16:36:07 -05:00
2024-04-01 15:13:04 -04:00
## Minimum Supported Rust Version (MSRV)
2023-11-09 16:17:03 -06:00
This library should compile with any combination of features with Rust 1.73.0.
2023-08-03 16:36:07 -05:00
2022-11-14 10:54:06 -05:00
## Contributing
2024-04-01 15:13:04 -04:00
To add new structs and functions, see the [UniFFI User Guide ](https://mozilla.github.io/uniffi-rs/ ) and the [uniffi-examples ](https://thunderbiscuit.github.io/uniffi-examples/ ) repository.
2022-11-14 10:54:06 -05:00
## Goals
1. Language bindings should feel idiomatic in target languages/platforms
2022-11-15 20:29:58 -05:00
2. Adding new targets should be easy
3. Getting up and running should be easy
4. Contributing should be easy
5. Get it right, then automate
2021-10-30 00:27:02 +05:30
2022-11-15 20:29:58 -05:00
## Using the libraries
### bdk-android
```kotlin
// build.gradle.kts
2021-12-14 08:24:41 -08:00
repositories {
mavenCentral()
}
2023-09-06 14:13:15 -04:00
dependencies {
implementation("org.bitcoindevkit:bdk-android:< version > ")
2021-12-14 08:24:41 -08:00
}
```
2021-11-06 01:30:36 +05:30
2022-11-15 20:29:58 -05:00
### bdk-jvm
2021-12-14 08:24:41 -08:00
```kotlin
2022-11-15 20:29:58 -05:00
// build.gradle.kts
repositories {
mavenCentral()
}
2023-09-06 14:13:15 -04:00
dependencies {
implementation("org.bitcoindevkit:bdk-jvm:< version > ")
2022-11-15 20:29:58 -05:00
}
2022-04-12 15:04:24 -04:00
```
2021-10-16 14:45:32 +05:30
2022-11-30 12:20:48 -05:00
_Note:_ We also publish snapshot versions of bdk-jvm and bdk-android. See the specific readmes for instructions on how to use those.
2022-11-15 20:29:58 -05:00
### bdk-python
2022-04-12 15:04:24 -04:00
```shell
2022-11-15 20:29:58 -05:00
pip3 install bdkpython
2022-04-12 15:04:24 -04:00
```
2022-09-13 13:33:36 -04:00
2022-11-15 20:29:58 -05:00
### bdk-swift
Add bdk-swift to your dependencies in XCode.
2021-12-14 08:24:41 -08:00
2022-11-25 12:41:02 -05:00
## Developing language bindings using uniffi-rs
If you are interested in better understanding the base structure we use here in order to build your own Rust-to-Kotlin/Swift/Python language bindings, check out the [uniffi-bindings-template ](https://github.com/thunderbiscuit/uniffi-bindings-template ) repository. We maintain it as an example and starting point for other projects that wish to leverage the tech stack used in producing the BDK language bindings.
2022-09-23 10:48:29 -04:00
## Verifying Signatures
2022-09-26 09:01:05 -04:00
Both libraries and all their corresponding artifacts are signed with a PGP key you can find in the
root of this repository. To verify the signatures follow the below steps:
2022-09-23 10:48:29 -04:00
2022-09-26 09:01:05 -04:00
1. Import the PGP key in your keyring.
2022-09-23 10:48:29 -04:00
```shell
2022-09-26 09:01:05 -04:00
# Navigate to the root of the repository and import the ./PGP-BDK-BINDINGS.asc public key
2022-09-23 10:48:29 -04:00
gpg --import ./PGP-BDK-BINDINGS.asc
2022-09-26 09:01:05 -04:00
# Alternatively, you can import the key directly from a public key server
2022-09-23 10:48:29 -04:00
gpg --keyserver keyserver.ubuntu.com --receive-key 2768C43E8803C6A3
2022-09-26 09:01:05 -04:00
2022-09-23 10:48:29 -04:00
# Verify that the correct key was imported
gpg --list-keys
2022-09-26 09:01:05 -04:00
# You should see the below output
pub ed25519 2022-08-31 [SC]
88AD93AC4589FD090FF3B8D12768C43E8803C6A3
uid [ unknown] bitcoindevkit-bindings < bindings @bitcoindevkit .org >
sub cv25519 2022-08-31 [E]
```
2022-09-23 10:48:29 -04:00
2022-09-26 09:01:05 -04:00
2. Download the binary artifacts and corresponding signature files.
- from [bdk-jvm]
2022-11-14 10:54:06 -05:00
- `bdk-jvm-<version>.jar`
- `bdk-jvm-<version>.jar.asc`
2022-09-26 09:01:05 -04:00
- from [bdk-android]
2022-11-14 10:54:06 -05:00
- `bdk-android-<version>.aar`
- `bdk-android-<version>.aar.asc`
2022-09-23 10:48:29 -04:00
2022-09-26 09:01:05 -04:00
3. Verify the signatures.
```shell
gpg --verify bdk-jvm-< version > .jar.asc
gpg --verify bdk-android-< version > .aar.asc
2022-09-23 10:48:29 -04:00
2022-09-26 09:01:05 -04:00
# you should see a "Good signature" result
gpg: Good signature from "bitcoindevkit-bindings < bindings @bitcoindevkit .org > " [unknown]
2022-09-23 10:48:29 -04:00
```
### PGP Metadata
Full key ID: `88AD 93AC 4589 FD09 0FF3 B8D1 2768 C43E 8803 C6A3`
Fingerprint: `2768C43E8803C6A3`
Name: `bitcoindevkit-bindings`
2022-11-14 10:54:06 -05:00
Email: `bindings@bitcoindevkit.org`
2022-09-23 10:48:29 -04:00
2022-11-15 20:29:58 -05:00
## Thanks
This project is made possible thanks to the wonderful work by the [mozilla/uniffi-rs] team.
2021-12-14 08:24:41 -08:00
[Kotlin]: https://kotlinlang.org/
[Android Studio]: https://developer.android.com/studio/
[`bdk` ]: https://github.com/bitcoindevkit/bdk
[`bdk-ffi` ]: https://github.com/bitcoindevkit/bdk-ffi
["Getting Started (Developer)"]: https://github.com/bitcoindevkit/bdk-ffi#getting -started-developer
2022-11-15 20:29:58 -05:00
[bdk-jvm]: https://search.maven.org/artifact/org.bitcoindevkit/bdk-jvm/0.11.0/jar
[bdk-android]: https://search.maven.org/artifact/org.bitcoindevkit/bdk-android/0.11.0/aar
[bdk-jvm (Maven Central)]: https://central.sonatype.dev/artifact/org.bitcoindevkit/bdk-jvm/0.11.0
[bdk-android (Maven Central)]: https://central.sonatype.dev/artifact/org.bitcoindevkit/bdk-android/0.11.0
[bdk-swift (GitHub)]: https://github.com/bitcoindevkit/bdk-swift
[bdk-python (PyPI)]: https://pypi.org/project/bdkpython/
2022-11-14 10:54:06 -05:00
[mozilla/uniffi-rs]: https://github.com/mozilla/uniffi-rs
2022-11-15 20:29:58 -05:00
[bdk]: https://github.com/bitcoindevkit/bdk
[Bitcoin Dev Kit]: https://github.com/bitcoindevkit
[uniffi-rs]: https://github.com/mozilla/uniffi-rs
[Readme bdk-jvm]: https://github.com/bitcoindevkit/bdk-ffi/tree/master/bdk-jvm
[Readme bdk-android]: https://github.com/bitcoindevkit/bdk-ffi/tree/master/bdk-android
[Readme bdk-swift]: https://github.com/bitcoindevkit/bdk-swift
[Readme bdk-python]: https://github.com/bitcoindevkit/bdk-ffi/tree/master/bdk-python
[Kotlin JVM API Docs]: https://bitcoindevkit.org/jvm/
[Android API Docs]: https://bitcoindevkit.org/android/