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();
}
}