diff --git a/the-matrix/index.html b/the-matrix/index.html index b5fac26..bd55fe8 100644 --- a/the-matrix/index.html +++ b/the-matrix/index.html @@ -576,8 +576,8 @@
DEPOSIT AMOUNT (200–10,000 sats)
- - + + @@ -585,7 +585,7 @@
+ min="200" max="10000" value="200" step="1" /> sats
@@ -622,8 +622,8 @@
TOPUP AMOUNT (200–10,000 sats)
- - + + @@ -631,7 +631,7 @@
+ min="200" max="10000" value="200" step="1" /> sats
diff --git a/the-matrix/js/session.js b/the-matrix/js/session.js index bfaedf7..a52cbb9 100644 --- a/the-matrix/js/session.js +++ b/the-matrix/js/session.js @@ -16,6 +16,7 @@ import { setSpeechBubble, setMood } from './agents.js'; import { appendSystemMessage, setSessionSendHandler, setInputBarSessionMode } from './ui.js'; import { getOrRefreshToken } from './nostr-identity.js'; import { sentiment } from './edge-worker-client.js'; +import qrcode from 'qrcode-generator'; const API = '/api'; const LS_KEY = 'timmy_session_v1'; @@ -31,8 +32,8 @@ let _balanceSats = 0; let _sessionState = null; // null | 'awaiting_payment' | 'active' | 'paused' | 'expired' let _pollTimer = null; let _inFlight = false; -let _selectedSats = 500; // deposit amount selection -let _topupSats = 500; // topup amount selection +let _selectedSats = 200; // deposit amount selection +let _topupSats = 200; // topup amount selection // ── Public API ──────────────────────────────────────────────────────────────── @@ -238,6 +239,7 @@ async function _createSession() { const hashEl = _el('session-invoice-hash'); if (hashEl) hashEl.dataset.hash = inv.paymentHash || ''; + _renderQR('session-invoice-qr', inv.paymentRequest); _setStep('invoice'); _setStatus('invoice', '⚡ Awaiting deposit…', '#ffaa00'); @@ -345,6 +347,7 @@ async function _createTopup() { _el('session-topup-pr').textContent = pending.paymentRequest || ''; const th = _el('session-topup-hash'); if (th) th.dataset.hash = pending.paymentHash || ''; + _renderQR('session-topup-qr', pending.paymentRequest); _el('session-topup-pr-row').style.display = ''; _setStatus('topup', '⚡ Previous invoice still pending', '#ffaa00'); return; @@ -357,6 +360,7 @@ async function _createTopup() { _el('session-topup-pr').textContent = inv.paymentRequest || ''; const th = _el('session-topup-hash'); if (th) th.dataset.hash = inv.paymentHash || ''; + _renderQR('session-topup-qr', inv.paymentRequest); _el('session-topup-pr-row').style.display = ''; _setStatus('topup', '⚡ Awaiting topup payment…', '#ffaa00'); @@ -566,6 +570,30 @@ function _clearError() { if (el) el.textContent = ''; } +function _renderQR(containerId, data) { + const el = _el(containerId); + if (!el || !data) return; + try { + const qr = qrcode(0, 'L'); + qr.addData(data.toUpperCase()); + qr.make(); + el.innerHTML = qr.createSvgTag({ scalable: true }); + el.style.height = 'auto'; + el.style.padding = '8px'; + // Style the SVG to fit + const svg = el.querySelector('svg'); + if (svg) { + svg.style.width = '100%'; + svg.style.maxWidth = '200px'; + svg.style.height = 'auto'; + svg.style.display = 'block'; + svg.style.margin = '0 auto'; + } + } catch { + el.textContent = '[ QR ]'; + } +} + function _stopPolling() { clearTimeout(_pollTimer); _pollTimer = null; diff --git a/the-matrix/package-lock.json b/the-matrix/package-lock.json index 65fa405..de33909 100644 --- a/the-matrix/package-lock.json +++ b/the-matrix/package-lock.json @@ -10,10 +10,11 @@ "dependencies": { "@xenova/transformers": "^2.17.2", "nostr-tools": "^2.23.3", + "qrcode-generator": "^1.4.4", "three": "0.171.0" }, "devDependencies": { - "vite": "^5.4.0" + "vite": "^5.4.15" } }, "node_modules/@esbuild/aix-ppc64": { @@ -1617,6 +1618,12 @@ "once": "^1.3.1" } }, + "node_modules/qrcode-generator": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/qrcode-generator/-/qrcode-generator-1.4.4.tgz", + "integrity": "sha512-HM7yY8O2ilqhmULxGMpcHSF1EhJJ9yBj8gvDEuZ6M+KGJ0YY2hKpnXvRD+hZPLrDVck3ExIGhmPtSdcjC+guuw==", + "license": "MIT" + }, "node_modules/rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", diff --git a/the-matrix/package.json b/the-matrix/package.json index 40b8266..0859fb6 100644 --- a/the-matrix/package.json +++ b/the-matrix/package.json @@ -11,6 +11,7 @@ "dependencies": { "@xenova/transformers": "^2.17.2", "nostr-tools": "^2.23.3", + "qrcode-generator": "^1.4.4", "three": "0.171.0" }, "devDependencies": {