Entwicklerportal

Entwicklerportal / API-Referenz

Technische Dokumentation auf Englisch

OPENAPI / v1.3.0

SPILVON Wallet API (implemented by the operator)

You implement this API; SPILVON calls it. The player's money never leaves your platform: when a player bets, SPILVON asks your wallet to debit the stake; when the round ends, it asks you to credit the win (possibly zero). Four endpoints under one base URL that you register with SPILVON (your wallet URL): POST {wallet_url}/balance, /bet, /win, /rollback.

Derived from rgs/src/wallet.ts, rgs/src/player-do.ts, rgs/src/jackpot-player.ts, shared/signing.ts, shared/wallet-keys.ts, the reference implementation in demo-casino/src/index.ts and the conformance tool tools/wallet-conformance.ts, as of 2026-12-01.

Verifying our calls

Every call is signed. Your operator account is configured for one of three modes:

ModeHeaders on every callYou verify with
hmac (default)X-Spilvon-Operator, X-Spilvon-Timestamp, X-Spilvon-Signatureyour wallet secret
ed25519X-Spilvon-Operator, X-Spilvon-Timestamp, X-Spilvon-Key-Id, X-Spilvon-Signature-Ed25519, X-Spilvon-Signature-Ed25519-V2SPILVON's public key
bothall of the above (for switching without downtime)either

The signed string is identical in both schemes:

Text
timestamp + "." + "POST" + "." + path_and_query + "." + raw_body
  • HMAC: X-Spilvon-Signature = lowercase_hex(HMAC-SHA256(wallet_secret, signed_string)).
  • Ed25519: X-Spilvon-Signature-Ed25519 = base64(Ed25519_sign(private_key, signed_string)) (standard base64, 64-byte signature); X-Spilvon-Key-Id names the key. Public keys are at GET https://{spilvon-host}/.well-known/spilvon-wallet-keys.json. Cache the key set; refetch daily and when you see an unknown key id. Reject an unknown key id after one refetch.
  • path_and_query is the path of your URL as we requested it, e.g. /spilvon-wallet/bet.
  • Verify before parsing the JSON, over the exact raw bytes. Never re-serialise.
  • Reject a timestamp more than 300 s from your clock. Compare signatures in constant time.
  • Check X-Spilvon-Operator is your operator id.
  • Then check the signed body names you (mandatory, every mode). After verifying and parsing, refuse the call with 401 INVALID_SIGNATURE and move no money unless operator_id in the body equals your operator id. The X-Spilvon-Operator header is not signed; operator_id is. One SPILVON Ed25519 key signs every operator's calls, so a call captured by another casino (a jackpot credit needs no bet, round or session) verifies at your wallet too; this check is what refuses its replay. The conformance check signature.operator tests it, and go-live requires it.
  • Optional, recommended with Ed25519: also verify X-Spilvon-Signature-Ed25519-V2, a second signature over "SPILVON-WALLET-V2" LF operator_id LF timestamp LF "POST" LF path_and_query LF raw_body, where you fill in your own operator id. A call signed for another operator then fails the signature itself. Once you verify v2, refuse calls without it.
  • Test vectors for all schemes: docs/signature-test-vectors.json.

How SPILVON reads your answer

Your answerOur classification
HTTP 200 with {"balance": "<decimal string>"}success
HTTP 200, or 4xx other than 408/429, with {"error":{"code": <one of the codes below>}}definitive refusal / already done
anything else: timeout (6 s), connection error, 5xx, 3xx redirect, 408, 429, body over 16 KiB, non-JSON body, unknown error code, 200 without a valid balanceoutcome unknown

Outcome unknown is never treated as success or refusal: a bet is cancelled and a rollback is sent; a win or rollback is retried with the same transaction_id after 2 s, 5 s, 15 s, 1 min, 5 min, 15 min, then hourly until acknowledged. After 5 failed attempts it is raised to SPILVON operations. bet is never retried.

The rules of a correct wallet

  1. Idempotency by transaction_id. A transaction you have already processed must change nothing and return the same success response (or DUPLICATE_TRANSACTION).
  2. A bet is all or nothing. Debit the full amount or refuse with a code; never partially.
  3. Rollback of an unknown bet. Answer TRANSACTION_NOT_FOUND and remember the reference_transaction_id; if that bet arrives later, refuse it (any refusal code; it will be followed by a rollback that you again answer TRANSACTION_NOT_FOUND).
  4. Wins and rollbacks are always accepted, even after logout, session expiry or blocking.
  5. Answer fast: we wait 6 seconds; aim for under 500 ms.
  6. One rollback refunds once. A second rollback (new transaction_id) of the same bet must not refund again.
  7. A transaction id is a promise about its details. The same transaction_id with a different amount, player, currency, round or reference is not a retry: refuse it with TRANSACTION_MISMATCH (never DUPLICATE_TRANSACTION, which we read as "already done"), so it is retried and raised to a human instead of being silently paid or dropped.
  8. A bet needs a live session. Check token on every bet: an unknown token, or one that belongs to another player, is refused with TOKEN_INVALID (or TOKEN_EXPIRED). Wins and rollbacks are not token-checked (rule 4).
  9. A rollback must match its bet. Refund the bet's owner from your stored bet, never from the request. Refuse a rollback whose player, currency, round or amount differs from the bet (TRANSACTION_MISMATCH), and a rollback of a bet whose round already received its win (ROUND_ALREADY_SETTLED); undoing it would pay twice.

tools/wallet-conformance.ts checks these rules, including standalone jackpot credits. It needs a live session token of the test player (--token).

Round lifecycle

  • A paid round settles with one game win (possibly "0.00", round_closed: true) or one rollback. A progressive jackpot is an additional, independent win per prize, not another game settlement.
  • Free-round awards: no bet; the round ends with one win carrying free_round: true, reference_transaction_id: null and the award identifiers.
  • Crash (Zenith): a player may hold two bets in one round; each has its own round_id. A bet cancelled before take-off ends with a rollback.
  • A multi-step round left open by the player is settled automatically after 24 hours.

Browse endpoints · Download YAML