mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-26 08:55:56 +01:00
Update WidgetAPI.swift
This commit is contained in:
parent
d1edcc3624
commit
e16de64c1a
1 changed files with 7 additions and 2 deletions
|
@ -41,11 +41,16 @@ class WidgetAPI {
|
|||
completion(nil, APIError())
|
||||
return
|
||||
}
|
||||
if let response = String(bytes: data, encoding: .utf8), let nextBlockResponse = response.components(separatedBy: #"result":"#).last?.components(separatedBy: ",").first, let nextBlockResponseDouble = Double(nextBlockResponse.trimmingCharacters(in: .whitespacesAndNewlines)) {
|
||||
let characterSet = Set("0123456789.")
|
||||
if let response = String(bytes: data, encoding: .utf8), let nextBlockResponse = response.components(separatedBy: #"result":"#).last?.components(separatedBy: ",").first, let nextBlockResponseDouble = Double(nextBlockResponse.filter({characterSet.contains($0)}).trimmingCharacters(in: .whitespacesAndNewlines)) {
|
||||
print("Successfully obtained response from Electrum sever")
|
||||
print(userElectrumSettings)
|
||||
let marketData = MarketData(nextBlock: String(format: "%.0f", (nextBlockResponseDouble / 1024) * 100000000), sats: "0", price: "0", rate: 0)
|
||||
client.close()
|
||||
completion(MarketData(nextBlock: String(format: "%.0f", (nextBlockResponseDouble / 1024) * 100000000), sats: "0", price: "0", rate: 0), nil)
|
||||
completion(marketData, nil)
|
||||
} else {
|
||||
client.close()
|
||||
completion(nil, APIError())
|
||||
}
|
||||
case .failure(let error):
|
||||
print(error)
|
||||
|
|
Loading…
Add table
Reference in a new issue