mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-18 06:41:27 +02:00
transfer_split sends one on-chain tx to many destinations, so payout rows in a batch share a tx_hash. The old UNIQUE index on payouts.tx_hash made the 2nd+ row fail to record, leaving funds sent but rows stranded in 'processing' and re-sendable by the retry service. - Migration 015 drops the payouts tx_hash unique index (idempotency is enforced by idx_payouts_one_per_game) and extends that guard to cover 'processing' so no second payable row can be inserted mid-flight. - Batch completion now updates the whole batch in a single transaction via id = ANY(...), so rows can't be left half-completed. Per-user stats use BIGINT arithmetic in SQL (no JS float). - Ambiguous batch failures are marked 'needs_review' (which the retry service does NOT pick up) instead of 'failed', preventing a double-send when transfer_split may have already broadcast. Operator is alerted. Adds batchPayout.test.js covering the shared-tx_hash completion and the needs_review failure path. Full suite: 12 suites / 115 tests.