Skip to content

Add JVM bindings library #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ jobs:
- name: Check formatting
if: matrix.check-fmt
run: rustup component add rustfmt && cargo fmt --all -- --check
- name: Test on Rust ${{ matrix.toolchain }}
run: cargo test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

*.dylib

ldk_node.kt
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/ldk-node.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 47 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,66 @@
[package]
name = "ldk-lite"
name = "ldk-node"
version = "0.1.0"
authors = ["Elias Rohrer <[email protected]>"]
license = "MIT OR Apache-2.0"
edition = "2018"
description = "A ready-to-go node implementation based on LDK."

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["staticlib", "cdylib"]
name = "ldk_node"

[dependencies]
lightning = { version = "0.0.110", features = ["max_level_trace", "std"] }
lightning-invoice = { version = "0.18" }
lightning-net-tokio = { version = "0.0.110" }
lightning-persister = { version = "0.0.110" }
lightning-background-processor = { version = "0.0.110" }
lightning-rapid-gossip-sync = { version = "0.0.110" }
#lightning = { version = "0.0.112", features = ["max_level_trace", "std"] }
#lightning-invoice = { version = "0.20" }
#lightning-net-tokio = { version = "0.0.112" }
#lightning-persister = { version = "0.0.112" }
#lightning-background-processor = { version = "0.0.112" }
#lightning-rapid-gossip-sync = { version = "0.0.112" }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["max_level_trace", "std"] }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }

lightning = { git = "https://github.com/tnull/rust-lightning", branch="2022-11-add-transaction-sync-crate", features = ["max_level_trace", "std"] }
lightning-invoice = { git = "https://github.com/tnull/rust-lightning", branch="2022-11-add-transaction-sync-crate" }
lightning-net-tokio = { git = "https://github.com/tnull/rust-lightning", branch="2022-11-add-transaction-sync-crate" }
lightning-persister = { git = "https://github.com/tnull/rust-lightning", branch="2022-11-add-transaction-sync-crate" }
lightning-background-processor = { git = "https://github.com/tnull/rust-lightning", branch="2022-11-add-transaction-sync-crate" }
lightning-rapid-gossip-sync = { git = "https://github.com/tnull/rust-lightning", branch="2022-11-add-transaction-sync-crate" }
lightning-transaction-sync = { git = "https://github.com/tnull/rust-lightning", branch="2022-11-add-transaction-sync-crate", features = ["esplora-async"] }

#bdk = "0.20.0"
bdk = { git = "https://github.com/tnull/bdk", branch="feat/use-external-esplora-client", features = ["use-esplora-ureq", "key-value-db"]}
bitcoin = "0.28.1"
#lightning = { path = "../rust-lightning/lightning", features = ["max_level_trace", "std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor" }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }

bdk = { version = "0.26.0", default-features = false, features = ["async-interface", "use-esplora-async", "key-value-db"]}
bitcoin = "0.29.2"

rand = "0.8.5"
chrono = "0.4"
futures = "0.3"
serde_json = { version = "1.0" }
tokio = { version = "1", features = [ "io-util", "macros", "rt", "rt-multi-thread", "sync", "net", "time" ] }
tokio = { version = "1", features = [ "full" ] }
uniffi = { version = "0.21.0", features = ["builtin-bindgen"] }
uniffi_macros = { version = "0.21.0", features = ["builtin-bindgen"] }

[dev-dependencies]
electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_23_0"] }
electrum-client = "0.12.0"
once_cell = "1.16.0"

[build-dependencies]
uniffi_build = "0.21.0"

[profile.release]
panic = "abort"
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# ldk-lite
A Simplified API for LDK.

## Build and publish to local Maven repository
```shell
source uniffi_bindgen_generate_kotlin.sh
cd ldk-node-jvm
./gradlew publishToMavenLocal
```

## How to Use
To use the Kotlin language bindings for [`ldk-node`] in your JVM project, add the following to your gradle dependencies:
```kotlin
repositories {
mavenCentral()
}

dependencies {
implementation("org.ldk:ldk-node:0.0.1")
}
```

You may then import and use the `org.ldk_node` library in your Kotlin code. For example:
```kotlin
import uniffi.ldk_node.Builder
import uniffi.ldk_node.Node

fun main() {
val node: Node = Builder().build()
}
```
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
uniffi_build::generate_scaffolding("uniffi/ldk_node.udl").unwrap();
}
6 changes: 6 additions & 0 deletions ldk-node-jvm/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

7 changes: 7 additions & 0 deletions ldk-node-jvm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

.idea/
1 change: 1 addition & 0 deletions ldk-node-jvm/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libraryVersion=0.0.2
Binary file added ldk-node-jvm/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions ldk-node-jvm/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading