diff --git a/docs/grpc/java.md b/docs/grpc/java.md index d3c291e6c..933ff1ac1 100644 --- a/docs/grpc/java.md +++ b/docs/grpc/java.md @@ -19,10 +19,6 @@ with lnd in Java. We'll be using Maven as our build tool. ├── java │ └── Main.java ├── proto - ├── google - │ └── api - │ ├── annotations.proto - │ └── http.proto └── lnrpc └── lightning.proto @@ -30,13 +26,11 @@ with lnd in Java. We'll be using Maven as our build tool. Note the ***proto*** folder, where all the proto files are kept. - [lightning.proto](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/lightning.proto) - - [annotations.proto](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/third_party/googleapis/google/api/annotations.proto) - - [http.proto](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/third_party/googleapis/google/api/http.proto) #### pom.xml ```xml - 1.8.0 + 1.36.0 ``` The following dependencies are required. @@ -60,7 +54,7 @@ The following dependencies are required. io.netty netty-tcnative-boringssl-static - 2.0.7.Final + 2.0.28.Final commons-codec @@ -76,16 +70,16 @@ In the build section, we'll need to configure the following things : kr.motd.maven os-maven-plugin - 1.5.0.Final + 1.6.2.Final org.xolstice.maven.plugins protobuf-maven-plugin - 0.5.0 + 0.6.1 - com.google.protobuf:protoc:3.4.0:exe:${os.detected.classifier} + com.google.protobuf:protoc:3.12.0:exe:${os.detected.classifier} grpc-java io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} @@ -129,36 +123,30 @@ import java.nio.file.Paths; import java.util.concurrent.Executor; public class Main { - static class MacaroonCallCredential implements CallCredentials { + static class MacaroonCallCredential extends CallCredentials { private final String macaroon; MacaroonCallCredential(String macaroon) { this.macaroon = macaroon; } - public void thisUsesUnstableApi() {} - - public void applyRequestMetadata( - MethodDescriptor < ? , ? > methodDescriptor, - Attributes attributes, - Executor executor, - final MetadataApplier metadataApplier - ) { - String authority = attributes.get(ATTR_AUTHORITY); - System.out.println(authority); - executor.execute(new Runnable() { - public void run() { - try { - Metadata headers = new Metadata(); - Metadata.Key < String > macaroonKey = Metadata.Key.of("macaroon", Metadata.ASCII_STRING_MARSHALLER); - headers.put(macaroonKey, macaroon); - metadataApplier.apply(headers); - } catch (Throwable e) { - metadataApplier.fail(Status.UNAUTHENTICATED.withCause(e)); - } + @Override + public void applyRequestMetadata(RequestInfo requestInfo, Executor executor, MetadataApplier metadataApplier) { + executor.execute(() -> { + try { + Metadata headers = new Metadata(); + Metadata.Key macaroonKey = Metadata.Key.of("macaroon", Metadata.ASCII_STRING_MARSHALLER); + headers.put(macaroonKey, macaroon); + metadataApplier.apply(headers); + } catch (Throwable e) { + metadataApplier.fail(Status.UNAUTHENTICATED.withCause(e)); } }); } + + @Override + public void thisUsesUnstableApi() { + } } private static final String CERT_PATH = "/Users/user/Library/Application Support/Lnd/tls.cert"; @@ -199,19 +187,19 @@ Execute the following command in the directory where the **pom.xml** file is loc [INFO] ------------------------------------------------------------------------ [INFO] os.detected.name: osx [INFO] os.detected.arch: x86_64 -[INFO] os.detected.version: 10.13 +[INFO] os.detected.version: 10.15 [INFO] os.detected.version.major: 10 -[INFO] os.detected.version.minor: 13 +[INFO] os.detected.version.minor: 15 [INFO] os.detected.classifier: osx-x86_64 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building lightning-client 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] -[INFO] --- protobuf-maven-plugin:0.5.0:compile (default) @ lightning-client --- +[INFO] --- protobuf-maven-plugin:0.6.1:compile (default) @ lightning-client --- [INFO] Compiling 3 proto file(s) to /Users/user/Documents/Projects/lightningclient/target/generated-sources/protobuf/java [INFO] -[INFO] --- protobuf-maven-plugin:0.5.0:compile-custom (default) @ lightning-client --- +[INFO] --- protobuf-maven-plugin:0.6.1:compile-custom (default) @ lightning-client --- [INFO] Compiling 3 proto file(s) to /Users/user/Documents/Projects/lightningclient/target/generated-sources/protobuf/grpc-java [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lightning-client ---