Skip to content

Commit

Permalink
Merge pull request #85 from lightningj-org/support_lnd_0_16_2
Browse files Browse the repository at this point in the history
Added support for LND 0.16.2
Added service ChainKit
  • Loading branch information
herrvendil committed May 18, 2023
2 parents 801d9f3 + 2b0691d commit 8701948
Show file tree
Hide file tree
Showing 14 changed files with 321 additions and 33 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ plugins {

group 'org.lightningj'

version '0.16.0-Beta'
version '0.16.2-Beta'

description = "LightningJ - Lightning APIs for Java"

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

Expand Down Expand Up @@ -149,7 +149,7 @@ dependencies {

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

Expand Down Expand Up @@ -178,7 +178,7 @@ asciidoctor {
}


task ('doc',type: Copy,dependsOn: [javadoc, asciidoctor, htmlDependencyReport, test]){
task ('doc',type: Copy,dependsOn: [javadoc, asciidoctor, htmlDependencyReport, test, generateXSD]){
from('build/docs/'){
include('index.html')
}
Expand Down
14 changes: 14 additions & 0 deletions buildSrc/src/main/groovy/ProtocolSettings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class ProtocolSettings extends BaseProtocolSettings{
return "org.lightningj.lnd.autopilot.proto.AutopilotOuterClass"
case "chainnotifier":
return "org.lightningj.lnd.chainnotifier.proto.ChainNotifierOuterClass"
case "chainkit":
return "org.lightningj.lnd.chainkit.proto.Chainkit"
case "invoices":
return "org.lightningj.lnd.invoices.proto.InvoicesOuterClass"
case "router":
Expand Down Expand Up @@ -141,6 +143,17 @@ import org.lightningj.lnd.wrapper.message.FeatureBit;
baseFileName: 'ChainNotifierAPI.java'
)
]
case "chainkit":
return [
new ApiSettings(
baseGrpcClassPath:'org.lightningj.lnd.chainkit.proto.ChainKitGrpc$ChainKit',
grpcClassName: 'ChainKitGrpc ',
baseApiClassName: 'ChainKitAPI',
baseProtoClassPath: 'org.lightningj.lnd.chainkit.proto.ChainKit',
baseStubClass: 'ChainKit',
baseFileName: 'ChainKitAPI.java'
)
]
case "invoices":
return [
new ApiSettings(
Expand Down Expand Up @@ -334,6 +347,7 @@ import org.lightningj.lnd.wrapper.message.FeatureBit;
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/lndjapi_1_0", prefix = ""),
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/autopilot_1_0", prefix = "autopilot"),
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/chainnotifier_1_0", prefix = "chainnotifier"),
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/chainkit_1_0", prefix = "chainkit"),
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/invoices_1_0", prefix = "invoices"),
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/router_1_0", prefix = "router"),
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "http://lightningj.org/xsd/signer_1_0", prefix = "signer"),
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/groovy/XSDGenerator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class XSDGenerator extends DefaultTask{
ByteArraySchemaOutputResolver sor = new ByteArraySchemaOutputResolver(protocolSettings.getXMLNameSpace())
jaxbContext.generateSchema(sor)

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

Expand Down
8 changes: 8 additions & 0 deletions docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ to the license agreement can be found link:LICENSE.txt[here].

== Whats New

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

| ChainKit API
| Contains methods for the chain kit service.
| chainkit:
| http://lightningj.org/xsd/chainkit_1_0
| link:chainkit_v1.xsd[chainkit_v1.xsd]
| 0.16.2-Beta

| Invoices API
| Invoices is a service that can be used to create, accept, settle and cancel invoices
| invoices:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/************************************************************************
* *
* LightningJ *
* *
* This software is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* (LGPL-3.0-or-later) *
* License as published by the Free Software Foundation; either *
* version 3 of the License, or any later version. *
* *
* See terms of license at gnu.org. *
* *
*************************************************************************/
package org.lightningj.lnd.wrapper.chainkit


import spock.lang.Shared
import spock.lang.Specification

/**
* Integration tests running the chainkit client APIs against a live test-net LND node.
*/
class ChainKitIntegrationSpec extends Specification{


@Shared String lndHost
@Shared int lndPort
@Shared File tlsCertPath
@Shared File macaroonPath

SynchronousChainKitAPI synchronousAPI
AsynchronousChainKitAPI asynchronousAPI

def setupSpec(){
lndHost = System.getProperty("lightningj.integration.test.lnd.host")
lndPort = Integer.parseInt(System.getProperty("lightningj.integration.test.lnd.port"))
tlsCertPath = new File(System.getProperty("lightningj.integration.test.lnd.tlscertpath"))
macaroonPath = new File(System.getProperty("lightningj.integration.test.lnd.macaroonpath"))
}

def setup(){
asynchronousAPI = new AsynchronousChainKitAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
synchronousAPI = new SynchronousChainKitAPI(lndHost,lndPort,tlsCertPath, macaroonPath)
}

def "Test to verify chainkit api is available"(){
expect:
synchronousAPI.getBlockHash(123L) != null
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class WtclientIntegrationSpec extends Specification{

def "Test to verify watchtower client api is available"(){
expect:
synchronousAPI.listTowers(true)
synchronousAPI.listTowers(true,false)
}


Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/lightningj/lnd/wrapper/V1XMLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected String[] getSchemaLocations() {
"/lnd_v1.xsd",
"/autopilot_v1.xsd",
"/chainnotifier_v1.xsd",
"/chainkit_v1.xsd",
"/invoices_v1.xsd",
"/router_v1.xsd",
"/signer_v1.xsd",
Expand All @@ -61,6 +62,7 @@ protected String getJAXBClassPath() {
return "org.lightningj.lnd.wrapper.message:" +
"org.lightningj.lnd.wrapper.autopilot.message:"+
"org.lightningj.lnd.wrapper.chainnotifier.message:"+
"org.lightningj.lnd.wrapper.chainkit.message:"+
"org.lightningj.lnd.wrapper.invoices.message:"+
"org.lightningj.lnd.wrapper.router.message:"+
"org.lightningj.lnd.wrapper.signer.message:"+
Expand Down
65 changes: 65 additions & 0 deletions src/main/proto/chainkit.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* This file is fetched from https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto
* And is distributed under LNDs MIT License.
* LND (561bf82) tag : Downloaded 2022-05-18
*/
syntax = "proto3";

package chainrpc;

option java_package = "org.lightningj.lnd.chainkit.proto";
option go_package = "github.com/lightningnetwork/lnd/lnrpc/chainrpc";

// ChainKit is a service that can be used to get information from the
// chain backend.
service ChainKit {
/* lncli: `chain getblock`
GetBlock returns a block given the corresponding block hash.
*/
rpc GetBlock (GetBlockRequest) returns (GetBlockResponse);

/* lncli: `chain getbestblock`
GetBestBlock returns the block hash and current height from the valid
most-work chain.
*/
rpc GetBestBlock (GetBestBlockRequest) returns (GetBestBlockResponse);

/* lncli: `chain getblockhash`
GetBlockHash returns the hash of the block in the best blockchain
at the given height.
*/
rpc GetBlockHash (GetBlockHashRequest) returns (GetBlockHashResponse);
}

message GetBlockRequest {
// The hash of the requested block.
bytes block_hash = 1;
}

// TODO(ffranr): The neutrino GetBlock response includes many
// additional helpful fields. Consider adding them here also.
message GetBlockResponse {
// The raw bytes of the requested block.
bytes raw_block = 1;
}

message GetBestBlockRequest {
}

message GetBestBlockResponse {
// The hash of the best block.
bytes block_hash = 1;

// The height of the best block.
int32 block_height = 2;
}

message GetBlockHashRequest {
// Block height of the target best chain block.
int64 block_height = 1;
}

message GetBlockHashResponse {
// The hash of the best block at the specified height.
bytes block_hash = 1;
}
12 changes: 11 additions & 1 deletion src/main/proto/lightning.api.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* This file is fetched from https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto
* And is distributed under LNDs MIT License.
* LND (c26917e) tag : Downloaded 2023-03-30
* LND (444bbfa) tag : Downloaded 2023-04-27
*/
syntax = "proto3";

Expand Down Expand Up @@ -1548,6 +1548,9 @@ message Channel {

// The configured alias name of our peer.
string peer_alias = 34;

// This is the peer SCID alias.
uint64 peer_scid_alias = 35 [jstype = JS_STRING];
}

message ListChannelsRequest {
Expand Down Expand Up @@ -2270,6 +2273,13 @@ message OpenChannelRequest {
capacity.
*/
uint64 remote_chan_reserve_sat = 25;

/*
If set, then lnd will attempt to commit all the coins under control of the
internal wallet to open the channel, and the LocalFundingAmount field must
be zero and is ignored.
*/
bool fund_max = 26;
}
message OpenStatusUpdate {
oneof update {
Expand Down
72 changes: 71 additions & 1 deletion src/main/proto/wallet.kit.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* This file is fetched from https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto
* And is distributed under LNDs MIT License.
* LND (fd49640) tag : Downloaded 2023-03-30
* LND (44dcfec) tag : Downloaded 2023-04-27
*/
syntax = "proto3";

Expand Down Expand Up @@ -869,6 +869,76 @@ enum WitnessType {
transaction.
*/
COMMITMENT_ANCHOR = 13;

/*
A witness type that is similar to the COMMITMENT_NO_DELAY type,
but it omits the tweak that randomizes the key we need to
spend with a channel peer supplied set of randomness.
*/
COMMITMENT_NO_DELAY_TWEAKLESS = 14;

/*
A witness type that allows us to spend our output on the counterparty's
commitment transaction after a confirmation.
*/
COMMITMENT_TO_REMOTE_CONFIRMED = 15;

/*
A witness type that allows us to sweep an HTLC output that we extended
to a party, but was never fulfilled. This _is_ the HTLC output directly
on our commitment transaction, and the input to the second-level HTLC
timeout transaction. It can only be spent after CLTV expiry, and
commitment confirmation.
*/
HTLC_OFFERED_TIMEOUT_SECOND_LEVEL_INPUT_CONFIRMED = 16;

/*
A witness type that allows us to sweep an HTLC output that was offered
to us, and for which we have a payment preimage. This _is_ the HTLC
output directly on our commitment transaction, and the input to the
second-level HTLC success transaction. It can only be spent after the
commitment has confirmed.
*/
HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL_INPUT_CONFIRMED = 17;

/*
A witness type that allows us to spend our output on our local
commitment transaction after a relative and absolute lock-time lockout as
part of the script enforced lease commitment type.
*/
LEASE_COMMITMENT_TIME_LOCK = 18;

/*
A witness type that allows us to spend our output on the counterparty's
commitment transaction after a confirmation and absolute locktime as part
of the script enforced lease commitment type.
*/
LEASE_COMMITMENT_TO_REMOTE_CONFIRMED = 19;

/*
A witness type that allows us to sweep an HTLC output that we extended
to a party, but was never fulfilled. This HTLC output isn't directly on
the commitment transaction, but is the result of a confirmed second-level
HTLC transaction. As a result, we can only spend this after a CSV delay
and CLTV locktime as part of the script enforced lease commitment type.
*/
LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL = 20;

/*
A witness type that allows us to sweep an HTLC output that was offered
to us, and for which we have a payment preimage. This HTLC output isn't
directly on our commitment transaction, but is the result of confirmed
second-level HTLC transaction. As a result, we can only spend this after
a CSV delay and CLTV locktime as part of the script enforced lease
commitment type.
*/
LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL = 21;

/*
A witness type that allows us to spend a regular p2tr output that's sent
to an output which is under complete control of the backing wallet.
*/
TAPROOT_PUB_KEY_SPEND = 22;
}

message PendingSweep {
Expand Down
Loading

0 comments on commit 8701948

Please sign in to comment.