Skip to content

Commit 27d4b57

Browse files
committed
remove timeout
1 parent d0591ca commit 27d4b57

File tree

1 file changed

+6
-33
lines changed

1 file changed

+6
-33
lines changed

BDKSwiftExampleWallet/View Model/OnboardingViewModel.swift

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,6 @@ import BitcoinDevKit
99
import Foundation
1010
import SwiftUI
1111

12-
struct TimeoutError: Error {}
13-
14-
func withTimeout<T>(seconds: TimeInterval, operation: @escaping () throws -> T) async throws -> T {
15-
try await withThrowingTaskGroup(of: T.self) { group in
16-
group.addTask {
17-
return try operation()
18-
}
19-
20-
group.addTask {
21-
try await Task.sleep(nanoseconds: UInt64(seconds * 1_000_000_000))
22-
throw TimeoutError()
23-
}
24-
25-
let result = try await group.next()!
26-
group.cancelAll()
27-
return result
28-
}
29-
}
3012

3113
// Can't make @Observable yet
3214
// https://developer.apple.com/forums/thread/731187
@@ -128,14 +110,12 @@ class OnboardingViewModel: ObservableObject {
128110

129111
Task {
130112
do {
131-
try await withTimeout(seconds: 30) {
132-
if self.isDescriptor {
133-
try self.bdkClient.createWalletFromDescriptor(self.words)
134-
} else if self.isXPub {
135-
try self.bdkClient.createWalletFromXPub(self.words)
136-
} else {
137-
try self.bdkClient.createWalletFromSeed(self.words)
138-
}
113+
if self.isDescriptor {
114+
try self.bdkClient.createWalletFromDescriptor(self.words)
115+
} else if self.isXPub {
116+
try self.bdkClient.createWalletFromXPub(self.words)
117+
} else {
118+
try self.bdkClient.createWalletFromSeed(self.words)
139119
}
140120
DispatchQueue.main.async {
141121
self.isCreatingWallet = false
@@ -147,13 +127,6 @@ class OnboardingViewModel: ObservableObject {
147127
self.isCreatingWallet = false
148128
self.createWithPersistError = error
149129
}
150-
} catch is TimeoutError {
151-
DispatchQueue.main.async {
152-
self.isCreatingWallet = false
153-
self.onboardingViewError = .generic(
154-
message: "Wallet creation timed out. Please try again."
155-
)
156-
}
157130
} catch {
158131
DispatchQueue.main.async {
159132
self.isCreatingWallet = false

0 commit comments

Comments
 (0)