Skip to content

fix: filter third-party bank_tx and fix receiver trimming in pending balance#3484

Open
TaprootFreak wants to merge 2 commits intodevelopfrom
fix/scrypt-eur-pending-balance-v2
Open

fix: filter third-party bank_tx and fix receiver trimming in pending balance#3484
TaprootFreak wants to merge 2 commits intodevelopfrom
fix/scrypt-eur-pending-balance-v2

Conversation

@TaprootFreak
Copy link
Collaborator

@TaprootFreak TaprootFreak commented Mar 20, 2026

Summary

Replaces the flawed sum-based Scrypt pending balance with correct 1:1 transaction matching.

Problem: filterSenderPendingList returned windowed sender/receiver lists, and getPendingBankAmount summed them independently. When old receivers' senders aged out of the 21-day window, orphaned receivers created false negatives — making pending transfers (e.g. 30k EUR) invisible in the FinancialDataLog.

Solution: New getUnmatchedSenders() method matches each sender with a receiver 1:1 by amount and chronological order (same criteria as findSenderReceiverPair). Only truly unmatched senders contribute to the pending balance — no receiver subtraction needed.

Changes

  • New getUnmatchedSenders(senders, receivers) with 1:1 greedy matching
  • All 4 Scrypt directions (CHF/EUR × Bank→Scrypt/Scrypt→Bank) use 1:1 matching
  • Both filtered and unfiltered paths updated
  • Minus amounts eliminated for Scrypt (implicit in matching)
  • Kraken paths unchanged
  • Foreign transaction filters from fix: exclude third-party deposits from Scrypt EUR pending balance #3480 retained (txId for exchange_tx, instructedCurrency for bank_tx)

Net effect: -94 lines, +72 lines (simpler code)

Test plan

  • Existing filterSenderPendingList tests pass (9/9)
  • Verify FinancialDataLog shows correct positive toScrypt/fromScrypt pending amounts
  • Confirm Kraken pending balances unchanged
  • Check toScrypt !== toScryptUnfiltered comparison doesn't trigger false errors

@TaprootFreak TaprootFreak force-pushed the fix/scrypt-eur-pending-balance-v2 branch from e8e02db to e35b420 Compare March 20, 2026 12:26
…ding balance

Three issues caused Scrypt EUR pending balances to be invisible:

1. Third-party EUR deposits (txId=null) inflated the receiver sum
2. Third-party bank_tx (instructedCurrency=null) inflated the sender count
3. filterSenderPendingList did not trim orphaned receivers when sender
   and receiver counts were equal — old receivers whose senders aged out
   of the 21-day window absorbed new unmatched senders, netting to 0

Fix: filter foreign transactions from both lists, and when counts are
equal, detect senders newer than all receivers (definitely unmatched)
and trim corresponding orphaned old receivers.
@TaprootFreak TaprootFreak force-pushed the fix/scrypt-eur-pending-balance-v2 branch from e35b420 to 978a6dd Compare March 20, 2026 12:29
@TaprootFreak TaprootFreak marked this pull request as ready for review March 20, 2026 12:36
…tching

The previous approach used filterSenderPendingList + sum difference to
calculate pending Scrypt balances. This was fundamentally flawed: old
receivers whose senders aged out of the 21-day window created false
negatives, making pending transfers invisible.

New approach: getUnmatchedSenders() matches each sender with a receiver
1:1 by amount and chronological order (same criteria as findSenderReceiverPair).
Only truly unmatched senders contribute to the pending balance — no
receiver subtraction needed.

Applied to all 4 Scrypt directions (CHF/EUR × Bank→Scrypt/Scrypt→Bank),
both filtered and unfiltered paths. Kraken paths unchanged.
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