Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions examples/src/main/kotlin/WalletSetupBip32.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fun createDescriptorsFromBip32RootKey (
val mnemonic = Mnemonic(WordCount.WORDS12)
val bip32ExtendedRootKey = DescriptorSecretKey(network, mnemonic, null)
println("Bip32 root key: $bip32ExtendedRootKey")

val descriptor: Descriptor = createScriptAppropriateDescriptor(
activeWalletScriptType,
bip32ExtendedRootKey,
Expand Down Expand Up @@ -64,13 +64,20 @@ fun createScriptAppropriateDescriptor(
)
}
}

fun getPersistenceFilePath(): String {
val currentDirectory = Paths.get("").toAbsolutePath().toString() + "/bdk-jvm/examples/src/main/kotlin/bdk_persistence.sqlite"
File(currentDirectory).apply {
// Resolve absolute path to the fixed `examples/data` directory
val projectRoot = Paths.get("").toAbsolutePath().parent.resolve("examples")
val persistenceDirectory = projectRoot.resolve("data").toFile()
val persistenceFilePath = projectRoot.resolve("data/bdk_persistence.sqlite").toString()

persistenceDirectory.apply {
if (!exists()) mkdirs()
}

File(persistenceFilePath).apply {
if (exists()) delete()
}
return currentDirectory
return persistenceFilePath
}

enum class ActiveWalletScriptType {
Expand Down