Skip to content

fix: cleanup unpaid order transfers from migration#466

Open
jvsena42 wants to merge 3 commits intomasterfrom
fix/unpaid-order-import
Open

fix: cleanup unpaid order transfers from migration#466
jvsena42 wants to merge 3 commits intomasterfrom
fix/unpaid-order-import

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Feb 26, 2026

Fixes #461

Description

This PR fixes a bug where unpaid/expired Blocktank orders from the RN backup's paidOrders map were imported as pending transfers during migration, permanently locking funds in balanceInTransferToSpending.

The RN app could store orders in paidOrders even when the payment was never completed. The migration code blindly trusted this map and only filtered out .executed orders, allowing expired/unpaid orders through.

Changes:

  1. Only create migration transfers for orders in .paid state (not just skipping .executed)
  2. Fix amountSats to use clientBalanceSat instead of clientBalanceSat + feeSat, matching the normal transfer creation flow
  3. Handle expired orders in syncTransferStates so any invalid transfers get cleaned up during normal sync
  4. Add a one-time cleanup that fetches order states from Blocktank and settles transfers for non-paid orders

Linked Issues/Tasks

Screenshot / Video

simulate-migration.mp4
after-fix.mp4

QA Notes:

To reproduce:

  1. On RN app, replace blocktank.ts with this file blocktank.ts to create an order without broadcast the payment
  2. Also comment out checkForAppUpdate(); to don't display the update sheet
  3. Migrate to native on master branch
  4. Expected: Transfer banner never dismissed and amount + fee count on total balance
  5. checkout to fix/unpaid-order-import
  6. Expected: cleanup invalid transfer and update total balance ✅

@jvsena42 jvsena42 self-assigned this Feb 26, 2026
@jvsena42

This comment was marked as resolved.

@jvsena42 jvsena42 marked this pull request as ready for review February 26, 2026 14:26
@jvsena42
Copy link
Member Author

From the logs, there is no on-chain balance. The mismatch from total comes from the invalid pending transfer

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.

ios: savings empty and transfer in progress after update

1 participant