From 12c6da582291bb62297f9bb100a25b60da7711b7 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 30 Oct 2026 18:16:50 -0700 Subject: names: GET /pos/invoice/ tells a terminal whether its sale settled A terminal in the field sat on "Waiting for payment" with its websocket open the whole time while the registrar credited the sale and pushed the payment frame. The firmware now polls this while it waits, so a socket that stays up but goes deaf can't strand a paid sale. Co-Authored-By: Claude Fable 5.1 --- names/server.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'names') diff --git a/names/server.js b/names/server.js index 0829c47..71ebcc0 100644 --- a/names/server.js +++ b/names/server.js @@ -1257,6 +1257,15 @@ Bun.serve({ if (url.pathname === '/pos/me' && req.method === 'GET') { return json({ username: name, address: a.key, currency: a.currency }); } + // One sale's state. The terminal polls this while it waits, so a + // socket that stays open but goes deaf (seen in the field) can't + // strand a paid sale on "Waiting for payment". + const pi = url.pathname.match(/^\/pos\/invoice\/([0-9a-f]{64})$/); + if (pi && req.method === 'GET') { + const v = posInvoices()[pi[1]]; + if (!v || v.key !== a.key) return json({ error: 'not found' }, 404); + return json({ id: pi[1], amount: v.sat, tip: 0, received: v.received ?? 0, paid: v.paid || null, created: v.created }); + } // Ring up a sale: {invoice:{fiat}} (the terminal's shape) or {amount} in sats. if (url.pathname === '/pos/invoice' && req.method === 'POST') { if (otherNetwork(state.names[a.key]?.uri, state.names[a.key]?.domain)) { -- cgit v1.2.3