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.

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.

3 participants