This project builds a .jar package for the JVM platform that provide Kotlin language bindings for the bdk
library. The Kotlin language bindings are created by the bdk-ffi
project which is included in the root of this repository.
To use the Kotlin language bindings for bdk
in your JVM project add the following to your gradle dependencies:
repositories {
mavenCentral()
}
dependencies {
implementation("org.bitcoindevkit:bdk-jvm:<version>")
}
You may then import and use the org.bitcoindevkit
library in your Kotlin code. For example:
import org.bitcoindevkit.*
// ...
val externalDescriptor = Descriptor("wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", Network.TESTNET)
val internalDescriptor = Descriptor("wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/1/*)", Network.TESTNET)
val databaseConfig = DatabaseConfig.Memory
val blockchainConfig = BlockchainConfig.Electrum(
ElectrumConfig("ssl://electrum.blockstream.info:60002", null, 5u, null, 10u, true)
)
val wallet = Wallet(externalDescriptor, internalDescriptor, Network.TESTNET, databaseConfig, blockchainConfig)
val newAddress = wallet.getAddress(AddressIndex.LastUnused)
To use a snapshot release, specify the snapshot repository url in the repositories
block and use the snapshot version in the dependencies
block:
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
implementation("org.bitcoindevkit:bdk-jvm:<version-SNAPSHOT>")
}
Note that Kotlin version 1.6.10
or later is required to build the library.
- Clone this repository.
git clone https://github.com/bitcoindevkit/bdk-ffi
- Follow the "General" bdk-ffi ["Getting Started (Developer)"] instructions.
- If building on macOS install required intel and m1 jvm targets
rustup target add x86_64-apple-darwin aarch64-apple-darwin
- Build kotlin bindings
# build JVM library
./gradlew buildJvmLib
cd bdk-jvm
./gradlew publishToMavenLocal --exclude-task signMavenPublication
Note that the commands assume you don't need the local libraries to be signed. If you do wish to sign them, simply set your ~/.gradle/gradle.properties
signing key values like so:
signing.gnupg.keyName=<YOUR_GNUPG_ID>
signing.gnupg.passphrase=<YOUR_GNUPG_PASSPHRASE>
and use the publishToMavenLocal
task without excluding the signing task:
./gradlew publishToMavenLocal
Depending on the JVM version you use, you might not have the JNA dependency on your classpath. The exception thrown will be
class file for com.sun.jna.Pointer not found
The solution is to add JNA as a dependency like so:
dependencies {
// ...
implementation("net.java.dev.jna:jna:5.12.1")
}
Temporary line: needed to run CI