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" } }, { 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..068197415 100644 --- a/Bitkit/Services/CoreService.swift +++ b/Bitkit/Services/CoreService.swift @@ -2283,6 +2283,13 @@ class BlocktankService { do { return try await operation() } catch { + if "\(error)".contains("401 Unauthorized") { + 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") @@ -2304,7 +2311,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 +2323,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 +2335,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 +2351,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