MATCH COINS -- 1.39.13.0, 2026-10-21

Unranked loss: 1 Coin. Unranked win: 2 Coins.
Ranked loss: 3 Coins. Ranked win: 4 Coins.
These are the only credit path. There is no purchase, login, warmup,
challenge, duplicate-item refund or manual grant award. Existing Coins,
ownership and receipts are preserved. Draws, cancelled matches, incomplete
starting rosters and bot matches do not earn Coins.

Eligibility uses the existing frozen, registered eight-player match roster.
Original participants receive the result even if disconnected at completion;
spectators and fill-ins do not receive that roster's payout. Halftime and
individual rounds keep the same match ID and do not settle independently.

GSC emits B2 with its queue and awaits the authenticated match service.
ServerRegistry verifies the server's configured kind, allowed map/mode and
all eight reserved accounts. A client cannot supply a win, queue or amount
to its wallet API. Unranked parties may cross teams; Ranked duos stay together.
Unranked uses the same lifecycle/leases but never creates or modifies a rating,
placement, streak or latest-rated-result record.

The completed result and a versioned Coin outbox record commit in the same
rating-database transaction. Wallet settlement credits all eight accounts and
a match receipt in one account-database transaction. The receipt and unique
ledger operation prevent duplicate payments, including after a crash between
wallet commit and outbox acknowledgement. The bridge retries a storage error;
a service worker also drains pending results every five seconds. No response
claiming Coins is returned until wallet settlement succeeds. F3 replies carry
the actual fixed award for the post-match screen. Linked PCs share the account
frozen at match start. Purchases and match payouts serialize in SQLite.

Legacy B1 starts/results do not opt into Coins and are never backfilled.
New B2 starts opt into coin_version 1. Existing completed results and balances
are not rewritten. Both database schemas gain only an initially empty table.

Deploy account coins.py/loot.py/admin.py and registry.py to both central code
installations, rating service/bridge to the central and game-host installations,
and the matching elo_service.gsc/elo_system.gsc to all game instances. Restart
only empty game instances, and retain durable outboxes. Migrate the account
schema before restarting the match service. Its systemd sandbox must permit
writing /var/lib/zeal as well as /var/lib/zeal-ratings; the existing zealcentral
group grants account DB access. This internal service has no public credit API.
Install deploy/zeal-match-coins.conf as
/etc/systemd/system/iw4x-qa-rating.service.d/zzzzzz-match-coins.conf, then
systemctl daemon-reload. The remaining systemd hardening stays enabled.
Back up both databases and verify all preexisting tables/balances before/after.

Verification:
  python3 -m unittest discover -s tests -q
The match-coins suite covers all four awards, server authority, concurrency,
linked PCs, purchases racing payouts, atomic failures, restart recovery,
conflicting replies, cancellation/draw/warmup/legacy exclusions and the real
authenticated HTTP/file bridge. tests/native/elo_smoke.gsc additionally checks
B2/F3 in IW4x against isolated fixture accounts; never deploy this fixture.
