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:
| Mode | Headers on every call | You verify with |
|---|---|---|
hmac (default) | X-Spilvon-Operator, X-Spilvon-Timestamp, X-Spilvon-Signature | your wallet secret |
ed25519 | X-Spilvon-Operator, X-Spilvon-Timestamp, X-Spilvon-Key-Id, X-Spilvon-Signature-Ed25519, X-Spilvon-Signature-Ed25519-V2 | SPILVON's public key |
both | all of the above (for switching without downtime) | either |
The signed string is identical in both schemes:
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-Idnames the key. Public keys are atGET 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_queryis 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-Operatoris your operator id. - Then check the signed body names you (mandatory, every mode). After verifying and parsing, refuse the call with
401INVALID_SIGNATUREand move no money unlessoperator_idin the body equals your operator id. TheX-Spilvon-Operatorheader is not signed;operator_idis. 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 checksignature.operatortests 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 answer | Our 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 balance | outcome 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
- Idempotency by
transaction_id. A transaction you have already processed must change nothing and return the same success response (orDUPLICATE_TRANSACTION). - A bet is all or nothing. Debit the full amount or refuse with a code; never partially.
- Rollback of an unknown bet. Answer
TRANSACTION_NOT_FOUNDand remember thereference_transaction_id; if that bet arrives later, refuse it (any refusal code; it will be followed by a rollback that you again answerTRANSACTION_NOT_FOUND). - Wins and rollbacks are always accepted, even after logout, session expiry or blocking.
- Answer fast: we wait 6 seconds; aim for under 500 ms.
- One rollback refunds once. A second rollback (new
transaction_id) of the same bet must not refund again. - A transaction id is a promise about its details. The same
transaction_idwith a different amount, player, currency, round or reference is not a retry: refuse it withTRANSACTION_MISMATCH(neverDUPLICATE_TRANSACTION, which we read as "already done"), so it is retried and raised to a human instead of being silently paid or dropped. - A bet needs a live session. Check
tokenon everybet: an unknown token, or one that belongs to another player, is refused withTOKEN_INVALID(orTOKEN_EXPIRED). Wins and rollbacks are not token-checked (rule 4). - 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 itswin(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 onerollback. A progressive jackpot is an additional, independentwinper prize, not another game settlement. - Free-round awards: no
bet; the round ends with onewincarryingfree_round: true,reference_transaction_id: nulland 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 arollback. - A multi-step round left open by the player is settled automatically after 24 hours.