orbis1-sdk-rn 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/Rgb.swift +62 -13
- package/package.json +1 -1
package/ios/Rgb.swift
CHANGED
|
@@ -137,6 +137,30 @@ public class RgbSwiftHelper: NSObject {
|
|
|
137
137
|
try fileManager.removeItem(at: URL(fileURLWithPath: targetPath))
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
private static func deleteRuntimeLockFile(masterFingerprint: String) {
|
|
141
|
+
let constants = AppConstants.shared
|
|
142
|
+
constants.ensureInitialized()
|
|
143
|
+
|
|
144
|
+
guard let rgbDir = constants.rgbDir else {
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
let runtimeLockURL = rgbDir
|
|
149
|
+
.appendingPathComponent(masterFingerprint, isDirectory: true)
|
|
150
|
+
.appendingPathComponent("rgb_runtime.lock", isDirectory: false)
|
|
151
|
+
|
|
152
|
+
let fileManager = FileManager.default
|
|
153
|
+
guard fileManager.fileExists(atPath: runtimeLockURL.path) else {
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
do {
|
|
158
|
+
try fileManager.removeItem(at: runtimeLockURL)
|
|
159
|
+
} catch {
|
|
160
|
+
NSLog("RNRgb: Failed to delete runtime lock file: \(error.localizedDescription)")
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
140
164
|
private static func getNetwork(_ network: String) -> BitcoinNetwork {
|
|
141
165
|
switch network.uppercased() {
|
|
142
166
|
case "MAINNET":
|
|
@@ -343,20 +367,45 @@ public class RgbSwiftHelper: NSObject {
|
|
|
343
367
|
return ["error": "Wallet with id \(walletId) not found"] as NSDictionary
|
|
344
368
|
}
|
|
345
369
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
"
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
370
|
+
let masterFingerprint = session.wallet.getWalletData().masterFingerprint
|
|
371
|
+
|
|
372
|
+
func runOnline() -> (Bool, String)? {
|
|
373
|
+
do {
|
|
374
|
+
let online = try session.wallet.goOnline(
|
|
375
|
+
skipConsistencyCheck: skipConsistencyCheck,
|
|
376
|
+
indexerUrl: indexerUrl
|
|
377
|
+
)
|
|
378
|
+
WalletStore.shared.setOnline(id: walletId.intValue, online: online)
|
|
379
|
+
return (true, "")
|
|
380
|
+
} catch {
|
|
381
|
+
return (false, parseErrorMessage(error))
|
|
382
|
+
}
|
|
359
383
|
}
|
|
384
|
+
|
|
385
|
+
if let result = runOnline() {
|
|
386
|
+
let (status, errorMessage) = result
|
|
387
|
+
if status {
|
|
388
|
+
return [
|
|
389
|
+
"status": NSNumber(value: status),
|
|
390
|
+
"error": errorMessage
|
|
391
|
+
] as NSDictionary
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
deleteRuntimeLockFile(masterFingerprint: masterFingerprint)
|
|
395
|
+
|
|
396
|
+
if let retryResult = runOnline() {
|
|
397
|
+
let (retryStatus, retryError) = retryResult
|
|
398
|
+
return [
|
|
399
|
+
"status": NSNumber(value: retryStatus),
|
|
400
|
+
"error": retryError
|
|
401
|
+
] as NSDictionary
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return [
|
|
406
|
+
"status": NSNumber(value: false),
|
|
407
|
+
"error": "Failed to go online"
|
|
408
|
+
] as NSDictionary
|
|
360
409
|
}
|
|
361
410
|
|
|
362
411
|
@objc(_getBtcBalance:skipSync:)
|
package/package.json
CHANGED