aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-03 16:17:17 -0700
committerAdam Soltys <[email protected]>2026-11-03 16:17:17 -0700
commit14a6dd5ccc03e4617703888beeb3c9e0d4b09cbb (patch)
treeb20b3d7c848b540c3bc506aef1d3f040ae01d186
parent12c6da582291bb62297f9bb100a25b60da7711b7 (diff)
downloadcoinosv3-server-14a6dd5ccc03e4617703888beeb3c9e0d4b09cbb.tar.gz
coinosv3-server-14a6dd5ccc03e4617703888beeb3c9e0d4b09cbb.zip
names: a wallet on another ark server says it is listening, and its queued Lightning deliveries go now. A name whose wallet lives on Second (or a custom captaind) can only be paid over Lightning, and only while the wallet is open to answer the registrar's offer request — the float can't arkoor to a server it isn't on — and the queue's hourly retry with its six-second window rarely overlapped a short phone session: manna's 52 sats failed 449 times from 2026-10-18 to 11-03. POST /listening (NIP-98) marks every queued forward for the caller's names due now and runs the retry pass at once (or again, when one is mid-flight); the answer says how much is waiting. The app calls it once its offer listener is up (coinosv3, same day)
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6TFgisGKUDhdStLUvs
-rw-r--r--names/server.js39
1 files changed, 35 insertions, 4 deletions
diff --git a/names/server.js b/names/server.js
index 71ebcc0..e12e71b 100644
--- a/names/server.js
+++ b/names/server.js
@@ -961,12 +961,18 @@ function pendingSummary() {
};
}
-let retryTicking = false;
-setInterval(async () => {
+let retryTicking = false, retryAgain = false;
+async function tick() {
if (!fwd || retryTicking) return;
retryTicking = true;
- try { await retryTick(); } finally { retryTicking = false; }
-}, 60_000);
+ try { do { retryAgain = false; await retryTick(); } while (retryAgain); }
+ finally { retryTicking = false; }
+}
+setInterval(tick, 60_000);
+// A wallet that just told us it is listening must not wait for the next
+// minute — or for a tick that already looked past its entry: run again as
+// soon as the current pass is done.
+function kickRetry() { if (retryTicking) retryAgain = true; else tick().catch(() => {}); }
async function retryTick() {
// always sync: it reads ark mail AND drives pending actions (a board
// waiting out its confirmations, an ln-recv mid-claim, a queued top-up)
@@ -1463,6 +1469,31 @@ Bun.serve({
return json({ receipts: receipts.slice(0, 100) });
}
+ // A wallet on another ark server (Second, a custom captaind) can only be
+ // paid over Lightning, and only while it is open to answer our offer
+ // request; the queue's hourly retry with its six-second window rarely
+ // overlapped a short phone session (manna's 52 sats: 449 tries from
+ // 2026-10-18). The wallet says so once its offer listener is up, and
+ // whatever is queued for its names goes now. NIP-98 authed: only the
+ // owner (or manager) can hurry their own payments along.
+ if (url.pathname === '/listening' && req.method === 'POST') {
+ if (!rateOk(ip, 30)) return json({ error: 'rate limited' }, 429);
+ const bodyText = await req.text();
+ const a = await checkNip98(req, url, bodyText);
+ if (a.error) return json({ error: a.error }, 401);
+ const mine = (state.pending || []).filter((p) => {
+ const rec = state.names[p.name];
+ return p.pubkey === a.pubkey || rec?.pubkey === a.pubkey || rec?.manager === a.pubkey;
+ });
+ for (const p of mine) p.next = 0;
+ if (mine.length) {
+ log(`${mine.map((p) => p.name).join(', ')} is listening — ${mine.length} queued forward(s) go now`);
+ persist();
+ kickRetry();
+ }
+ return json({ waiting: mine.length, sat: mine.reduce((n, p) => n + p.sat, 0) });
+ }
+
// Prefix search over registered names — powers recipient search in the
// wallet's DMs. Public data (every name is a public DNS record).
if (url.pathname === '/search' && req.method === 'GET') {