-
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
Open
ben-kaufman
wants to merge
5
commits into
feat/rn-migration
Choose a base branch
from
feat/rn-restore
base: feat/rn-migration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,003
−61
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9f99ffb
feat: support restore from RN app
ben-kaufman 1c412e3
Fixes
ben-kaufman f46465b
Add mnemonic validation on migration
ben-kaufman b408b87
Fix validate mnemonic
ben-kaufman d9c00ec
Merge branch 'feat/rn-migration' into feat/rn-restore
ben-kaufman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -352,15 +352,16 @@ class ActivityService { | |
| 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 @@ class ActivityService { | |
| // 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 @@ class ActivityService { | |
| 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), | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.