From 42842f89a7d978bd0ef00784d4485935a840f3ba Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 11 Nov 2026 00:38:26 +0100 Subject: [PATCH 1/3] chore: send regtest auth from env --- Bitkit/Constants/Env.swift | 6 ++++++ Bitkit/Services/CoreService.swift | 16 ++++++++++++---- journeys/README.md | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Bitkit/Constants/Env.swift b/Bitkit/Constants/Env.swift index 90aed6ed0..0a2de021d 100644 --- a/Bitkit/Constants/Env.swift +++ b/Bitkit/Constants/Env.swift @@ -236,6 +236,12 @@ enum Env { configValue("TREZOR_BRIDGE_URL") ?? "http://127.0.0.1:21325" } + /// Basic auth (`user:password`) for Blocktank's regtest routes, read only in Debug and E2E builds. + static var blocktankRegtestAuth: String? { + guard isDebug || isE2E else { return nil } + return configValue("BLOCKTANK_REGTEST_AUTH") + } + static var trezorElectrumUrl: String? { guard isDebug || isE2E else { return nil } return configValue("TREZOR_ELECTRUM_URL") diff --git a/Bitkit/Services/CoreService.swift b/Bitkit/Services/CoreService.swift index 460eac965..5de70814a 100644 --- a/Bitkit/Services/CoreService.swift +++ b/Bitkit/Services/CoreService.swift @@ -2283,6 +2283,9 @@ class BlocktankService { do { return try await operation() } catch { + if "\(error)".contains("401 Unauthorized") { + throw error + } lastError = error Logger.warn("Regtest operation failed on attempt \(attempt + 1)/\(maxRetries): \(error)", context: "BlocktankService") @@ -2304,7 +2307,7 @@ class BlocktankService { try await executeWithRetry { try await ServiceQueue.background(.core) { - try await regtestMine(count: count) + try await regtestMine(count: count, auth: Env.blocktankRegtestAuth) } } } @@ -2316,7 +2319,7 @@ class BlocktankService { return try await executeWithRetry { try await ServiceQueue.background(.core) { - try await regtestDeposit(address: address, amountSat: amountSat) + try await regtestDeposit(address: address, amountSat: amountSat, auth: Env.blocktankRegtestAuth) } } } @@ -2328,7 +2331,7 @@ class BlocktankService { return try await executeWithRetry { try await ServiceQueue.background(.core) { - try await regtestPay(invoice: invoice, amountSat: amountSat) + try await regtestPay(invoice: invoice, amountSat: amountSat, auth: Env.blocktankRegtestAuth) } } } @@ -2344,7 +2347,12 @@ class BlocktankService { return try await executeWithRetry { try await ServiceQueue.background(.core) { - try await regtestCloseChannel(fundingTxId: fundingTxo.txid, vout: fundingTxo.vout, forceCloseAfterS: forceCloseAfterSeconds) + try await regtestCloseChannel( + fundingTxId: fundingTxo.txid, + vout: fundingTxo.vout, + forceCloseAfterS: forceCloseAfterSeconds, + auth: Env.blocktankRegtestAuth + ) } } } diff --git a/journeys/README.md b/journeys/README.md index 91d47b09c..bddcc99d8 100644 --- a/journeys/README.md +++ b/journeys/README.md @@ -111,6 +111,10 @@ maximum and the journeys pass for the wrong reason: exit status, so an empty response there is not a failure. Give the wallet ~20s to sync before reading the balance. +Staging's `/regtest/*` routes need basic auth. Export `BLOCKTANK_REGTEST_AUTH=user:password` for the +`lsp` helper, and pass the same variable to the app (process environment or launch argument) so +Settings > Blocktank Regtest can deposit and mine; Debug and E2E builds read it, release builds never do. + **The `lsp` helper is borrowed from the sibling Android checkout.** It is the `blocktank-api` plugin's script, and there is no iOS copy yet — #694 tracks porting it. The relative path assumes `bitkit-android` is cloned next to this repo, which is the usual layout here; the hardware-wallet From 0def4fea0a0d7d6d9a57aec28d906d7c7e102156 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 11 Nov 2026 01:20:19 +0100 Subject: [PATCH 2/3] chore: show a clear error for regtest 401 --- Bitkit/Services/CoreService.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Bitkit/Services/CoreService.swift b/Bitkit/Services/CoreService.swift index 5de70814a..068197415 100644 --- a/Bitkit/Services/CoreService.swift +++ b/Bitkit/Services/CoreService.swift @@ -2284,7 +2284,11 @@ class BlocktankService { return try await operation() } catch { if "\(error)".contains("401 Unauthorized") { - throw error + throw AppError( + message: "Blocktank regtest auth is missing or was rejected. Launch the app with BLOCKTANK_REGTEST_AUTH=user:password.", + debugMessage: "\(error)", + underlyingError: error + ) } lastError = error Logger.warn("Regtest operation failed on attempt \(attempt + 1)/\(maxRetries): \(error)", context: "BlocktankService") From 4b872daa6cad4f42a97e0d33fda0bbc00bd101bf Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 11 Nov 2026 13:57:51 +0100 Subject: [PATCH 3/3] chore: bump bitkit-core to 0.8.0-rc14 --- Bitkit.xcodeproj/project.pbxproj | 2 +- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Bitkit.xcodeproj/project.pbxproj b/Bitkit.xcodeproj/project.pbxproj index 01904dc13..c155c5a3e 100644 --- a/Bitkit.xcodeproj/project.pbxproj +++ b/Bitkit.xcodeproj/project.pbxproj @@ -1241,7 +1241,7 @@ repositoryURL = "https://github.com/synonymdev/bitkit-core"; requirement = { kind = exactVersion; - version = "0.8.0-rc13"; + version = "0.8.0-rc14"; }; }; 96E493A22C942FD1000E8BC2 /* XCRemoteSwiftPackageReference "swift-secp256k1" */ = { diff --git a/Bitkit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Bitkit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 943206fc2..99355ef22 100644 --- a/Bitkit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Bitkit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,8 +6,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/synonymdev/bitkit-core", "state" : { - "revision" : "184ccf5f290e84baad0e0b4f49447af78ac28278", - "version" : "0.8.0-rc13" + "revision" : "8fbf1d75591f9b3c746b5fa7de3754d04e699c6d", + "version" : "0.8.0-rc14" } }, {