Add demo application in kotlin

This commit is contained in:
Sudarsan Balaji
2021-10-16 14:45:32 +05:30
parent 85d803afcf
commit 3f620ecf19
8 changed files with 83 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'application'
}
group = 'uniffi.bdk'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test'
implementation project(':jvm')
}
test {
useJUnit()
}
compileKotlin {
kotlinOptions.jvmTarget = '1.8'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.8'
}
application {
mainClassName = 'MainKt'
}
run {
standardInput = System.in
}

Binary file not shown.

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -0,0 +1,25 @@
import uniffi.bdk.*
class LogProgress: BdkProgress {
override fun update(progress: Float, message: String? ) {
println(progress);
println(message);
}
}
fun main(args: Array<String>) {
val descriptor =
"wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)";
val db = DatabaseConfig.Memory("")
val client = BlockchainConfig.Electrum(ElectrumConfig("ssl://electrum.blockstream.info:60002", null, 5u, null, 100u))
val wallet = OnlineWallet(descriptor, Network.TESTNET, db, client)
val address = wallet.getNewAddress()
println("Please send satoshis to wallet address: $address")
readLine()
println("Syncing...")
wallet.sync(LogProgress(), null)
val balance = wallet.getBalance()
println("New wallet balance: $balance")
println("Press any key to exit")
readLine()
}

View File

@@ -1,4 +1,4 @@
rootProject.name = 'bdk-kotlin'
include ':jvm' //, ':android', ':test-fixtures'
include ':jvm', ':demo' //, ':android', ':test-fixtures'