-
Notifications
You must be signed in to change notification settings - Fork 1
Support restore from RN app #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/rn-migration
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ | |
| } | ||
| } | ||
| await MainActor.run { | ||
| self.cachedTxIdsInBoostTxIds = txIds | ||
| } | ||
| } catch { | ||
| Logger.error("Failed to refresh boostTxIds cache: \(error)", context: "ActivityService") | ||
|
|
@@ -109,7 +109,7 @@ | |
|
|
||
| func isActivitySeen(id: String) async -> Bool { | ||
| do { | ||
| if let activity = try await getActivityById(activityId: id) { | ||
| switch activity { | ||
| case let .onchain(onchain): | ||
| return onchain.seenAt != nil | ||
|
|
@@ -352,15 +352,16 @@ | |
| let value = payment.amountSats ?? 0 | ||
|
|
||
| // Determine confirmation status from payment's txStatus | ||
| // Ensure confirmTimestamp is at least equal to paymentTimestamp when confirmed | ||
| // This handles cases where payment.latestUpdateTimestamp is more recent than blockTimestamp | ||
| let (isConfirmed, confirmedTimestamp): (Bool, UInt64?) = | ||
| if case let .onchain(_, txStatus) = payment.kind, | ||
| case let .confirmed(_, _, blockTimestamp) = txStatus { | ||
| (true, max(blockTimestamp, paymentTimestamp)) | ||
| } else { | ||
| (false, nil) | ||
| } | ||
| var blockTimestamp: UInt64? | ||
| let isConfirmed: Bool | ||
| if case let .onchain(_, txStatus) = payment.kind, | ||
| case let .confirmed(_, _, bts) = txStatus | ||
| { | ||
| isConfirmed = true | ||
| blockTimestamp = bts | ||
| } else { | ||
| isConfirmed = false | ||
| } | ||
|
|
||
| // Extract existing activity data | ||
| let existingOnchain: OnchainActivity? = { | ||
|
|
@@ -412,6 +413,12 @@ | |
| // Build and save the activity | ||
| let finalDoesExist = isConfirmed ? true : doesExist | ||
|
|
||
| let activityTimestamp: UInt64 = if existingActivity == nil, let bts = blockTimestamp, bts < paymentTimestamp { | ||
| bts | ||
| } else { | ||
| existingOnchain?.timestamp ?? paymentTimestamp | ||
| } | ||
|
Comment on lines
+416
to
+420
|
||
|
|
||
| let onchain = OnchainActivity( | ||
| id: payment.id, | ||
| txType: payment.direction == .outbound ? .sent : .received, | ||
|
|
@@ -421,12 +428,12 @@ | |
| feeRate: feeRate, | ||
| address: address, | ||
| confirmed: isConfirmed, | ||
| timestamp: paymentTimestamp, | ||
| timestamp: activityTimestamp, | ||
| isBoosted: isBoosted, | ||
| boostTxIds: boostTxIds, | ||
| isTransfer: isTransfer, | ||
| doesExist: finalDoesExist, | ||
| confirmTimestamp: confirmedTimestamp, | ||
| confirmTimestamp: blockTimestamp, | ||
| channelId: channelId, | ||
| transferTxId: transferTxId, | ||
| createdAt: UInt64(payment.creationTime.timeIntervalSince1970), | ||
|
|
@@ -618,7 +625,7 @@ | |
| } | ||
|
|
||
| private func processLightningPayment(_ payment: PaymentDetails) async throws { | ||
| guard case let .bolt11(hash, preimage, secret, description, bolt11) = payment.kind else { return } | ||
|
Check warning on line 628 in Bitkit/Services/CoreService.swift
|
||
|
|
||
| // Skip pending inbound payments - just means they created an invoice | ||
| guard !(payment.status == .pending && payment.direction == .inbound) else { return } | ||
|
|
@@ -671,7 +678,7 @@ | |
|
|
||
| for payment in payments { | ||
| do { | ||
| let state: BitkitCore.PaymentState = switch payment.status { | ||
| case .failed: | ||
| .failed | ||
| case .pending: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
vss > 0check appears to be a magic number. Consider using a named constant or adding a comment explaining what a timestamp of 0 or less represents.