orbis1-sdk-rn 0.2.3 → 0.2.4
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.
|
@@ -335,14 +335,43 @@ class RgbModule(reactContext: ReactApplicationContext) :
|
|
|
335
335
|
val session = WalletStore.get(walletId.toInt())
|
|
336
336
|
?: throw IllegalStateException("Wallet with id $walletId not found")
|
|
337
337
|
|
|
338
|
-
val
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
338
|
+
val masterFingerprint = session.wallet.getWalletData().masterFingerprint
|
|
339
|
+
|
|
340
|
+
suspend fun runOnline(): Pair<Boolean, String>? {
|
|
341
|
+
return try {
|
|
342
|
+
val online = session.wallet.goOnline(
|
|
343
|
+
skipConsistencyCheck = skipConsistencyCheck,
|
|
344
|
+
indexerUrl = indexerUrl
|
|
345
|
+
)
|
|
346
|
+
WalletStore.setOnline(walletId.toInt(), online)
|
|
347
|
+
Pair(true, "")
|
|
348
|
+
} catch (e: Exception) {
|
|
349
|
+
Pair(false, parseErrorMessage(e.message))
|
|
350
|
+
}
|
|
351
|
+
}
|
|
343
352
|
|
|
344
|
-
|
|
345
|
-
|
|
353
|
+
val result = runOnline()
|
|
354
|
+
|
|
355
|
+
withContext(Dispatchers.Main) {
|
|
356
|
+
if (result != null) {
|
|
357
|
+
val (status, error) = result
|
|
358
|
+
if (status) {
|
|
359
|
+
val map = Arguments.createMap()
|
|
360
|
+
map.putBoolean("status", status)
|
|
361
|
+
map.putString("error", error)
|
|
362
|
+
promise.resolve(map)
|
|
363
|
+
} else {
|
|
364
|
+
deleteRuntimeLockFile(masterFingerprint)
|
|
365
|
+
val retryResult = runOnline()
|
|
366
|
+
if (retryResult != null) {
|
|
367
|
+
val (retryStatus, retryError) = retryResult
|
|
368
|
+
val map = Arguments.createMap()
|
|
369
|
+
map.putBoolean("status", retryStatus)
|
|
370
|
+
map.putString("error", retryError)
|
|
371
|
+
promise.resolve(map)
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
346
375
|
}
|
|
347
376
|
} catch (e: Exception) {
|
|
348
377
|
Log.e(TAG, "goOnline error: ${e.message}", e)
|
|
@@ -353,6 +382,26 @@ class RgbModule(reactContext: ReactApplicationContext) :
|
|
|
353
382
|
}
|
|
354
383
|
}
|
|
355
384
|
|
|
385
|
+
fun deleteRuntimeLockFile(masterFingerprint: String) {
|
|
386
|
+
try {
|
|
387
|
+
val runtimeLockPath = AppConstants.rgbDir
|
|
388
|
+
.resolve(masterFingerprint)
|
|
389
|
+
.resolve("rgb_runtime.lock")
|
|
390
|
+
if (!runtimeLockPath.exists()) {
|
|
391
|
+
Log.i("RGB", "No runtime lock file exists at path: ${runtimeLockPath.path}")
|
|
392
|
+
return
|
|
393
|
+
}
|
|
394
|
+
Log.i("RGB", "Deleting runtime lock at: ${runtimeLockPath.path}")
|
|
395
|
+
if (runtimeLockPath.delete()) {
|
|
396
|
+
Log.i("RGB", "Runtime lock deleted successfully.")
|
|
397
|
+
} else {
|
|
398
|
+
Log.e("RGB", "Failed to delete runtime lock.")
|
|
399
|
+
}
|
|
400
|
+
} catch (e: Exception) {
|
|
401
|
+
Log.e("RGB", "Failed to delete runtime lock: ${e.message}", e)
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
356
405
|
override fun getBtcBalance(
|
|
357
406
|
walletId: Double,
|
|
358
407
|
skipSync: Boolean,
|
package/package.json
CHANGED