diff --git a/.claude/plugins/blocktank-api/skills/lsp/SKILL.md b/.claude/plugins/blocktank-api/skills/lsp/SKILL.md index 71c6306417..4eb026398d 100644 --- a/.claude/plugins/blocktank-api/skills/lsp/SKILL.md +++ b/.claude/plugins/blocktank-api/skills/lsp/SKILL.md @@ -12,7 +12,7 @@ version: 0.1.0 Blocktank is the Lightning Service Provider (LSP) used by Bitkit. This skill provides full knowledge of its REST API and a utility script to call any endpoint from the command line. -All requests and responses use JSON. Staging's `/regtest/*` routes need basic auth: set `BLOCKTANK_REGTEST_AUTH=user:password` and the script sends it; without it they return `401`. Other routes need no authentication. +All requests and responses use JSON. Staging's `/regtest/*` routes need basic auth: set `BLOCKTANK_REGTEST_AUTH=user:password` and the script sends it; without it they return `401`. Other routes need no authentication. Debug builds of the app send the same value from Settings > Blocktank Regtest when `BLOCKTANK_REGTEST_AUTH` is set at build time (environment variable, Gradle property or `local.properties`); release builds never carry it. ## Configuration diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a34882ad6c..31f3d08307 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -364,7 +364,7 @@ androidComponents { buildConfigFields.put("E2E_HOMEGATE_URL", e2eHomegateUrlEnv.stringField()) buildConfigFields.put("E2E_HOMESERVER_PUBKY", e2eHomeserverPubkyEnv.stringField()) buildConfigFields.put("E2E_HOMEGATE_OVERRIDE", e2eHomegateOverrideEnv.stringField()) - for (key in listOf("E2E_VSS_SERVER_URL", "E2E_LNURL_AUTH_SERVER_URL", "E2E_BLOCKTANK_API_URL")) { + for (key in listOf("E2E_VSS_SERVER_URL", "E2E_LNURL_AUTH_SERVER_URL", "E2E_BLOCKTANK_API_URL", "BLOCKTANK_REGTEST_AUTH")) { val value = if (variant.buildType == "debug") localProp(key).orElse("") else provider { "" } buildConfigFields.put(key, value.stringField()) } @@ -417,7 +417,7 @@ androidComponents { } fun Provider.stringField(): Provider> = - map { BuildConfigField(type = "String", value = "\"$it\"", comment = null) } + map { BuildConfigField(type = "String", value = "\"${it.replace("\\", "\\\\").replace("\"", "\\\"")}\"", comment = null) } fun Provider.booleanField(): Provider> = map { BuildConfigField(type = "boolean", value = it, comment = null) } diff --git a/app/src/main/java/to/bitkit/env/Env.kt b/app/src/main/java/to/bitkit/env/Env.kt index d211f9d4bc..7b23a2a6ac 100644 --- a/app/src/main/java/to/bitkit/env/Env.kt +++ b/app/src/main/java/to/bitkit/env/Env.kt @@ -41,6 +41,9 @@ internal object Env { get() = BuildConfig.ESPLORA_URL.takeIf { it.isNotBlank() && network == Network.REGTEST } val isDebug = BuildConfig.DEBUG + + /** Basic auth (`user:password`) for Blocktank's regtest routes, set only in debug builds. */ + val blocktankRegtestAuth: String? get() = BuildConfig.BLOCKTANK_REGTEST_AUTH.takeIf { isDebug && it.isNotBlank() } const val isE2eTest = BuildConfig.E2E val e2eBackend = BuildConfig.E2E_BACKEND.lowercase() val isLocalE2eBackend = isE2eTest && e2eBackend == "local" diff --git a/app/src/main/java/to/bitkit/services/CoreService.kt b/app/src/main/java/to/bitkit/services/CoreService.kt index 0c3c879510..c8b3b80eb1 100644 --- a/app/src/main/java/to/bitkit/services/CoreService.kt +++ b/app/src/main/java/to/bitkit/services/CoreService.kt @@ -2270,13 +2270,14 @@ class BlocktankService( // MARK: - Regtest methods suspend fun regtestMine(count: UInt = 1u) { - com.synonym.bitkitcore.regtestMine(count = count) + com.synonym.bitkitcore.regtestMine(count = count, auth = Env.blocktankRegtestAuth) } suspend fun regtestDeposit(address: String, amountSat: ULong = 10_000_000uL): String { return com.synonym.bitkitcore.regtestDeposit( address = address, amountSat = amountSat, + auth = Env.blocktankRegtestAuth, ) } @@ -2284,6 +2285,7 @@ class BlocktankService( return com.synonym.bitkitcore.regtestPay( invoice = invoice, amountSat = amountSat, + auth = Env.blocktankRegtestAuth, ) } @@ -2296,6 +2298,7 @@ class BlocktankService( fundingTxId = fundingTxId, vout = vout, forceCloseAfterS = forceCloseAfterS.toULong(), + auth = Env.blocktankRegtestAuth, ) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index db95608929..4a4885e843 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,7 +23,7 @@ activity-compose = { module = "androidx.activity:activity-compose", version = "1 appcompat = { module = "androidx.appcompat:appcompat", version = "1.8.0" } barcode-scanning = { module = "com.google.mlkit:barcode-scanning", version = "17.3.0" } biometric = { module = "androidx.biometric:biometric", version = "1.4.0-beta01" } -bitkit-core = { module = "com.synonym:bitkit-core-android", version = "0.8.0-rc13" } +bitkit-core = { module = "com.synonym:bitkit-core-android", version = "0.8.0-rc14" } breez-sdk-spark = { module = "breez_sdk_spark:bindings-android", version = "0.28.0" } paykit = { module = "com.synonym:paykit-android", version = "0.1.1-rc7" } bouncycastle-pkix-jdk = { module = "org.bouncycastle:bcpkix-jdk18on", version = "1.86" }