Skip to content

Commit 8701948

Browse files
authored
Merge pull request #85 from lightningj-org/support_lnd_0_16_2
Added support for LND 0.16.2 Added service ChainKit
2 parents 801d9f3 + 2b0691d commit 8701948

File tree

14 files changed

+321
-33
lines changed

14 files changed

+321
-33
lines changed

build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ plugins {
3838

3939
group 'org.lightningj'
4040

41-
version '0.16.0-Beta'
41+
version '0.16.2-Beta'
4242

4343
description = "LightningJ - Lightning APIs for Java"
4444

@@ -118,7 +118,7 @@ test {
118118
*/
119119
task generateWrappers(type: WrapperClassGenerator, dependsOn:compileJava){
120120
// When adding new protocols, remember to also add in WrapperFactory.
121-
protocols = ["lnrpc","autopilot","chainnotifier","invoices","router","signer","walletkit","watchtower","wtclient",
121+
protocols = ["lnrpc","autopilot","chainnotifier","chainkit","invoices","router","signer","walletkit","watchtower","wtclient",
122122
"verrpc", "walletunlocker","stateservice","dev","peers","neutrino"]
123123
}
124124

@@ -149,7 +149,7 @@ dependencies {
149149

150150
task generateXSD(type: XSDGenerator, dependsOn: compileWrapperMessages){
151151
classpath=compileJava.classpath.asPath
152-
protocols = ["lnrpc","autopilot","chainnotifier","invoices","router","signer","walletkit","watchtower","wtclient",
152+
protocols = ["lnrpc","autopilot","chainnotifier","chainkit","invoices","router","signer","walletkit","watchtower","wtclient",
153153
"verrpc","walletunlocker","stateservice","dev","peers","neutrino"]
154154
}
155155

@@ -178,7 +178,7 @@ asciidoctor {
178178
}
179179

180180

181-
task ('doc',type: Copy,dependsOn: [javadoc, asciidoctor, htmlDependencyReport, test]){
181+
task ('doc',type: Copy,dependsOn: [javadoc, asciidoctor, htmlDependencyReport, test, generateXSD]){
182182
from('build/docs/'){
183183
include('index.html')
184184
}

buildSrc/src/main/groovy/ProtocolSettings.groovy

+14
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class ProtocolSettings extends BaseProtocolSettings{
2929
return "org.lightningj.lnd.autopilot.proto.AutopilotOuterClass"
3030
case "chainnotifier":
3131
return "org.lightningj.lnd.chainnotifier.proto.ChainNotifierOuterClass"
32+
case "chainkit":
33+
return "org.lightningj.lnd.chainkit.proto.Chainkit"
3234
case "invoices":
3335
return "org.lightningj.lnd.invoices.proto.InvoicesOuterClass"
3436
case "router":
@@ -141,6 +143,17 @@ import org.lightningj.lnd.wrapper.message.FeatureBit;
141143
baseFileName: 'ChainNotifierAPI.java'
142144
)
143145
]
146+
case "chainkit":
147+
return [
148+
new ApiSettings(
149+
baseGrpcClassPath:'org.lightningj.lnd.chainkit.proto.ChainKitGrpc$ChainKit',
150+
grpcClassName: 'ChainKitGrpc ',
151+
baseApiClassName: 'ChainKitAPI',
152+
baseProtoClassPath: 'org.lightningj.lnd.chainkit.proto.ChainKit',
153+
baseStubClass: 'ChainKit',
154+
baseFileName: 'ChainKitAPI.java'
155+
)
156+
]
144157
case "invoices":
145158
return [
146159
new ApiSettings(
@@ -334,6 +347,7 @@ import org.lightningj.lnd.wrapper.message.FeatureBit;
334347
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/lndjapi_1_0", prefix = ""),
335348
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/autopilot_1_0", prefix = "autopilot"),
336349
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/chainnotifier_1_0", prefix = "chainnotifier"),
350+
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/chainkit_1_0", prefix = "chainkit"),
337351
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/invoices_1_0", prefix = "invoices"),
338352
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/router_1_0", prefix = "router"),
339353
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/signer_1_0", prefix = "signer"),

buildSrc/src/main/groovy/XSDGenerator.groovy

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class XSDGenerator extends DefaultTask{
5454
ByteArraySchemaOutputResolver sor = new ByteArraySchemaOutputResolver(protocolSettings.getXMLNameSpace())
5555
jaxbContext.generateSchema(sor)
5656

57-
project.file(generatedResourcesDir+ "/" + protocolSettings.getXSDName()).write(new String(sor.bytes,"UTF-8"))
57+
File xsdFile = new File(generatedResourcesDir+ "/" + protocolSettings.getXSDName())
58+
xsdFile.text = new String(sor.bytes,"UTF-8")
5859
}
5960
}
6061

docs/index.adoc

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ to the license agreement can be found link:LICENSE.txt[here].
4040

4141
== Whats New
4242

43+
* 0.16.2-Beta : Generated against LND 0.16.2 API, added support for ChainKit RPC Service.
4344
* 0.16.0-Beta : Generated against LND 0.16.0 API
4445
* 0.15.5-Beta : Generated against LND 0.15.5 and fix for NaN issue #79
4546
* 0.15.3-Beta : Major update, Generated against 0.15.3 and updated Gradle to 7.5.1.
@@ -538,6 +539,13 @@ XSD.
538539
| link:chainnotifier_v1.xsd[chainnotifier_v1.xsd]
539540
| 0.6-Beta-rc1
540541

542+
| ChainKit API
543+
| Contains methods for the chain kit service.
544+
| chainkit:
545+
| http://lightningj.org/xsd/chainkit_1_0
546+
| link:chainkit_v1.xsd[chainkit_v1.xsd]
547+
| 0.16.2-Beta
548+
541549
| Invoices API
542550
| Invoices is a service that can be used to create, accept, settle and cancel invoices
543551
| invoices:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/************************************************************************
2+
* *
3+
* LightningJ *
4+
* *
5+
* This software is free software; you can redistribute it and/or *
6+
* modify it under the terms of the GNU Lesser General Public License *
7+
* (LGPL-3.0-or-later) *
8+
* License as published by the Free Software Foundation; either *
9+
* version 3 of the License, or any later version. *
10+
* *
11+
* See terms of license at gnu.org. *
12+
* *
13+
*************************************************************************/
14+
package org.lightningj.lnd.wrapper.chainkit
15+
16+
17+
import spock.lang.Shared
18+
import spock.lang.Specification
19+
20+
/**
21+
* Integration tests running the chainkit client APIs against a live test-net LND node.
22+
*/
23+
class ChainKitIntegrationSpec extends Specification{
24+
25+
26+
@Shared String lndHost
27+
@Shared int lndPort
28+
@Shared File tlsCertPath
29+
@Shared File macaroonPath
30+
31+
SynchronousChainKitAPI synchronousAPI
32+
AsynchronousChainKitAPI asynchronousAPI
33+
34+
def setupSpec(){
35+
lndHost = System.getProperty("lightningj.integration.test.lnd.host")
36+
lndPort = Integer.parseInt(System.getProperty("lightningj.integration.test.lnd.port"))
37+
tlsCertPath = new File(System.getProperty("lightningj.integration.test.lnd.tlscertpath"))
38+
macaroonPath = new File(System.getProperty("lightningj.integration.test.lnd.macaroonpath"))
39+
}
40+
41+
def setup(){
42+
asynchronousAPI = new AsynchronousChainKitAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
43+
synchronousAPI = new SynchronousChainKitAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
44+
}
45+
46+
def "Test to verify chainkit api is available"(){
47+
expect:
48+
synchronousAPI.getBlockHash(123L) != null
49+
}
50+
51+
52+
}

src/integration-test/groovy/org/lightningj/lnd/wrapper/wtclient/WtclientIntegrationSpec.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class WtclientIntegrationSpec extends Specification{
4545

4646
def "Test to verify watchtower client api is available"(){
4747
expect:
48-
synchronousAPI.listTowers(true)
48+
synchronousAPI.listTowers(true,false)
4949
}
5050

5151

src/main/java/org/lightningj/lnd/wrapper/V1XMLParser.java

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ protected String[] getSchemaLocations() {
3838
"/lnd_v1.xsd",
3939
"/autopilot_v1.xsd",
4040
"/chainnotifier_v1.xsd",
41+
"/chainkit_v1.xsd",
4142
"/invoices_v1.xsd",
4243
"/router_v1.xsd",
4344
"/signer_v1.xsd",
@@ -61,6 +62,7 @@ protected String getJAXBClassPath() {
6162
return "org.lightningj.lnd.wrapper.message:" +
6263
"org.lightningj.lnd.wrapper.autopilot.message:"+
6364
"org.lightningj.lnd.wrapper.chainnotifier.message:"+
65+
"org.lightningj.lnd.wrapper.chainkit.message:"+
6466
"org.lightningj.lnd.wrapper.invoices.message:"+
6567
"org.lightningj.lnd.wrapper.router.message:"+
6668
"org.lightningj.lnd.wrapper.signer.message:"+

src/main/proto/chainkit.proto

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* This file is fetched from https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto
3+
* And is distributed under LNDs MIT License.
4+
* LND (561bf82) tag : Downloaded 2022-05-18
5+
*/
6+
syntax = "proto3";
7+
8+
package chainrpc;
9+
10+
option java_package = "org.lightningj.lnd.chainkit.proto";
11+
option go_package = "github.com/lightningnetwork/lnd/lnrpc/chainrpc";
12+
13+
// ChainKit is a service that can be used to get information from the
14+
// chain backend.
15+
service ChainKit {
16+
/* lncli: `chain getblock`
17+
GetBlock returns a block given the corresponding block hash.
18+
*/
19+
rpc GetBlock (GetBlockRequest) returns (GetBlockResponse);
20+
21+
/* lncli: `chain getbestblock`
22+
GetBestBlock returns the block hash and current height from the valid
23+
most-work chain.
24+
*/
25+
rpc GetBestBlock (GetBestBlockRequest) returns (GetBestBlockResponse);
26+
27+
/* lncli: `chain getblockhash`
28+
GetBlockHash returns the hash of the block in the best blockchain
29+
at the given height.
30+
*/
31+
rpc GetBlockHash (GetBlockHashRequest) returns (GetBlockHashResponse);
32+
}
33+
34+
message GetBlockRequest {
35+
// The hash of the requested block.
36+
bytes block_hash = 1;
37+
}
38+
39+
// TODO(ffranr): The neutrino GetBlock response includes many
40+
// additional helpful fields. Consider adding them here also.
41+
message GetBlockResponse {
42+
// The raw bytes of the requested block.
43+
bytes raw_block = 1;
44+
}
45+
46+
message GetBestBlockRequest {
47+
}
48+
49+
message GetBestBlockResponse {
50+
// The hash of the best block.
51+
bytes block_hash = 1;
52+
53+
// The height of the best block.
54+
int32 block_height = 2;
55+
}
56+
57+
message GetBlockHashRequest {
58+
// Block height of the target best chain block.
59+
int64 block_height = 1;
60+
}
61+
62+
message GetBlockHashResponse {
63+
// The hash of the best block at the specified height.
64+
bytes block_hash = 1;
65+
}

src/main/proto/lightning.api.proto

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This file is fetched from https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto
33
* And is distributed under LNDs MIT License.
4-
* LND (c26917e) tag : Downloaded 2023-03-30
4+
* LND (444bbfa) tag : Downloaded 2023-04-27
55
*/
66
syntax = "proto3";
77

@@ -1548,6 +1548,9 @@ message Channel {
15481548

15491549
// The configured alias name of our peer.
15501550
string peer_alias = 34;
1551+
1552+
// This is the peer SCID alias.
1553+
uint64 peer_scid_alias = 35 [jstype = JS_STRING];
15511554
}
15521555

15531556
message ListChannelsRequest {
@@ -2270,6 +2273,13 @@ message OpenChannelRequest {
22702273
capacity.
22712274
*/
22722275
uint64 remote_chan_reserve_sat = 25;
2276+
2277+
/*
2278+
If set, then lnd will attempt to commit all the coins under control of the
2279+
internal wallet to open the channel, and the LocalFundingAmount field must
2280+
be zero and is ignored.
2281+
*/
2282+
bool fund_max = 26;
22732283
}
22742284
message OpenStatusUpdate {
22752285
oneof update {

src/main/proto/wallet.kit.proto

+71-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This file is fetched from https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto
33
* And is distributed under LNDs MIT License.
4-
* LND (fd49640) tag : Downloaded 2023-03-30
4+
* LND (44dcfec) tag : Downloaded 2023-04-27
55
*/
66
syntax = "proto3";
77

@@ -869,6 +869,76 @@ enum WitnessType {
869869
transaction.
870870
*/
871871
COMMITMENT_ANCHOR = 13;
872+
873+
/*
874+
A witness type that is similar to the COMMITMENT_NO_DELAY type,
875+
but it omits the tweak that randomizes the key we need to
876+
spend with a channel peer supplied set of randomness.
877+
*/
878+
COMMITMENT_NO_DELAY_TWEAKLESS = 14;
879+
880+
/*
881+
A witness type that allows us to spend our output on the counterparty's
882+
commitment transaction after a confirmation.
883+
*/
884+
COMMITMENT_TO_REMOTE_CONFIRMED = 15;
885+
886+
/*
887+
A witness type that allows us to sweep an HTLC output that we extended
888+
to a party, but was never fulfilled. This _is_ the HTLC output directly
889+
on our commitment transaction, and the input to the second-level HTLC
890+
timeout transaction. It can only be spent after CLTV expiry, and
891+
commitment confirmation.
892+
*/
893+
HTLC_OFFERED_TIMEOUT_SECOND_LEVEL_INPUT_CONFIRMED = 16;
894+
895+
/*
896+
A witness type that allows us to sweep an HTLC output that was offered
897+
to us, and for which we have a payment preimage. This _is_ the HTLC
898+
output directly on our commitment transaction, and the input to the
899+
second-level HTLC success transaction. It can only be spent after the
900+
commitment has confirmed.
901+
*/
902+
HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL_INPUT_CONFIRMED = 17;
903+
904+
/*
905+
A witness type that allows us to spend our output on our local
906+
commitment transaction after a relative and absolute lock-time lockout as
907+
part of the script enforced lease commitment type.
908+
*/
909+
LEASE_COMMITMENT_TIME_LOCK = 18;
910+
911+
/*
912+
A witness type that allows us to spend our output on the counterparty's
913+
commitment transaction after a confirmation and absolute locktime as part
914+
of the script enforced lease commitment type.
915+
*/
916+
LEASE_COMMITMENT_TO_REMOTE_CONFIRMED = 19;
917+
918+
/*
919+
A witness type that allows us to sweep an HTLC output that we extended
920+
to a party, but was never fulfilled. This HTLC output isn't directly on
921+
the commitment transaction, but is the result of a confirmed second-level
922+
HTLC transaction. As a result, we can only spend this after a CSV delay
923+
and CLTV locktime as part of the script enforced lease commitment type.
924+
*/
925+
LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL = 20;
926+
927+
/*
928+
A witness type that allows us to sweep an HTLC output that was offered
929+
to us, and for which we have a payment preimage. This HTLC output isn't
930+
directly on our commitment transaction, but is the result of confirmed
931+
second-level HTLC transaction. As a result, we can only spend this after
932+
a CSV delay and CLTV locktime as part of the script enforced lease
933+
commitment type.
934+
*/
935+
LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL = 21;
936+
937+
/*
938+
A witness type that allows us to spend a regular p2tr output that's sent
939+
to an output which is under complete control of the backing wallet.
940+
*/
941+
TAPROOT_PUB_KEY_SPEND = 22;
872942
}
873943

874944
message PendingSweep {

0 commit comments

Comments
 (0)