From 9207bbcb8f8af3f7b463840918e76d8c98cdf10f Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Fri, 31 Jul 2026 15:03:42 +0200 Subject: [PATCH] Don't reveal the win banner before winner_amount_sats is known (B-50) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit winner_user_id is committed as soon as the draw picks a winner, but winner_amount_sats isn't set until the payout tx is built afterwards (a real Electrum listunspent round-trip later, in a separate DB transaction). The frontend revealed the win banner as soon as winner_user_id appeared, formatPlm(undefined) rendered as "—", and the toast/result box briefly showed "You won! +— PLM" until the next poll picked up the real amount. Gate the winner's own reveal on winner_amount_sats also being non-null; a loss can still reveal immediately since it never needs the amount. Co-Authored-By: Claude Sonnet 5 --- app/static/app.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/static/app.js b/app/static/app.js index de2ee3a..ea8787a 100644 --- a/app/static/app.js +++ b/app/static/app.js @@ -488,11 +488,21 @@ async function refreshRound() { // myUserId may not be loaded yet on the very first tick after a reload // (refreshMe() and refreshRound() run concurrently) — fall back to the // persisted result rather than risk showing nothing or the wrong side. + // winner_user_id is committed as soon as the draw picks a winner, but + // winner_amount_sats isn't set until the payout tx is built afterwards + // (a real Electrum round-trip later) — revealing a win before then would + // show "+— PLM". Only the winner's own reveal needs to wait for it. + const iWon = myUserId != null && data.winner_user_id === myUserId; + const amountReady = !iWon || data.winner_amount_sats != null; const canReveal = - data.user_played && data.winner_user_id != null && (alreadyKnown || elapsedMs >= minMs) && myUserId != null; + data.user_played && + data.winner_user_id != null && + (alreadyKnown || elapsedMs >= minMs) && + myUserId != null && + amountReady; if (canReveal) { - const won = data.winner_user_id === myUserId; + const won = iWon; if (!alreadyKnown) { persistResult(data.round_id, won, data.winner_amount_sats); if (won) {