Remove non-kotlin related files, add bdk-ffi as submodule, update build.sh
This commit is contained in:
83
jvm/build.gradle
Normal file
83
jvm/build.gradle
Normal file
@@ -0,0 +1,83 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'signing'
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging {
|
||||
events "PASSED", "SKIPPED", "FAILED", "STANDARD_OUT", "STANDARD_ERROR"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation platform('org.jetbrains.kotlin:kotlin-bom')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "net.java.dev.jna:jna:5.8.0"
|
||||
api "org.slf4j:slf4j-api:1.7.30"
|
||||
testImplementation "junit:junit:4.13.2"
|
||||
testImplementation "ch.qos.logback:logback-classic:1.2.3"
|
||||
testImplementation "ch.qos.logback:logback-core:1.2.3"
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
publishing {
|
||||
publications {
|
||||
|
||||
release(MavenPublication) {
|
||||
groupId = 'org.bitcoindevkit'
|
||||
artifactId = 'bdk-jvm'
|
||||
version = '0.1.3-dev'
|
||||
|
||||
from components.java
|
||||
|
||||
pom {
|
||||
name = 'bdk-jvm'
|
||||
description = 'Bitcoin Dev Kit Kotlin language bindings.'
|
||||
url = "https://bitcoindevkit.org"
|
||||
licenses {
|
||||
license {
|
||||
name = "APACHE"
|
||||
url = "https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-APACHE"
|
||||
}
|
||||
license {
|
||||
name = "MIT"
|
||||
url = "https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-MIT"
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = 'notmandatory'
|
||||
name = 'Steve Myers'
|
||||
email = 'notmandatory@noreply.github.org'
|
||||
}
|
||||
developer {
|
||||
id = 'artfuldev'
|
||||
name = 'Sudarsan Balaji'
|
||||
email = 'sudarsan.balaji@artfuldev.com'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection = 'scm:git:github.com/bitcoindevkit/bdk-ffi.git'
|
||||
developerConnection = 'scm:git:ssh://github.com/bitcoindevkit/bdk-ffi.git'
|
||||
url = 'https://github.com/bitcoindevkit/bdk-ffi/tree/master'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign publishing.publications
|
||||
}
|
||||
100
jvm/src/test/kotlin/org/bitcoindevkit/JvmLibTest.kt
Normal file
100
jvm/src/test/kotlin/org/bitcoindevkit/JvmLibTest.kt
Normal file
@@ -0,0 +1,100 @@
|
||||
package org.bitcoindevkit
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
/**
|
||||
* Library test, which will execute on linux host.
|
||||
*
|
||||
*/
|
||||
class JvmLibTest {
|
||||
|
||||
fun getTestDataDir(): String {
|
||||
return Files.createTempDirectory("bdk-test").toString()
|
||||
//return Paths.get(System.getProperty("java.io.tmpdir"), "bdk-test").toString()
|
||||
}
|
||||
|
||||
fun cleanupTestDataDir(testDataDir: String) {
|
||||
File(testDataDir).deleteRecursively()
|
||||
}
|
||||
|
||||
val log: Logger = LoggerFactory.getLogger(JvmLibTest::class.java)
|
||||
|
||||
val desc =
|
||||
"wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)"
|
||||
|
||||
@Test
|
||||
fun memoryWalletNewAddress() {
|
||||
val config = DatabaseConfig.Memory("")
|
||||
val wallet = OfflineWallet(desc, Network.REGTEST, config)
|
||||
val address = wallet.getNewAddress()
|
||||
assertNotNull(address)
|
||||
assertEquals(address, "bcrt1qzg4mckdh50nwdm9hkzq06528rsu73hjxytqkxs")
|
||||
}
|
||||
|
||||
@Test(expected = BdkException.Descriptor::class)
|
||||
fun invalidDescriptorExceptionIsThrown() {
|
||||
val config = DatabaseConfig.Memory("")
|
||||
OfflineWallet("invalid-descriptor", Network.REGTEST, config)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sledWalletNewAddress() {
|
||||
val testDataDir = getTestDataDir()
|
||||
val config = DatabaseConfig.Sled(SledDbConfiguration(testDataDir, "testdb"))
|
||||
val wallet = OfflineWallet(desc, Network.REGTEST, config)
|
||||
val address = wallet.getNewAddress()
|
||||
assertNotNull(address)
|
||||
assertEquals(address, "bcrt1qzg4mckdh50nwdm9hkzq06528rsu73hjxytqkxs")
|
||||
cleanupTestDataDir(testDataDir)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlineWalletInMemory() {
|
||||
val db = DatabaseConfig.Memory("")
|
||||
val client = BlockchainConfig.Electrum(
|
||||
ElectrumConfig(
|
||||
"ssl://electrum.blockstream.info:60002",
|
||||
null,
|
||||
5u,
|
||||
null,
|
||||
100u
|
||||
)
|
||||
)
|
||||
val wallet = OnlineWallet(desc, null, Network.TESTNET, db, client)
|
||||
assertNotNull(wallet)
|
||||
val network = wallet.getNetwork()
|
||||
assertEquals(network, Network.TESTNET)
|
||||
}
|
||||
|
||||
class LogProgress : BdkProgress {
|
||||
val log: Logger = LoggerFactory.getLogger(JvmLibTest::class.java)
|
||||
|
||||
override fun update(progress: Float, message: String?) {
|
||||
log.debug("Syncing...")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlineWalletSyncGetBalance() {
|
||||
val db = DatabaseConfig.Memory("")
|
||||
val client = BlockchainConfig.Electrum(
|
||||
ElectrumConfig(
|
||||
"ssl://electrum.blockstream.info:60002",
|
||||
null,
|
||||
5u,
|
||||
null,
|
||||
100u
|
||||
)
|
||||
)
|
||||
val wallet = OnlineWallet(desc, null, Network.TESTNET, db, client)
|
||||
wallet.sync(LogProgress(), null)
|
||||
val balance = wallet.getBalance()
|
||||
assertTrue(balance > 0u)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user