Skip to content

fix: settle invalid migration transfers from unpaid orders#813

Open
jvsena42 wants to merge 4 commits intofix/channel-close-uifrom
fix/unpaid-order-import
Open

fix: settle invalid migration transfers from unpaid orders#813
jvsena42 wants to merge 4 commits intofix/channel-close-uifrom
fix/unpaid-order-import

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Feb 27, 2026

Port of synonymdev/bitkit-ios#466

This PR:

  1. Fixes the state filter in createTransfersForPaidOrders to only create transfers for orders in PAID state, skipping expired/executed/refunded orders
  2. Fixes the transfer amount to use clientBalanceSat instead of clientBalanceSat + feeSat
  3. Settles transfers with expired Blocktank orders during syncTransferStates
  4. Adds a one-time cleanup that settles invalid migration transfers created from unpaid orders

Description

When migrating from the RN version of Bitkit, the backup's paidOrders map can contain orders that were never actually paid (expired, refunded, etc). This caused invalid transfers to be created, leaving stuck phantom transfers in the user's wallet.

The fix applies a three-layer defense:

  • Layer 1: Only create transfers for orders in PAID state during migration (prevents new invalid transfers)
  • Layer 2: Detect and settle expired orders during ongoing transfer state sync (catches orders that expire after transfer creation)
  • Layer 3: One-time cleanup on node start to settle any already-created invalid transfers (migration recovery for existing users)

Preview

unpaid-order-import-bug.webm
after-fix.webm

QA Notes

  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 27, 2026
@jvsena42 jvsena42 requested a review from ovitrif February 27, 2026 18:00
@jvsena42 jvsena42 marked this pull request as ready for review February 27, 2026 18:00
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.

1 participant