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:0.2.0'
// OR for android
implementation 'org.bitcoindevkit:bdk-android:0.2.0'
}
You may then import and use the org.bitcoindevkit
library in your Kotlin code. For example:
import org.bitcoindevkit.*
// ...
val descriptor = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)"
val db = DatabaseConfig.Memory("")
val client =
BlockchainConfig.Electrum(
ElectrumConfig("ssl://electrum.blockstream.info:60002", null, 5u, null, 10u)
)
val wallet = OnlineWallet(descriptor, null, Network.TESTNET, db, client)
val newAddress = wallet.getNewAddress()
How to build
- 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_SDK_ROOT
and$ANDROID_NDK_HOME
path variables (which are required by the build scripts), for example:export ANDROID_SDK_ROOT=~/Android/Sdk export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/21.3.6528147
- Build kotlin bindings
./build.sh
How to publish to your local maven repo
- Set your
~/.gradle/gradle.properties
signing key valuessigning.gnupg.keyName=<YOUR_GNUPG_ID> signing.gnupg.passphrase=<YOUR_GNUPG_PASSPHRASE>
- Publish
./gradlew :jvm:publishReleasePublicationToMavenLocal ./gradlew :android:publishReleasePublicationToMavenLocal
How to publish to maven central (project maintainers only)
- Set your
~/.gradle/gradle.properties
signing key values and SONATYPE loginsigning.gnupg.keyName=<YOUR_GNUPG_ID> signing.gnupg.passphrase=<YOUR_GNUPG_PASSPHRASE> ossrhUserName=<YOUR_SONATYPE_USERNAME> ossrhPassword=<YOUR_SONATYPE_PASSWORD>
- Publish
./gradlew :jvm:publishToSonatype closeAndReleaseSonatypeStagingRepository ./gradlew :android:publishToSonatype closeAndReleaseSonatypeStagingRepository