Merge pull request #2109 from BlueWallet/widgetcrasfix

FIX: double completion block being called
This commit is contained in:
GLaDOS 2020-11-11 14:49:39 +00:00 committed by GitHub
commit bc81f0d4cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -35,7 +35,8 @@ struct WalletData {
var balance: Double var balance: Double
var latestTransactionTime: Int = 0 var latestTransactionTime: Int = 0
var formattedBalanceBTC: String { var formattedBalanceBTC: String {
return "\(balance / 100000000) BTC" let value = NSNumber(value: balance / 100000000);
return "\(value.decimalValue) BTC"
} }
} }

View file

@ -36,9 +36,8 @@ extension WidgetAPI {
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)) { 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("Successfully obtained response from Electrum sever")
print(userElectrumSettings) print(userElectrumSettings)
let marketData = MarketData(nextBlock: String(format: "%.0f", (nextBlockResponseDouble / 1024) * 100000000), sats: "0", price: "0", rate: 0)
client.close() client.close()
completion(MarketData(nextBlock: String(format: "%.0f", (nextBlockResponseDouble / 1024) * 100000000), sats: "0", price: "0", rate: 0), nil) let marketData = MarketData(nextBlock: String(format: "%.0f", (nextBlockResponseDouble / 1024) * 100000000), sats: "0", price: "0", rate: 0)
completion(marketData, nil) completion(marketData, nil)
} else { } else {
client.close() client.close()