Remove unnecesary dependencies

This commit is contained in:
Raymond Sebetoa 2024-08-19 13:57:20 +02:00
parent 3ec3a3a4e1
commit ea983cf990
4 changed files with 15 additions and 44 deletions

View File

@ -116,12 +116,12 @@ kotlin {
dependencies { dependencies {
implementation("com.github.raymond98.lightning-kmp:lightning-kmp:v1.6.2-FEECREDIT-8") implementation("com.github.raymond98.lightning-kmp:lightning-kmp:v1.6.2-FEECREDIT-8")
implementation("org.bytedeco:javacpp:1.5.10") //implementation("org.bytedeco:javacpp:1.5.10")
implementation("com.github.maven-nar:nar-maven-plugin:3.10.1") //implementation("com.github.maven-nar:nar-maven-plugin:3.10.1")
api("fr.acinq.bitcoin:bitcoin-kmp:${Versions.bitcoinKmpVersion}") //api("fr.acinq.bitcoin:bitcoin-kmp:${Versions.bitcoinKmpVersion}")
api("co.touchlab:kermit:${Versions.kermitLoggerVersion}") //api("co.touchlab:kermit:${Versions.kermitLoggerVersion}")
api("org.jetbrains.kotlinx:kotlinx-datetime:${Versions.datetimeVersion}") //api("org.jetbrains.kotlinx:kotlinx-datetime:${Versions.datetimeVersion}")
api(ktor("network")) api(ktor("network"))
api(ktor("network-tls")) api(ktor("network-tls"))
@ -148,7 +148,7 @@ kotlin {
jvmMain { jvmMain {
dependencies { dependencies {
implementation("app.cash.sqldelight:sqlite-driver:${Versions.sqlDelight}") implementation("app.cash.sqldelight:sqlite-driver:${Versions.sqlDelight}")
implementation("fr.acinq.secp256k1:secp256k1-kmp-jni-jvm:${Versions.secpJniJvmVersion}") //implementation("fr.acinq.secp256k1:secp256k1-kmp-jni-jvm:${Versions.secpJniJvmVersion}")
implementation(ktor("client-okhttp")) implementation(ktor("client-okhttp"))
implementation("ch.qos.logback:logback-classic:1.2.3") implementation("ch.qos.logback:logback-classic:1.2.3")
} }
@ -214,7 +214,7 @@ application {
mainClass = "fr.acinq.lightning.bin.MainKt" mainClass = "fr.acinq.lightning.bin.MainKt"
// Set java.library.path to include the directory where the shared library is generated // Set java.library.path to include the directory where the shared library is generated
applicationDefaultJvmArgs = listOf("-Djava.library.path=${project.buildDir}/libs") applicationDefaultJvmArgs = listOf("-Djava.library.path=${layout.buildDirectory.dir("libs").get().asFile.absolutePath}")
} }
/*val cliScripts by tasks.register("cliScripts", CreateStartScripts::class) { /*val cliScripts by tasks.register("cliScripts", CreateStartScripts::class) {
@ -232,7 +232,7 @@ val compileNative by tasks.register<Exec>("compileNative") {
group = "build" group = "build"
description = "Compile the native C++ code into a shared library and package it into a .nar file" description = "Compile the native C++ code into a shared library and package it into a .nar file"
val outputDir = file("${project.buildDir}/libs") val outputDir = layout.buildDirectory.dir("libs").get().asFile
val nativeSourceDir = file("src/commonMain/kotlin/fr/acinq/lightning/vsock/native") val nativeSourceDir = file("src/commonMain/kotlin/fr/acinq/lightning/vsock/native")
// Locate the JNI headers - adjust these paths based on your actual JDK location // Locate the JNI headers - adjust these paths based on your actual JDK location
@ -245,22 +245,6 @@ val compileNative by tasks.register<Exec>("compileNative") {
// Compile the shared library // Compile the shared library
commandLine("g++", "-I$jniIncludeDir", "-I$jniPlatformIncludeDir", "-shared", "-o", outputDir.resolve("libjniVSockImpl.so"), nativeSourceDir.resolve("VSockImpl.cpp"), "-fPIC") commandLine("g++", "-I$jniIncludeDir", "-I$jniPlatformIncludeDir", "-shared", "-o", outputDir.resolve("libjniVSockImpl.so"), nativeSourceDir.resolve("VSockImpl.cpp"), "-fPIC")
// After compilation, package the library into a .nar file
doLast {
val narOutputDir = file("${project.buildDir}/nar")
val narFile = narOutputDir.resolve("vsockj-native-1.0.0.nar")
// Ensure the output directory exists
narOutputDir.mkdirs()
// Use the tar command to create a .nar file (essentially a .tar.gz)
exec {
commandLine("tar", "-czvf", narFile.absolutePath, "-C", outputDir.absolutePath, ".")
}
println(System.getProperty("user.dir"))
}
} }

View File

@ -133,7 +133,7 @@ class Phoenixd : CliktCommand() {
private val electrumServerPort by option("--electrum-server-port", help = "Port for the electrum server").int().default(50002) private val electrumServerPort by option("--electrum-server-port", help = "Port for the electrum server").int().default(50002)
private val startVsock by option("--start-vsock-server", help = "Start the vsock server for API calls").boolean().default(true) private val startVsock by option("--start-vsock-server", help = "Start the vsock server for API calls").boolean().default(true)
private val vsockCID by option("--vsock-server-cid", help = "CID for the Vsock server").int().default(4) private val vsockCID by option("--vsock-server-cid", help = "CID for the Vsock server").int().default(4) //enclave cid is 4 i think
private val vsockPort by option("--vsock-server-port", help = "Port for the Vsock server").int().default(9002) private val vsockPort by option("--vsock-server-port", help = "Port for the Vsock server").int().default(9002)
class LiquidityOptions : OptionGroup(name = "Liquidity Options") { class LiquidityOptions : OptionGroup(name = "Liquidity Options") {
@ -396,8 +396,8 @@ class Phoenixd : CliktCommand() {
if (startVsock) { if (startVsock) {
vsockServer = VsockServer(vsockCID, vsockPort, httpBindPort, httpBindIp, loggerFactory) vsockServer = VsockServer(vsockCID, vsockPort, httpBindPort, httpBindIp, loggerFactory)
GlobalScope.launch { GlobalScope.launch {
consoleLog(yellow("Vsock Server Binding to Port: $vsockPort"))
vsockServer.start() vsockServer.start()
consoleLog(yellow("Vsock Server Binding to Cid: ${vsockPort}"))
} }
} }

View File

@ -16,8 +16,8 @@ import java.io.IOException
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
import java.util.Base64 import java.util.Base64
class VsockServer(private val CID: Int, private val port: Int, httpBindPort: Int, host: String, loggerFactory: LoggerFactory) { class VsockServer(private val cid: Int, private val port: Int, httpBindPort: Int, host: String, loggerFactory: LoggerFactory) {
public var server: ServerVSock? = null private var server: ServerVSock? = null
private val logger = loggerFactory.newLogger(this::class) private val logger = loggerFactory.newLogger(this::class)
private val client = HttpClient() private val client = HttpClient()
private val apiBaseUrl: String = "${host}:${httpBindPort}" private val apiBaseUrl: String = "${host}:${httpBindPort}"
@ -25,10 +25,9 @@ class VsockServer(private val CID: Int, private val port: Int, httpBindPort: Int
@OptIn(DelicateCoroutinesApi::class) @OptIn(DelicateCoroutinesApi::class)
fun start() { fun start() {
logger.info { "Called the Vsock" }
server = ServerVSock() server = ServerVSock()
try { try {
server?.bind(VSockAddress(VSockAddress.VMADDR_CID_ANY, port)) //For any CID use VSockAddress.VMADDR_CID_ANY server?.bind(VSockAddress(cid, port)) //For any CID use VSockAddress.VMADDR_CID_ANY
logger.info { "Vsock Bound on Cid: ${server?.localCid}" } logger.info { "Vsock Bound on Cid: ${server?.localCid}" }
server?.accept()?.use { peerVSock -> server?.accept()?.use { peerVSock ->

View File

@ -1,21 +1,9 @@
package fr.acinq.lightning.vsock.native package fr.acinq.lightning.vsock.native
import fr.acinq.lightning.vsock.VSockAddress import fr.acinq.lightning.vsock.VSockAddress
//import com.github.maven_nar.NarSystem
import org.bytedeco.javacpp.Pointer
import org.bytedeco.javacpp.annotation.Namespace
import org.bytedeco.javacpp.annotation.Platform
import java.net.SocketException import java.net.SocketException
@Platform(include = [ class VSockImpl() {
"<sys/socket.h>",
"<sys/ioctl.h>",
"<linux/vm_sockets.h>",
"<unistd.h>",
"<errno.h>"
])
@Namespace("vsock")
class VSockImpl() : Pointer() {
init { init {
System.load("${System.getProperty("user.dir")}/build/libs/libjniVSockImpl.so") System.load("${System.getProperty("user.dir")}/build/libs/libjniVSockImpl.so")
@ -37,7 +25,7 @@ class VSockImpl() : Pointer() {
external fun connect(address: VSockAddress?) external fun connect(address: VSockAddress?)
@Throws(Exception::class) @Throws(Exception::class)
external override fun close() external fun close()
@Throws(Exception::class) @Throws(Exception::class)
external fun write(b: ByteArray, offset: Int, len: Int) external fun write(b: ByteArray, offset: Int, len: Int)