Reorganize bdk-kotlin into jvm sub-module
This commit is contained in:
39
bindings/bdk-kotlin/jvm/build.gradle
Normal file
39
bindings/bdk-kotlin/jvm/build.gradle
Normal file
@@ -0,0 +1,39 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
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"
|
||||
implementation "junit:junit:4.13.2"
|
||||
api "org.slf4j:slf4j-api:1.7.30"
|
||||
testImplementation "ch.qos.logback:logback-classic:1.2.3"
|
||||
testImplementation "ch.qos.logback:logback-core:1.2.3"
|
||||
//testImplementation(project(':test-fixtures'))
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = 'org.bitcoindevkit'
|
||||
artifactId = 'bdk'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
1490
bindings/bdk-kotlin/jvm/src/main/kotlin/uniffi/bdk/bdk.kt
Normal file
1490
bindings/bdk-kotlin/jvm/src/main/kotlin/uniffi/bdk/bdk.kt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,66 @@
|
||||
package uniffi.bdk
|
||||
|
||||
import uniffi.bdk.OfflineWallet
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class LogProgress: BdkProgress {
|
||||
override fun update(progress: Float, message: String? ) {
|
||||
println(progress);
|
||||
println(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Library tests which will execute for jvm and android modules.
|
||||
*/
|
||||
class LibTest {
|
||||
|
||||
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 config = DatabaseConfig.Sled(SledDbConfiguration("/tmp/testdb", "testdb"))
|
||||
val wallet = OfflineWallet(desc, Network.REGTEST, config)
|
||||
val address = wallet.getNewAddress()
|
||||
assertNotNull(address)
|
||||
assertEquals(address, "bcrt1qzg4mckdh50nwdm9hkzq06528rsu73hjxytqkxs")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlineWalletInMemory() {
|
||||
val db = DatabaseConfig.Memory("")
|
||||
val client = BlockchainConfig.Electrum(ElectrumConfig("ssl://electrum.blockstream.info:50002", null, 5u, null, 100u))
|
||||
val wallet = OnlineWallet(desc, Network.TESTNET, db, client)
|
||||
assertNotNull(wallet)
|
||||
val network = wallet.getNetwork()
|
||||
assertEquals(network, Network.TESTNET)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlineWalletSyncGetBalance() {
|
||||
val db = DatabaseConfig.Memory("")
|
||||
val client = BlockchainConfig.Electrum(ElectrumConfig("ssl://electrum.blockstream.info:50002", null, 5u, null, 100u))
|
||||
val wallet = OnlineWallet(desc, Network.TESTNET, db, client)
|
||||
wallet.sync(LogProgress(), null)
|
||||
val balance = wallet.getBalance()
|
||||
assertNotNull(balance)
|
||||
println(balance)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user