Skip to content

Release: develop -> main#3486

Merged
TaprootFreak merged 1 commit intomainfrom
develop
Mar 21, 2026
Merged

Release: develop -> main#3486
TaprootFreak merged 1 commit intomainfrom
develop

Conversation

@github-actions
Copy link
Copy Markdown

Automatic Release PR

This PR was automatically created after changes were pushed to develop.

Commits: 1 new commit(s)

Checklist

  • Review all changes
  • Verify CI passes
  • Approve and merge when ready for production

…balance (#3484)

* fix: filter third-party transactions and fix receiver trimming in pending 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.

* fix: replace sum-based Scrypt pending balance with 1:1 transaction matching

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.

* fix: add 21-day filter on senders in getUnmatchedSenders

Filter senders to the last 21 days (only recent transfers are pending)
but keep all receivers available for matching (prevents orphaned
receivers from aged-out senders).

* fix: match CHF and EUR separately in unfiltered non-ScryptEur path

Combined CHF+EUR matching could cause cross-currency matches
(e.g. CHF sender 30k matching EUR receiver 30k). Match each
currency separately, then combine results.

* fix: replace fuzzy matching with reference-based 1:1 matching for Scrypt pending balance

Replace amount+timing greedy matching in getUnmatchedSenders with exact
reference matching (bankTx.remittanceInfo === exchangeTx.txId). This
eliminates wrong pairings that inflated the pending balance.

Additional fixes:
- Remove txId filter on EUR receivers (excluded legitimate deposits)
- Change status === 'ok' to status !== 'failed' on all Scrypt exchange_tx
  filters (pending deposits/withdrawals now count as matched)
- Reduce sender window from 21 to 7 days (max transfer duration)

* style: fix prettier formatting in test file
@TaprootFreak TaprootFreak merged commit d00da91 into main Mar 21, 2026
7 checks passed
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