Skip to content

Conversation

@ovitrif
Copy link
Collaborator

@ovitrif ovitrif commented Jan 9, 2026

Fixes scenario: User pays for a channel order in RN, migrates to Native before the channel opens → App doesn't know the order is paid & pending fulfillment → channel never opens.

Note

This was a bug I found by being more creative than the crew during the mainnet testing session of this week when we were testing the migration. Would love more creativity from everyone especially wrt. mainnet testing.

Description

  • Store paid orders with their transaction IDs during migration from RN backup
  • The paidOrders backup data is a map of orderId -> txId, not just a list of IDs
  • By calling cacheStore.addPaidOrder(orderId, txId), the native app can now recognize pending paid orders and fulfill them when block confirmation is received

Refactorings

  • Adopt Result API for consistent error handling in migration code
  • Remove suspend modifier from pure functions that don't need it
  • Replace reflection with direct property access for signing key derivation
  • Remove unused methods and dead code
  • Extract magic numbers to named constants
  • Move private data classes to bottom of file per convention
  • Fix lint warnings and simplify conditional expressions

Preview

N/A - No UI changes

QA Notes

Test: Migrating pending channel order from RN to Native

  1. Uninstall Bitkit app
  2. Install RN (React Native) Bitkit
  3. Load a fresh wallet → fund it
  4. Start a transfer to spending and complete the flow without waiting
  5. Immediately after (before the order is fulfilled):
    • Install native Bitkit build of this branch over the RN app
  6. Open app and wait for migration to complete
  7. Go to Settings → Advanced → Lightning Connections to see the pending order
  8. Wait with the app open and active until the order is fulfilled (after block confirmation is received)
  9. Expected: The app fulfills the channel order and the channel opens, with the app showing the toast for it and the Lightning Connections screen showing it as open
  10. Verify Send and Receive LN funds work correctly

@claude

This comment has been minimized.

@ovitrif ovitrif requested a review from ben-kaufman January 9, 2026 17:26
@ovitrif ovitrif changed the title fix: import migrated pending orders fix(migration): import pending orders to cache store Jan 9, 2026
@ovitrif ovitrif changed the title fix(migration): import pending orders to cache store fix(migration): import and cache pending orders Jan 9, 2026
@ovitrif ovitrif changed the title fix(migration): import and cache pending orders fix(migration): import pending orders in cache Jan 9, 2026
@ovitrif ovitrif changed the title fix(migration): import pending orders in cache fix(migration): pickup migrated pending orders to fulfill Jan 9, 2026
@ovitrif ovitrif changed the title fix(migration): pickup migrated pending orders to fulfill fix(migration): pickup pending orders for fulfillment Jan 9, 2026
@ovitrif
Copy link
Collaborator Author

ovitrif commented Jan 9, 2026

@ben-kaufman AFAIU the changes from commit 1c21784 are needed in iOS as well 🙏🏻

Could you tackle the iOS side please?

@ovitrif ovitrif requested review from jvsena42 and piotr-iohk January 9, 2026 17:40
@ovitrif ovitrif self-assigned this Jan 9, 2026
@ben-kaufman
Copy link
Contributor

Yes, will do

@ovitrif
Copy link
Collaborator Author

ovitrif commented Jan 9, 2026

Yes, will do

Dunno if iOS has the same mechanism, but if not it should:
if there are pendingOrders in caches, it should keep checking if their status is signalling they're ready to be fulfilled.

Then the actual migration only needs to ensure the pendingOrders map in caches is filled with the data picked-up from React Native's remote backups.

@ovitrif
Copy link
Collaborator Author

ovitrif commented Jan 9, 2026

Note to reviewer

Please test the migration scenario and do not merge until that's done.

I will test myself too on actual prod mainnet release build, didn't because most of the refactorings were suggestions from Android Studio.

fix: recover channel orders during migration
@claude

This comment has been minimized.

@piotr-iohk
Copy link
Collaborator

Tested the migration scenario, works as expected -> pending channel is visible and opens eventually after confirmation. 👍

The scenario fails in the restoration scenario:

  • Install RN (React Native) Bitkit
  • Load a fresh wallet → fund it
  • Get wallet seed.
  • Start a transfer to spending and complete the flow without waiting
  • Immediately after (before the order is fulfilled):
    - Uninstall RN
    - Install Bitkit Native and restore previous wallet

Here, the pending channel is still not visible after restoration and ultimately never opens.

@jvsena42

This comment was marked as outdated.

@jvsena42
Copy link
Member

The restore without migration worked. I'll test now on RN side

@jvsena42
Copy link
Member

The restore without migration worked. I'll test now on RN side

Also worked, so the issue is in RN restore mapping

@jvsena42
Copy link
Member

The restore without migration worked. I'll test now on RN side

Also worked, so the issue is in RN restore mapping

worked on #595

@ben-kaufman
Copy link
Contributor

Worked for me on both scenarios. For the restore from mnemonic, before deleting the app please go to backup in settings to make sure it synced, as in case the app is deleted before backup is synced there's nothing we can do.

@piotr-iohk
Copy link
Collaborator

Worked for me on both scenarios. For the restore from mnemonic, before deleting the app please go to backup in settings to make sure it synced, as in case the app is deleted before backup is synced there's nothing we can do.

Ok, worked after making sure it synced. 👍

Copy link
Collaborator

@piotr-iohk piotr-iohk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants