-
Notifications
You must be signed in to change notification settings - Fork 4
LDK Feedback & Questions #1
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
base: just-for-discusssion-of-code
Are you sure you want to change the base?
Changes from all commits
9a96a81
4468478
152c64e
56887e8
bfdda06
c5d2fca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "ldk"] | ||
| path = ldk | ||
| url = https://github.com/lightningdevkit/ldk-garbagecollected.git | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /* | ||
| * Copyright 2007-present the original author or authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| import java.net.*; | ||
| import java.io.*; | ||
| import java.nio.channels.*; | ||
| import java.util.Properties; | ||
|
|
||
| public class MavenWrapperDownloader { | ||
|
|
||
| private static final String WRAPPER_VERSION = "0.5.6"; | ||
| /** | ||
| * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. | ||
| */ | ||
| private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" | ||
| + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; | ||
|
|
||
| /** | ||
| * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to | ||
| * use instead of the default one. | ||
| */ | ||
| private static final String MAVEN_WRAPPER_PROPERTIES_PATH = | ||
| ".mvn/wrapper/maven-wrapper.properties"; | ||
|
|
||
| /** | ||
| * Path where the maven-wrapper.jar will be saved to. | ||
| */ | ||
| private static final String MAVEN_WRAPPER_JAR_PATH = | ||
| ".mvn/wrapper/maven-wrapper.jar"; | ||
|
|
||
| /** | ||
| * Name of the property which should be used to override the default download url for the wrapper. | ||
| */ | ||
| private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; | ||
|
|
||
| public static void main(String args[]) { | ||
| System.out.println("- Downloader started"); | ||
| File baseDirectory = new File(args[0]); | ||
| System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); | ||
|
|
||
| // If the maven-wrapper.properties exists, read it and check if it contains a custom | ||
| // wrapperUrl parameter. | ||
| File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); | ||
| String url = DEFAULT_DOWNLOAD_URL; | ||
| if(mavenWrapperPropertyFile.exists()) { | ||
| FileInputStream mavenWrapperPropertyFileInputStream = null; | ||
| try { | ||
| mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); | ||
| Properties mavenWrapperProperties = new Properties(); | ||
| mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); | ||
| url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); | ||
| } catch (IOException e) { | ||
| System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); | ||
| } finally { | ||
| try { | ||
| if(mavenWrapperPropertyFileInputStream != null) { | ||
| mavenWrapperPropertyFileInputStream.close(); | ||
| } | ||
| } catch (IOException e) { | ||
| // Ignore ... | ||
| } | ||
| } | ||
| } | ||
| System.out.println("- Downloading from: " + url); | ||
|
|
||
| File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); | ||
| if(!outputFile.getParentFile().exists()) { | ||
| if(!outputFile.getParentFile().mkdirs()) { | ||
| System.out.println( | ||
| "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); | ||
| } | ||
| } | ||
| System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); | ||
| try { | ||
| downloadFileFromURL(url, outputFile); | ||
| System.out.println("Done"); | ||
| System.exit(0); | ||
| } catch (Throwable e) { | ||
| System.out.println("- Error downloading"); | ||
| e.printStackTrace(); | ||
| System.exit(1); | ||
| } | ||
| } | ||
|
|
||
| private static void downloadFileFromURL(String urlString, File destination) throws Exception { | ||
| if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { | ||
| String username = System.getenv("MVNW_USERNAME"); | ||
| char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); | ||
| Authenticator.setDefault(new Authenticator() { | ||
| @Override | ||
| protected PasswordAuthentication getPasswordAuthentication() { | ||
| return new PasswordAuthentication(username, password); | ||
| } | ||
| }); | ||
| } | ||
| URL website = new URL(urlString); | ||
| ReadableByteChannel rbc; | ||
| rbc = Channels.newChannel(website.openStream()); | ||
| FileOutputStream fos = new FileOutputStream(destination); | ||
| fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); | ||
| fos.close(); | ||
| rbc.close(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip | ||
| wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,10 @@ | ||
| # ldk-sample-java | ||
| sample implementation of LDK for Java (https://github.com/lightningdevkit/ldk-garbagecollected) | ||
|
|
||
| ## Status / Purpose | ||
|
|
||
| This repository contains a sample implementation of LDK as the result of following the steps described in [Building a Node with LDK in Java](https://lightningdevkit.org/docs/build_node). | ||
| Its main purpose is providing feedback to the LDK developers. | ||
| Therefore: | ||
| * code quality / maintainability is bad | ||
| * **do NOT use this implementation in production** |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <parent> | ||
| <artifactId>ldk-parent</artifactId> | ||
| <groupId>com.getlipa</groupId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>ldk-sample</artifactId> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.ldk</groupId> | ||
| <artifactId>ldk-java</artifactId> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be much more convenient to have LDK on Maven Central (https://search.maven.org/). See also: https://central.sonatype.org/publish/publish-guide/ Moreover, we could assist with publishing to Maven Central / OSSRH as we have some experience in this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are now published on Central under org.lightningdevkit, artifact ldk-java!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, I will certainly try out building with ldk as a Maven dependency. I guess this would also solve the issue with the failing test, since all necessary binaries are included (besides that ldk tests are no longer executed when imported as a Maven dependency), right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it should include the release binaries for Apple amd64/A-1 and Linux amd64. I can include other platforms as needed, though windows will be a pain.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess Windows is pretty much always a pain 😜 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you need it I can work on a windows build, its probably less effort than OSX was :).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We currently have no need for a Windows build, thanks :) |
||
| <version>1.0-SNAPSHOT</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.bitcoinj</groupId> | ||
| <artifactId>bitcoinj-core</artifactId> | ||
| <version>0.15.10</version> | ||
| <scope>compile</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.squareup.okhttp3</groupId> | ||
| <artifactId>okhttp</artifactId> | ||
| <version>3.14.9</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.json</groupId> | ||
| <artifactId>json</artifactId> | ||
| <version>20140107</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| </project> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently use
v0.0.98.3of LDK since all newer versions have a failing test:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implies that a matching
liblightningjninative library was not found - how are you importing the LDK dependency and what platform are you running on?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LDK is declared as a Maven module
ldk:ldk-sample-java/pom.xml
Line 12 in c5d2fca
The
ldk-samplemodule then decalres it as a dependency:ldk-sample-java/ldk-sample/pom.xml
Lines 15 to 19 in c5d2fca
Tests are run either through the parent module by
LD_LIBRARY_PATH=$PWD/ldk ./mvnw verifyor within theldkmodule / directory directly byLD_LIBRARY_PATH=$PWD mvn verify. Both lead to the same test failure mentioned in the initial comment.The platform is a
Ubuntu 20.04.2 LTSwith kernel5.4.0-77-generic(x86_64) and Java11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible the files in
resourcesare being stripped by your build process? Note that theresourcesfiles are not included in the git tree, only in the release binaries (though you can fetch them directly from https://git.bitcoin.ninja/ldk-java-bins if you want).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since LDK is now on maven central, this one is no longer a real blocker. But maybe I will try to find out more anyway.