Skip to content

Commit dea9b3c

Browse files
authored
Merge pull request #73 from lightningj-org/support_lnd_0_15_0
Added support for LND 0.15.0 and added APs for peers, neutrino and dev.
2 parents 0959796 + bf1dc9d commit dea9b3c

File tree

22 files changed

+1389
-65
lines changed

22 files changed

+1389
-65
lines changed

build.gradle

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
group 'org.lightningj'
22

3-
version '0.14.3-Beta'
3+
version '0.15.0-Beta'
44

55
apply plugin: "groovy"
66
apply plugin: 'com.google.protobuf'
@@ -117,7 +117,8 @@ compileJava {
117117
*/
118118
task generateWrappers(type: WrapperClassGenerator, dependsOn:compileJava){
119119
// When adding new protocols, remember to also add in WrapperFactory.
120-
protocols = ["lnrpc","autopilot","chainnotifier","invoices","router","signer","walletkit","watchtower","wtclient","verrpc", "walletunlocker","stateservice"]
120+
protocols = ["lnrpc","autopilot","chainnotifier","invoices","router","signer","walletkit","watchtower","wtclient",
121+
"verrpc", "walletunlocker","stateservice","dev","peers","neutrino"]
121122
}
122123

123124
/*
@@ -144,7 +145,8 @@ dependencies {
144145

145146
task generateXSD(type: XSDGenerator, dependsOn: compileWrapperMessages){
146147
classpath=compileJava.classpath.asPath
147-
protocols = ["lnrpc","autopilot","chainnotifier","invoices","router","signer","walletkit","watchtower","wtclient","verrpc","walletunlocker","stateservice"]
148+
protocols = ["lnrpc","autopilot","chainnotifier","invoices","router","signer","walletkit","watchtower","wtclient",
149+
"verrpc","walletunlocker","stateservice","dev","peers","neutrino"]
148150
}
149151

150152
/*

buildSrc/src/main/groovy/ProtocolSettings.groovy

+62-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ class ProtocolSettings extends BaseProtocolSettings{
4747
return "org.lightningj.lnd.walletunlocker.proto.Walletunlocker"
4848
case "stateservice":
4949
return "org.lightningj.lnd.stateservice.proto.Stateservice"
50+
case "dev":
51+
return "org.lightningj.lnd.dev.proto.DevOuterClass"
52+
case "peers":
53+
return "org.lightningj.lnd.peers.proto.PeersOuterClass"
54+
case "neutrino":
55+
return "org.lightningj.lnd.neutrino.proto.Neutrino"
5056
}
5157
}
5258

@@ -83,6 +89,17 @@ import org.lightningj.lnd.wrapper.message.ChannelPoint;
8389
case "walletunlocker":
8490
return """
8591
import org.lightningj.lnd.wrapper.message.ChanBackupSnapshot;
92+
"""
93+
case "dev":
94+
return """
95+
import org.lightningj.lnd.wrapper.message.LightningNode;
96+
import org.lightningj.lnd.wrapper.message.ChannelEdge;
97+
import org.lightningj.lnd.wrapper.message.ChannelGraph;
98+
"""
99+
case "peers":
100+
return """
101+
import org.lightningj.lnd.wrapper.message.Op;
102+
import org.lightningj.lnd.wrapper.message.FeatureBit;
86103
"""
87104
default:
88105
return ""
@@ -223,6 +240,39 @@ import org.lightningj.lnd.wrapper.message.ChanBackupSnapshot;
223240
baseFileName: 'StateServiceAPI.java'
224241
)
225242
]
243+
case "dev":
244+
return [
245+
new ApiSettings(
246+
baseGrpcClassPath:'org.lightningj.lnd.dev.proto.DevGrpc$Dev',
247+
grpcClassName: 'DevGrpc',
248+
baseApiClassName: 'DevAPI',
249+
baseProtoClassPath: 'org.lightningj.lnd.dev.proto.DevOuterClass',
250+
baseStubClass: 'Dev',
251+
baseFileName: 'DevAPI.java'
252+
)
253+
]
254+
case "peers":
255+
return [
256+
new ApiSettings(
257+
baseGrpcClassPath:'org.lightningj.lnd.peers.proto.PeersGrpc$Peers',
258+
grpcClassName: 'PeersGrpc',
259+
baseApiClassName: 'PeersAPI',
260+
baseProtoClassPath: 'org.lightningj.lnd.peers.proto.PeersOuterClass',
261+
baseStubClass: 'Peers',
262+
baseFileName: 'PeersAPI.java'
263+
)
264+
]
265+
case "neutrino":
266+
return [
267+
new ApiSettings(
268+
baseGrpcClassPath:'org.lightningj.lnd.neutrino.proto.NeutrinoKitGrpc$NeutrinoKit',
269+
grpcClassName: 'NeutrinoKitGrpc',
270+
baseApiClassName: 'NeutrinoAPI',
271+
baseProtoClassPath: 'org.lightningj.lnd.neutrino.proto.Neutrino',
272+
baseStubClass: 'NeutrinoKit',
273+
baseFileName: 'NeutrinoAPI.java'
274+
)
275+
]
226276
default:
227277
return []
228278
}
@@ -242,6 +292,10 @@ import org.lightningj.lnd.wrapper.message.ChanBackupSnapshot;
242292
"KeyLocator" : "org.lightningj.lnd.signer.proto.SignerOuterClass",
243293
"TxOut" : "org.lightningj.lnd.signer.proto.SignerOuterClass"
244294
]
295+
case "dev":
296+
return [
297+
"ChannelGraph" : "org.lightningj.lnd.proto.LightningApi"
298+
]
245299
default:
246300
return [:]
247301
}
@@ -263,6 +317,10 @@ import org.lightningj.lnd.wrapper.message.ChanBackupSnapshot;
263317
if(methodName == "sendPaymentV2" || methodName == "trackPaymentV2" || methodName == "sendToRouteV2"){
264318
return "LightningApi"
265319
}
320+
case "dev":
321+
if(methodName == "importGraph"){
322+
return "DevOuterClass"
323+
}
266324
}
267325
return null
268326
}
@@ -284,7 +342,10 @@ import org.lightningj.lnd.wrapper.message.ChanBackupSnapshot;
284342
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/wtclient_1_0", prefix = "wtclient"),
285343
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/verrpc_1_0", prefix = "verrpc"),
286344
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/walletunlocker_1_0", prefix = "walletunlocker"),
287-
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/stateservice_1_0", prefix = "stateservice")
345+
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/stateservice_1_0", prefix = "stateservice"),
346+
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/dev_1_0", prefix = "dev"),
347+
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/neutrino_1_0", prefix = "neutrino"),
348+
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/peers_1_0", prefix = "peers")
288349
"""
289350
}
290351

docs/index.adoc

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

4242
== Whats New
4343

44+
* 0.15.0-Beta : Generated against LND 0.15.0 API, Added Dev, Peers and Neutrino RPC APIs.
4445
* 0.14.3-Beta : Generated against LND 0.14.3 API
4546
* 0.14.2-Beta : Generated against LND 0.14.2 API
4647
* 0.14.1-Beta : Generated against LND 0.14.0 and 0.14.1 API
@@ -390,12 +391,29 @@ Starting from 0.6.0 there are several different APIs to the different services.
390391
| org.lightningj.lnd.wrapper.verrpc.AsynchronousVersionerAPI
391392
| 0.10-Beta-rc2
392393

394+
| Peers API
395+
| Contains methods for the peers (peerrpc) service.
396+
| org.lightningj.lnd.wrapper.peers.SynchronousPeersAPI
397+
| org.lightningj.lnd.wrapper.peers.AsynchronousPeersAPI
398+
| 0.15.0-Beta
399+
400+
| Neutrino API
401+
| Contains methods for the neutrino (neutrinrpc) service.
402+
| org.lightningj.lnd.wrapper.neutrino.SynchronousNeutrinoAPI
403+
| org.lightningj.lnd.wrapper.neutrino.AsynchronousNeutrinoAPI
404+
| 0.15.0-Beta
405+
406+
| Dev API
407+
| Contains methods for the dev (devrpc) service.
408+
| org.lightningj.lnd.wrapper.dev.SynchronousDevAPI
409+
| org.lightningj.lnd.wrapper.dev.AsynchronousDevAPI
410+
| 0.15.0-Beta
393411

394412
|===
395413

396414
=== Json Conversion
397415

398-
The libarary uses the JSR 374 javax.json api to generate and parse JSON.
416+
The library uses the JSR 374 javax.json api to generate and parse JSON.
399417

400418
To convert between JSON and High Level API object is pretty straight forward as shown
401419
in following example:
@@ -543,6 +561,28 @@ XSD.
543561
| link:walletkit_v1.xsd[walletkit_v1.xsd]
544562
| 0.6-Beta-rc1
545563

564+
| Peers API
565+
| Contains methods for the peers service.
566+
| peers:
567+
| http://lightningj.org/xsd/peers_1_0
568+
| link:peers_v1.xsd[peers_v1.xsd]
569+
| 0.15.0-Beta
570+
571+
| Neutrino API
572+
| Contains methods for the neutrino service.
573+
| peers:
574+
| http://lightningj.org/xsd/neutrino_1_0
575+
| link:neutrino_v1.xsd[neutrino_v1.xsd]
576+
| 0.15.0-Beta
577+
578+
| Dev API
579+
| Contains methods for the dev service.
580+
| peers:
581+
| http://lightningj.org/xsd/dev_1_0
582+
| link:dev_v1.xsd[dev_v1.xsd]
583+
| 0.15.0-Beta
584+
585+
546586
|===
547587

548588
=== Validation
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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.dev
15+
16+
17+
import org.lightningj.lnd.wrapper.peers.AsynchronousPeersAPI
18+
import org.lightningj.lnd.wrapper.peers.SynchronousPeersAPI
19+
import spock.lang.Shared
20+
import spock.lang.Specification
21+
22+
/**
23+
* Integration tests running the nautrino APIs against a live test-net LND node.
24+
*/
25+
class DevIntegrationSpec extends Specification{
26+
27+
@Shared String lndHost
28+
@Shared int lndPort
29+
@Shared File tlsCertPath
30+
@Shared File macaroonPath
31+
32+
SynchronousDevAPI synchronousAPI
33+
AsynchronousDevAPI asynchronousAPI
34+
35+
def setupSpec(){
36+
lndHost = System.getProperty("lightningj.integration.test.lnd.host")
37+
lndPort = Integer.parseInt(System.getProperty("lightningj.integration.test.lnd.port"))
38+
tlsCertPath = new File(System.getProperty("lightningj.integration.test.lnd.tlscertpath"))
39+
macaroonPath = new File(System.getProperty("lightningj.integration.test.lnd.macaroonpath"))
40+
}
41+
42+
def setup(){
43+
asynchronousAPI = new AsynchronousDevAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
44+
synchronousAPI = new SynchronousDevAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
45+
}
46+
47+
def "Test to verify dev api is available"(){
48+
expect:
49+
synchronousAPI.importGraph([],[])
50+
}
51+
52+
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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.neutrino
15+
16+
17+
import org.lightningj.lnd.wrapper.autopilot.AsynchronousAutopilotAPI
18+
import org.lightningj.lnd.wrapper.autopilot.SynchronousAutopilotAPI
19+
import spock.lang.Shared
20+
import spock.lang.Specification
21+
22+
/**
23+
* Integration tests running the nautrino APIs against a live test-net LND node.
24+
*/
25+
class NeutrinoIntegrationSpec extends Specification{
26+
27+
@Shared String lndHost
28+
@Shared int lndPort
29+
@Shared File tlsCertPath
30+
@Shared File macaroonPath
31+
32+
SynchronousNeutrinoAPI synchronousAPI
33+
AsynchronousNeutrinoAPI asynchronousAPI
34+
35+
def setupSpec(){
36+
lndHost = System.getProperty("lightningj.integration.test.lnd.host")
37+
lndPort = Integer.parseInt(System.getProperty("lightningj.integration.test.lnd.port"))
38+
tlsCertPath = new File(System.getProperty("lightningj.integration.test.lnd.tlscertpath"))
39+
macaroonPath = new File(System.getProperty("lightningj.integration.test.lnd.macaroonpath"))
40+
}
41+
42+
def setup(){
43+
asynchronousAPI = new AsynchronousNeutrinoAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
44+
synchronousAPI = new SynchronousNeutrinoAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
45+
}
46+
47+
//@Ignore // Wait until proper instructions on how to enable to API.
48+
def "Test to verify neutrino api is available"(){
49+
expect:
50+
synchronousAPI.status() != null
51+
}
52+
53+
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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.peers
15+
16+
17+
import org.lightningj.lnd.wrapper.neutrino.AsynchronousNeutrinoAPI
18+
import org.lightningj.lnd.wrapper.neutrino.SynchronousNeutrinoAPI
19+
import org.lightningj.lnd.wrapper.peers.message.UpdateAddressAction
20+
import org.lightningj.lnd.wrapper.peers.message.UpdateFeatureAction
21+
import spock.lang.Shared
22+
import spock.lang.Specification
23+
24+
import java.security.SecureRandom
25+
26+
/**
27+
* Integration tests running the nautrino APIs against a live test-net LND node.
28+
*/
29+
class PeersIntegrationSpec extends Specification{
30+
31+
@Shared String lndHost
32+
@Shared int lndPort
33+
@Shared File tlsCertPath
34+
@Shared File macaroonPath
35+
36+
SynchronousPeersAPI synchronousAPI
37+
AsynchronousPeersAPI asynchronousAPI
38+
39+
def setupSpec(){
40+
lndHost = System.getProperty("lightningj.integration.test.lnd.host")
41+
lndPort = Integer.parseInt(System.getProperty("lightningj.integration.test.lnd.port"))
42+
tlsCertPath = new File(System.getProperty("lightningj.integration.test.lnd.tlscertpath"))
43+
macaroonPath = new File(System.getProperty("lightningj.integration.test.lnd.macaroonpath"))
44+
}
45+
46+
def setup(){
47+
asynchronousAPI = new AsynchronousPeersAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
48+
synchronousAPI = new SynchronousPeersAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
49+
}
50+
51+
//@Ignore // Wait until proper instructions on how to enable to API.
52+
def "Test to verify peers api is available"(){
53+
expect:
54+
synchronousAPI.updateNodeAnnouncement([],null,randomString(),[])
55+
}
56+
57+
static final char[] AliasCharset = "abcdefghijklmnopqrstqvst".toCharArray()
58+
59+
String randomString(){
60+
char[] retval = new char[10]
61+
for(int i=0;i<10;i++){
62+
retval[i] = AliasCharset[SecureRandom.getInstanceStrong().nextInt(AliasCharset.length-1)]
63+
}
64+
return new String(retval)
65+
}
66+
67+
68+
}

0 commit comments

Comments
 (0)