2022-03-19 11:11:44 -04:00
2022-02-04 14:32:18 -06:00
2022-03-17 13:38:59 -05:00
2022-03-19 11:11:44 -04:00
2021-10-16 14:45:32 +05:30
2022-02-28 22:14:17 -08:00
2022-02-28 22:14:17 -08:00
2022-02-28 22:14:17 -08:00
2022-03-17 16:10:23 -05:00
2022-01-24 10:35:56 -08:00

bdk-kotlin

This project builds .jar and .aar packages for the jvm and android platforms that provide Kotlin language bindings for the bdk library. The Kotlin language bindings are created by the bdk-ffi project which is included as a git submodule of this repository.

How to Use

To use the Kotlin language bindings for bdk in your jvm or android project add the following to your gradle dependencies:

repositories {
    mavenCentral()
}

dependencies {
  
  // for jvm
  implementation 'org.bitcoindevkit:bdk-jvm:<version>'
  // OR for android
  implementation 'org.bitcoindevkit:bdk-android:<version>'
  
}

You may then import and use the org.bitcoindevkit library in your Kotlin code. For example:

import org.bitcoindevkit.*

// ...

val externalDescriptor = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)"
val internalDescriptor = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/1/*)"

val databaseConfig = DatabaseConfig.Memory

val blockchainConfig =
  BlockchainConfig.Electrum(
    ElectrumConfig("ssl://electrum.blockstream.info:60002", null, 5u, null, 10u)
  )
val wallet = Wallet(externalDescriptor, internalDescriptor, Network.TESTNET, databaseConfig, blockchainConfig)
val newAddress = wallet.getNewAddress()

Example Projects

bdk-android

bdk-jvm

How to build

Note that Kotlin version 1.6.10 or later is required to build the library.

  1. Clone this repository and init and update it's bdk-ffi submodule.
    git clone https://github.com/bitcoindevkit/bdk-kotlin
    git submodule update --init
    
  2. Follow the "General" bdk-ffi "Getting Started (Developer)" instructions.
  3. If building on MacOS install required intel and m1 jvm targets
    rustup target add x86_64-apple-darwin aarch64-apple-darwin
    
  4. Install required targets
    rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android
    
  5. Install uniffi-bindgen
    cargo install uniffi_bindgen --version 0.16.0
    
    See the UniFFI User Guide for more info
  6. Install Android SDK and Build-Tools for API level 30+
  7. Setup $ANDROID_SDK_ROOT and $ANDROID_NDK_HOME path variables (which are required by the build scripts), for example (NDK major version 21 is required):
    export ANDROID_SDK_ROOT=~/Android/Sdk
    export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/21.<NDK_VERSION>
    
  8. Build kotlin bindings
    ./build.sh
    
  9. Start android emulator and run tests
    ./gradlew connectedAndroidTest 
    

How to publish

Publish to your local maven repo

  1. Set your ~/.gradle/gradle.properties signing key values
    signing.gnupg.keyName=<YOUR_GNUPG_ID>
    signing.gnupg.passphrase=<YOUR_GNUPG_PASSPHRASE>
    
  2. Publish
    ./gradlew :jvm:publishToMavenLocal
    ./gradlew :android:publishToMavenLocal
    

Note that if you do not have gpg keys set up to sign the publication, the task will fail. If you wish to publish to your local Maven repository for local testing without signing the release, you can do so by excluding the signMavenPublication subtask like so:

./gradlew :jvm:publishToMavenLocal --exclude-task signMavenPublication
./gradlew :android:publishToMavenLocal --exclude-task signMavenPublication

Publish to maven central with Gradle Nexus Publish Plugin (project maintainers only)

  1. Set your ~/.gradle/gradle.properties signing key values and SONATYPE login
    signing.gnupg.keyName=<YOUR_GNUPG_ID>
    signing.gnupg.passphrase=<YOUR_GNUPG_PASSPHRASE>
    
    ossrhUserName=<YOUR_SONATYPE_USERNAME>
    ossrhPassword=<YOUR_SONATYPE_PASSWORD>
    
  2. Publish
    ./gradlew :jvm:publishToSonatype closeAndReleaseSonatypeStagingRepository
    ./gradlew :android:publishToSonatype closeAndReleaseSonatypeStagingRepository
    
Description
Frost experimentation on bdk-ffi
Readme 22 MiB
Languages
Rust 64.6%
Kotlin 18.1%
Swift 9.5%
Python 4.6%
Shell 2.2%
Other 1%