From 7e55b2ad955f65ba101e504c751a529784b6d7bf Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 19 Mar 2026 00:43:26 +0400 Subject: [PATCH] fix: hopefully.. --- apps/web/src/views/checkout.ejs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/apps/web/src/views/checkout.ejs b/apps/web/src/views/checkout.ejs index e239a5a..67bd38b 100644 --- a/apps/web/src/views/checkout.ejs +++ b/apps/web/src/views/checkout.ejs @@ -257,38 +257,34 @@ watchedAddress = address; watchedTxids = []; - const query = { crypto: coin }; - const q = btoa(JSON.stringify(query)); - const url = `${SOCK_API}/sse?q=${q}`; - - eventSource = new EventSource(url); + // Raw SSE — no query filter at all + eventSource = new EventSource(`${SOCK_API}/sse`); + console.log('SSE: connected, watching for', address); eventSource.onmessage = (e) => { try { const event = JSON.parse(e.data); if (event.type === 'block') { onBlock(event); - } else { + } else if (event.type === 'tx') { onTx(event); } } catch {} }; - eventSource.onerror = () => { - // EventSource auto-reconnects - }; + eventSource.onerror = () => {}; } - /** Check if any tx output matches our payment address. */ function onTx(event) { if (!watchedAddress) return; const outputs = event.data?.out ?? []; for (const out of outputs) { - if (out?.script?.address !== watchedAddress) continue; + const addr = out?.script?.address; + if (!addr || addr !== watchedAddress) continue; const txHash = event.data?.tx?.hash ?? null; if (!txHash || watchedTxids.includes(txHash)) return; watchedTxids.push(txHash); - console.log('SSE: tx detected for our address:', txHash, `(${watchedTxids.length} total)`); + console.log('SSE: tx', txHash, 'matches our address'); document.getElementById('pay-status').innerHTML = ` Transaction detected, waiting for confirmation... @@ -298,13 +294,11 @@ } } - /** Check if a new block includes any of our confirming txids. */ function onBlock(event) { if (watchedTxids.length === 0) return; const blockTxs = event.data?.tx ?? []; - const found = watchedTxids.some(t => blockTxs.includes(t)); - if (found) { - console.log('SSE: block contains one of our txids'); + if (watchedTxids.some(t => blockTxs.includes(t))) { + console.log('SSE: block confirmed our tx'); pollStatus(); } }