Kotlin jvm + android packages for bdk-ffi

Overview

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

  1. Install required targets
    rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android
  2. Install Android SDK and Build-Tools for API level 30+
  3. 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    
  4. Build kotlin bindings
    ./build.sh

How to 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:publishReleasePublicationToMavenLocal
    ./gradlew :android:publishReleasePublicationToMavenLocal

How to publish to maven central (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
Comments
  • Convert Gradle script plugin for generating UniFfi bindings into a composite build.

    Convert Gradle script plugin for generating UniFfi bindings into a composite build.

    Description

    buildSrc has a major drawback of invalidating entire project's cache after a chance in the buildSrc itself. This is a probably not a big issue for the project of this size, but a way to fix this is to implement plugin as a standalone, composite build, which also happens to be a more idiomatic way of implementing plugins.

    Notes to the reviewers

    These are the rough steps that I took for converting the plugin:

    1. . Create new standalone plugins Gradle module for the plugin
    2. Create two new UniFfiJvmPlugin and UniFfiAndroidPlugin Gradle plugin classes, copy-and-pasting existing script plugin implementations
    3. Register two new plugins using the same IDs as convention plugins: org.bitcoindevkit.plugins.generate-jvm-bindings and org.bitcoindevkit.plugins.generate-android-bindings
    4. Delete buildSrc

    All Submissions:

    opened by kirillzh 9
  • Publish sources and javadoc for bdk-android

    Publish sources and javadoc for bdk-android

    Problem

    It seems that sources and javadocs for bdk-android are not being generated and published to maven: https://repo1.maven.org/maven2/org/bitcoindevkit/bdk-android/0.4.0.

    Description

    When using bdk-android as a library in your project it's not currently possible to look up source code and documentation of bdk-android because sources and javadocs are not being generated and published.

    With AGP 7.1.0 publishing Android sources and javadocs is very simple, we can use that https://developer.android.com/studio/releases/gradle-plugin#build-variant-publishing.

    Alternatives

    No response

    enhancement 
    opened by kirillzh 9
  • Update bdk-ffi to 0.5 (with TxBuilder APIs)

    Update bdk-ffi to 0.5 (with TxBuilder APIs)

    Description

    Update bdk-ffi to https://github.com/bitcoindevkit/bdk-ffi/pull/123 and add new TxBuilder tests.

    Notes to the reviewers

    I also fixed tests to use network and addresses for TESTNET to match BlockchainConfig.

    The tests must be a bit hacky until we have a way to use REGTEST for our Kotlin tests.

    Checklists

    All Submissions:

    • [x] I've signed all my commits
    • [x] I followed the contribution guidelines
    • [x] I ran cargo fmt and cargo clippy before committing

    New Features:

    • [x] I've added tests for the new feature
    • [x] I've added docs for the new feature
    • [ ] I've updated CHANGELOG.md
    opened by notmandatory 7
  • Add temporary API docs

    Add temporary API docs

    Description

    This PR adds a directory that contains the required files to build the API docs for bdk-android and bdk-jvm. The docs need to be updated and published once a release.

    Notes to the reviewers

    After getting comments on how specific-language API docs are useful in dev calls, I add these (albeit in a temporary fashion). We don't know how long it will be before the ability to use inline documentation is added to uniffi-rs, and so for the foreseeable future this is a good solution that will allow us to publish Kotlin API docs that work well and look good, and keep track of them in the same repository as the libraries themselves. I fully expect to remove this directory once the new workflows are in.

    All Submissions:

    documentation 
    opened by thunderbiscuit 5
  • Add Gradle plugin for building libraries

    Add Gradle plugin for building libraries

    Description

    This PR adds two internal Gradle plugins which live in the buildSrc directory. The purpose of the plugins is to replace the build.sh script by a more idiomatic and customizable workflow using Gradle tasks.

    Notes to the reviewers

    By default the :android:buildAndroidLib task will build all versions of bdk-android, which currently are the arm64-v8a (for mobile devices) and the x86_64 (for emulators).

    Users can opt out of a particular build if they'd like by excluding the task like so:

    ./gradlew :android:buildAndroidLib --exclude-task buildAndroidX86_64Binary
    

    This PR is open as a discussion piece on the direction I am taking for implementing the next iteration of our build logic.

    To test the plugins, first see that the tasks have been added using ./gradlew tasks, which should add the Bitcoindevkit group to the list of Gradle tasks:

    gradle

    Then run either tasks to build the given library:

    ./gradlew :jvm:buildJvmLib
    ./gradlew :android:buildAndroidLib
    

    All Submissions:

    • [x] I've signed all my commits

    New Features:

    • [ ] I've added tests for the new feature
    • [x] I've added docs for the new feature
    opened by thunderbiscuit 5
  • Remove compiler option to suppress warnings for using experimental unsigned types

    Remove compiler option to suppress warnings for using experimental unsigned types

    The following block is no longer necessary as of Kotlin 1.5 (we're currently using 1.6.10):

    allprojects {
        tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
            kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.ExperimentalUnsignedTypes"
        }
    }
    

    See uniffi-rs docs here and related merged PR here for more info.

    I can't assign myself but @notmandatory feel free to assign me this one.

    opened by thunderbiscuit 5
  • Migrate project-level Gradle build script to Kotlin DSL

    Migrate project-level Gradle build script to Kotlin DSL

    Description

    Migrating the Gradle build scripts to Kotlin DSL.

    Fixes #9

    Notes to the reviewers

    I have not tested the publishing workflow.

    All Submissions:

    • [x] I've signed all my commits
    opened by thunderbiscuit 5
  • Update README and build.sh script to use latest env var naming.

    Update README and build.sh script to use latest env var naming.

    Description

    ANDROID_HOME, ANDROID_SDK_HOME, and ANDROID_NDK_HOME are not used by the Android platform and SDK tools so these are considered deprecated/invalid.

    Google recommends using ANDROID_SDK_ROOT and ANDROID_NDK_ROOT instead:

    • https://groups.google.com/g/android-ndk/c/qZjhOaynHXc/m/2ux2ZZdxy2MJ
    • https://developer.android.com/studio/command-line/variables

    All Submissions:

    • [x] I've signed all my commits
    • [x] I followed the contribution guidelines
    • [x] I ran cargo fmt and cargo clippy before committing
    opened by kirillzh 4
  • Make signature optional for local maven publishing

    Make signature optional for local maven publishing

    I think forcing contributors to set up gpg signatures to simply test/deploy the library locally might be an unnecessary friction we could easily remove.

    opened by thunderbiscuit 4
  • API docs

    API docs

    Problem

    It would be great to be able to generate library docs.

    Description

    I might have a working solution on this branch of my repo.

    The workflow is as follows:

    1. create a fresh bindings file
    2. apply the patch docs.patch using patch jvm/src/main/kotlin/org/bitcoindevkit/bdk.kt docs.patch
    3. generate the website using ./gradlew :jvm:dokkaHtml

    The main question I have and the reason I have not put too much time in trying to port over all of the docs and polishing the current branch is that the patch does not seem to apply that easily, and I don't know to which extent the addition of a new API changes the bindings file. If the changes are extensive, I assume the patch will not work, and I'm still looking at a good way to fix that (like some interactive way using a GUI maybe), because at the moment when the patch fails it just... fails miserably but doesn't tell you much about why and where.

    See the current state of the docs here: bdk-android: https://thunderbiscuit.github.io/bdk-android-api-docs/ bdk-jvm: https://thunderbiscuit.github.io/bdk-jvm-api-docs/

    Honestly they look pretty good! The question is whether changes will always completely break them or if the process can be streamlined well.

    enhancement 
    opened by thunderbiscuit 4
  • Add group and version properties for nexus publishing plugin

    Add group and version properties for nexus publishing plugin

    This PR is a cherry-pick of 6c904cd26e6d994ab7e529856f580541d97a7a89 and 579c7cb07e2dc61a229d5f34ff775d680299d49b that adds the group and version properties to the root build.gradle.kts file. These properties are required for the nexus publish-plugin to work properly.

    It also makes the default publishing workflow publish entirely instead of only to the staging repo.

    Related to this PR is issue bitcoindevkit/bdk-ffi#234.

    opened by thunderbiscuit 3
Releases(v0.10.1)
  • v0.10.1(Nov 3, 2022)

    Summary

    This release updates the BDK 0.23 rust-bitcoin dependency to 0.28.2 which includes backported changes from rust-bitcoin 0.29 that fix an issue where some specific transactions and/or blocks fail to deserialize.

    Source code(tar.gz)
    Source code(zip)
  • v0.8.0(Sep 9, 2022)

    NOTE: artifacts are published on maven central as version 0.8.2 due to issues while publishing.

    What's Changed

    • Add GitHub issue and PR templates by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/6
    • Fix pull request template by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/7
    • Add Devkit Wallet link by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/8
    • Build JVM bdk-ffi libs for macos m1 by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/5
    • Add step to install uniffi-bindgen on README by @caiofaustino in https://github.com/bitcoindevkit/bdk-kotlin/pull/3
    • Update bdk-ffi version to v0.3.0, test PartiallySignedBitcoinTransaction serialization by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/14
    • Migrate project-level Gradle build script to Kotlin DSL by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/10
    • Release 0.4.0 by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/15
    • Add license files by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/16
    • Remove compiler option for experimental unsigned types by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/17
    • Add sqlite database option by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/19
    • Add documentation on how to skip signing task for local Maven by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/22
    • Fix Wallet.broadcast function, now returns a tx id as a hex string by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/23
    • Add javadocs to jvm build by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/25
    • Fix database memory test by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/26
    • Add basic CI workflow that runs tests on pull requests by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/28
    • Update README and build.sh script to use latest env var naming. by @kirillzh in https://github.com/bitcoindevkit/bdk-kotlin/pull/34
    • Add CI steps to build bdk-ffi libraries by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/38
    • #32: Enable publishing bdk-android sources and java docs by @kirillzh in https://github.com/bitcoindevkit/bdk-kotlin/pull/33
    • Add API docs by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/31
    • Add library version to API docs by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/43
    • Update bdk-ffi to 0.5 (with TxBuilder APIs) by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/40
    • Fix dokka theme bug with AGP by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/49
    • Add Gradle plugin for building libraries by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/37
    • Update to bdk-ffi 0.6.0 (remove Blockchain from Wallet) by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/54
    • Bump version to 0.7.0-SNAPSHOT by @notmandatory in https://github.com/bitcoindevkit/bdk-kotlin/pull/56
    • Build both x86_64 and aarch64 binaries when building bdk-jvm on macOS by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/58
    • Bump bdk-ffi submodule to 0.7.0 and update tests by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/62
    • feat: updated gitmodule to use HTTPS by @darkvoid32 in https://github.com/bitcoindevkit/bdk-kotlin/pull/60
    • add armeabi-v7a support by @nicbus in https://github.com/bitcoindevkit/bdk-kotlin/pull/63
    • Bump version to 0.8.0-SNAPSHOT by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/67
    • Remove install of uniffi-bindgen in CI workflow by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/65
    • Bump bdk-ffi submodule to version 0.8.0 by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/70
    • Bump version to 0.8.0 by @thunderbiscuit in https://github.com/bitcoindevkit/bdk-kotlin/pull/73

    New Contributors

    • @caiofaustino made their first contribution in https://github.com/bitcoindevkit/bdk-kotlin/pull/3
    • @darkvoid32 made their first contribution in https://github.com/bitcoindevkit/bdk-kotlin/pull/60
    • @nicbus made their first contribution in https://github.com/bitcoindevkit/bdk-kotlin/pull/63

    Full Changelog: https://github.com/bitcoindevkit/bdk-kotlin/compare/v0.3.2...v0.8.0

    Source code(tar.gz)
    Source code(zip)
  • v0.7.1(Jun 28, 2022)

  • v0.7.0(Jun 18, 2022)

    General

    Update bdk-ffi to 0.7.0, which relies on BDK version 0.19.0

    • Fixes sqlite-db issue causing wrong balance
    • Adds experimental taproot descriptor and PSBT support

    APIs Removed

    • Wallet.getNewAddress(), returned String, https://github.com/bitcoindevkit/bdk-ffi/pull/137
    • Wallet.getLastUnusedAddress(), returned String https://github.com/bitcoindevkit/bdk-ffi/pull/137

    APIs Added

    • Wallet.getAddress(AddressIndex), returns AddressInfo, which contains an address (String) and an index (UInt) https://github.com/bitcoindevkit/bdk-ffi/pull/137

    APIs Changed

    • Wallet.sign(PartiallySignedBitcoinTransaction) now returns a Boolean, true if the PSBT is finalized, false if it's only a partial signature and the PSBT is not ready for broadcast https://github.com/bitcoindevkit/bdk-ffi/pull/161

    NOTE

    This release is broken on maven central for bdk-jvm. Use 0.7.1 instead.

    Source code(tar.gz)
    Source code(zip)
  • v0.5.2(Apr 16, 2022)

  • v0.5.1(Apr 16, 2022)

Owner
Bitcoin Dev Kit
The Bitcoin Dev Kit project (formerly Magical Bitcoin 🧙) is building tools and libraries designed to be a solid foundation for descriptor based Bitcoin wallets
Bitcoin Dev Kit
Create libraries for all types of Kotlin projects: android, JVM, Multiplatform, Gradle plugins, and so on.

JavierSC Kotlin template Create libraries for all types of Kotlin projects: android, JVM, Multiplatform, Gradle plugins, and so on. Features Easy to p

Javier Segovia Córdoba 2 Dec 14, 2022
Kotlin SDK for Jellyfin supporting Android and the JVM.

Jellyfin Kotlin SDK Part of the Jellyfin Project The Jellyfin Kotlin SDK is a library implementing the Jellyfin API to easily access servers. It is cu

Jellyfin 60 Dec 18, 2022
An implementation of MediatR on JVM for Spring using Kotlin coroutines

Kpring MediatR In this project, an attempt has been made to implement the mediator pattern on the JVM with simplicity using Kotlin with native corouti

Mahdi Bohloul 4 Aug 6, 2022
Asynchronous Spring Initializr API wrapper for Kotlin/JVM

initializr-kt Asynchronous Spring Initializr API wrapper for Kotlin/JVM. This library provides the simplest DSL for initializing Spring Boot projects

Mikhail Titov 2 May 8, 2022
A simple, lightweight, non-bloated redis client for kotlin and other JVM languages

rekt is a lightweight, non-bloated redis client, primarily written for the kotlin programming language, while also supporting other JVM-based languages, such as Java, Scala, and obviously way more.

Patrick 8 Nov 2, 2022
Depenject - a lightweight, minimalistic dependency injection library for Kotlin/JVM.

depenject depenject is a lightweight, minimalistic dependency injection library for Kotlin/JVM. Our goal is similar to flavor's to simplify the usage

Patrick 1 Mar 22, 2022
StarkNet SDK for JVM languages (java, kotlin, scala)

☕ starknet jvm ☕ StarkNet SDK for JVM languages: Java Kotlin Scala Clojure Groovy Table of contents Documentation Example usages Making synchronous re

Software Mansion 29 Dec 15, 2022
Archimedes's implementation for the Java Virtual Machine (JVM)

Archimedes Give me a place to stand, and I shall move the earth. Archimedes's implementation for the Java Virtual Machine (JVM) Building From Source T

Archimedes 24 Aug 20, 2022
Utility library dedicated for functional & non-functional codebases to simplify modelling of success and failure responses for the JVM languages 🔀

Expressible Utility library, part of the panda-lang SDK, dedicated for functional codebases that require enhanced response handling. Express yourself

Panda 28 Nov 14, 2022
JVM Open Asset Import Library (Assimp)

assimp JVM porting of Assimp This port is being written trying to stick as much as possible close to the C version in order to: minimize maintenance t

null 83 Oct 30, 2022
Collection of JVM library logic that the Sirloin software development team is currently using

Collection of JVM library logic that the Sirloin software development team is currently using

Sirloin Dev 4 May 10, 2022
This is the interpreter of Hime language, a dialect of Lisp, run on JVM platform.

Hime Language About This is the interpreter of Hime language, a dialect of Lisp, running on JVM platform. Once a feature is finished and tested, and n

Hime Programming Language 8 Jul 12, 2022
Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Kotlin_practice_problems Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Aman 0 Oct 14, 2021
Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP)

Mockative Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP). Installation Mockative uses KSP to generate

Mockative 121 Dec 26, 2022
Kotlin-oop - Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura.

Projeto React OOP Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura

Marcos Felipe 1 Jan 5, 2022
Kotlin-koans - Kotlin Koans are a series of exercises to get you familiar with the Kotlin Syntax

kotlin-koans-edu Kotlin Koans are a series of exercises to get you familiar with

null 1 Jan 11, 2022
Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

Mohammadali Rezaei 7 Nov 28, 2022
🎲 Kotlin Symbol Processor to auto-generate extensive sealed classes and interfaces for Android and Kotlin.

SealedX ?? Kotlin Symbol Processor to auto-generate extensive sealed classes and interfaces for Android and Kotlin. Why SealedX? SealedX generates ext

Jaewoong Eum 236 Nov 30, 2022
Clean Android multi-module offline-first scalable app in 2022. Including Jetpack Compose, MVI, Kotlin coroutines/Flow, Kotlin serialization, Hilt and Room.

Android Kotlin starter project - 2022 edition Android starter project, described precisely in this article. Purpose To show good practices using Kotli

Krzysztof Dąbrowski 176 Jan 3, 2023