aboutsummaryrefslogtreecommitdiffstats
path: root/names
diff options
context:
space:
mode:
Diffstat (limited to 'names')
-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)) {