Mandatory validation rules
Definitions#
Bet: operation that opens a round_id and debits the player's amount to the operator.Win (end state): webhook sent to close the bet, with a value > 0 (win) or value = 0 (loss/no prize).Rollback (end state): webhook sent to refund the amount of a bet that has not yet been resolved, only in Crash games.Idempotency: guarantee that the same operation (bet, win, or rollback) will not take effect more than once when repeated with the same identifier.Main rules (resolutions)#
Every bet is closed by a single resolution event.
Win: closes the bet with a win (> 0) or without a win (= 0).
Rollback: closes the bet by returning the specified amount.
They never coexist: if a win has already been sent, there can be no rollback; if a rollback has already been sent, there can be no win.
A bet never originates more than one win or more than one rollback.
Any additional event after resolution must be rejected.
The first valid resolution event received (win or rollback) defines the final state.
Mandatory Operator Checks#
Confirm the existence of the original bet.
Confirm whether the bet has already been resolved (win or rollback).
Never accept transaction out of this flow (bet->win/rollback) and subsequent events for the same bet must be rejected.
The operator must guarantee idempotency for bets, rollbacks, and wins.
Validate that the same operation with the same identifier should never be processed more than once.
In resubmissions due to unavailability, the operation must be acknowledged and responded to without reprocessing.
Needs control by round_id to avoid multiple resolutions.
Security rejections#
All requests must verify the cryptographic signature and timestamp.
The timestamp must respect a defined validity window (suggestion: 2 minutes).
Reject messages with an invalid, missing, or expired signature.
Reconciliation#
The operator must maintain logs structured by round_id, bet_id, and idempotency identifier.
Periodic reconciliation reports (resolved bets, applied rollbacks, divergences) are recommended.
When reprocessing, record that the response was idempotent (with no additional effect).
Modificado em 2025-08-21 06:59:48