Skip to content

Commit

Permalink
add timeouts to ledger sign process
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Aug 21, 2024
1 parent 6512793 commit 6bf4f57
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/KukaiCoreSwift/Models/LedgerWallet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ public class LedgerWallet: Wallet {
let isWatermarkedOperation = (String(hex.prefix(2)) == "03") && hex.count != 32

LedgerService.shared.connectTo(uuid: ledgerUUID)
.flatMap { _ -> AnyPublisher<String, KukaiError> in
.timeout(.seconds(10), scheduler: RunLoop.main, customError: {
return KukaiError.knownErrorMessage("Timed out waiting for device to connect. Check device/bluetooth is turned on and try again")
})
.flatMap { _ -> Publishers.Timeout<AnyPublisher<String, KukaiError>, RunLoop> in
return LedgerService.shared.sign(hex: hex, parse: isWatermarkedOperation)
.timeout(.seconds(10), scheduler: RunLoop.main, customError: {
return KukaiError.knownErrorMessage("Timed out waiting for device to connect. Check device/bluetooth is turned on and try again")
})
}
.sink(onError: { error in
completion(Result.failure(error))
Expand Down

0 comments on commit 6bf4f57

Please sign in to comment.