Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 4 additions & 20 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
id("com.android.application") version "9.2.0"
id("org.jetbrains.kotlin.plugin.compose") version "2.3.21"
id("org.jetbrains.kotlin.plugin.serialization") version "2.3.21"
id("com.google.protobuf") version "0.10.0"
id("org.jlleitschuh.gradle.ktlint") version "14.2.0"
}

Expand Down Expand Up @@ -55,11 +54,12 @@ tasks.withType<KotlinCompile> {
dependencies {
// Basic android dependencies
implementation("androidx.core:core-ktx:1.17.0")
implementation("androidx.datastore:datastore:1.2.0")
implementation("com.google.protobuf:protobuf-javalite:4.33.5")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.10.0")
implementation("androidx.core:core-splashscreen:1.2.0")

// DataStore
implementation("androidx.datastore:datastore:1.2.1")

// Jetpack Compose
// Adding the Bill of Materials synchronizes dependencies in the androidx.compose namespace
// You can remove the library version in your dependency declarations
Expand All @@ -77,7 +77,7 @@ dependencies {
implementation("com.composables:icons-lucide:1.1.0")

// Bitcoin Development Kit
implementation("org.bitcoindevkit:bdk-android:3.0.0-RC2")
implementation("org.bitcoindevkit:bdk-android:3.0.0")

// QR codes
implementation("com.google.zxing:core:3.5.4")
Expand All @@ -88,22 +88,6 @@ dependencies {
androidTestImplementation("androidx.test.espresso:espresso-core:3.7.0")
}

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.25.0"
}

generateProtoTasks {
all().forEach { task ->
task.builtins {
create("java") {
option("lite")
}
}
}
}
}

ktlint {
version = "1.8.0"
ignoreFailures = false
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.bitcoindevkit.devkitwallet.data

import org.bitcoindevkit.Descriptor
import org.bitcoindevkit.Network
import org.bitcoindevkit.devkitwallet.data.datastore.ActiveWalletScriptType

data class NewWalletConfig(
val name: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2021-2026 thunderbiscuit and contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the ./LICENSE file.
*/

package org.bitcoindevkit.devkitwallet.data.datastore

import androidx.datastore.core.CorruptionException
import androidx.datastore.core.Serializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationException
import kotlinx.serialization.json.Json
import java.io.InputStream
import java.io.OutputStream

@Serializable
data class AppSettings(
val darkTheme: Boolean = true,
val introDone: Boolean = false,
)

object AppSettingsSerializer : Serializer<AppSettings> {
override val defaultValue = AppSettings()

override suspend fun readFrom(input: InputStream): AppSettings {
try {
return Json.decodeFromString(input.readBytes().decodeToString())
} catch (e: SerializationException) {
throw CorruptionException("Cannot read AppSettings.", e)
}
}

override suspend fun writeTo(t: AppSettings, output: OutputStream) {
output.write(Json.encodeToString(t).encodeToByteArray())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.bitcoindevkit.devkitwallet.data.datastore

import androidx.datastore.core.CorruptionException
import androidx.datastore.core.Serializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationException
import kotlinx.serialization.json.Json
import java.io.InputStream
import java.io.OutputStream

@Serializable
enum class ActiveWalletNetwork {
TESTNET,
SIGNET,
REGTEST,
}

@Serializable
enum class ActiveWalletScriptType {
P2WPKH,
P2TR,
UNKNOWN,
}

@Serializable
data class StoredWallet(
val id: String,
val name: String,
val network: ActiveWalletNetwork,
val scriptType: ActiveWalletScriptType,
val descriptor: String,
val changeDescriptor: String,
val recoveryPhrase: String = "",
val fullScanCompleted: Boolean = false,
)

@Serializable
data class WalletData(
val wallets: List<StoredWallet> = emptyList(),
// network config fields go here alongside wallets
)

object WalletDataSerializer : Serializer<WalletData> {
override val defaultValue = WalletData()

override suspend fun readFrom(input: InputStream): WalletData {
try {
return Json.decodeFromString(input.readBytes().decodeToString())
} catch (e: SerializationException) {
throw CorruptionException("Cannot read AppSettings.", e)
}
}

override suspend fun writeTo(t: WalletData, output: OutputStream) {
output.write(Json.encodeToString(t).encodeToByteArray())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2021-2026 thunderbiscuit and contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the ./LICENSE file.
*/

package org.bitcoindevkit.devkitwallet.domain

import androidx.datastore.core.DataStore
import kotlinx.coroutines.flow.first
import org.bitcoindevkit.devkitwallet.data.datastore.AppSettings

class AppSettingsRepository(private val store: DataStore<AppSettings>) {
suspend fun fetchDarkTheme() = store.data.first().darkTheme

suspend fun setDarkTheme(isDark: Boolean) = store.updateData { it.copy(darkTheme = isDark) }

suspend fun fetchIntroDone() = store.data.first().introDone

suspend fun setIntroDone() = store.updateData { it.copy(introDone = true) }
}

This file was deleted.

Loading
Loading