aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-30 18:16:50 -0700
committerAdam Soltys <[email protected]>2026-10-30 18:16:50 -0700
commit12c6da582291bb62297f9bb100a25b60da7711b7 (patch)
tree567b49ffb5f4ebaf7dcdc89c27b6432e9f21558e
parent59cd71ff935b36aa1298ae1a9ede516930890ef9 (diff)
downloadcoinosv3-server-12c6da582291bb62297f9bb100a25b60da7711b7.tar.gz
coinosv3-server-12c6da582291bb62297f9bb100a25b60da7711b7.zip
names: GET /pos/invoice/<hash> 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 <[email protected]>
-rw-r--r--names/server.js9
1 files changed, 9 insertions, 0 deletions
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)) {