Add demo application in kotlin
This commit is contained in:
36
bindings/bdk-kotlin/demo/build.gradle
Normal file
36
bindings/bdk-kotlin/demo/build.gradle
Normal 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
|
||||
}
|
||||
BIN
bindings/bdk-kotlin/demo/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
bindings/bdk-kotlin/demo/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
bindings/bdk-kotlin/demo/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
bindings/bdk-kotlin/demo/gradle/wrapper/gradle-wrapper.properties
vendored
Normal 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
|
||||
25
bindings/bdk-kotlin/demo/src/main/kotlin/Main.kt
Normal file
25
bindings/bdk-kotlin/demo/src/main/kotlin/Main.kt
Normal 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()
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
rootProject.name = 'bdk-kotlin'
|
||||
|
||||
include ':jvm' //, ':android', ':test-fixtures'
|
||||
include ':jvm', ':demo' //, ':android', ':test-fixtures'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user