Index, probe, and announce LNURL mints in the API.

Wire discovery and probing for LNURL mints, add rate-limited POST /api/index
for user submissions, and optionally announce confirmed state to relays.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
michilis
2026-08-22 03:44:35 +02:00
co-authored by Cursor
parent c97b44018d
commit 2a9444942b
19 changed files with 4383 additions and 72 deletions
+32 -2
View File
@@ -10,7 +10,7 @@
import { closeDb, getDb } from './db.ts';
import { closePool, runDiscovery } from './discovery.ts';
import { log } from './log.ts';
import { insertMintIfNew } from './mints.ts';
import { insertLnurlIfNew, insertMintIfNew } from './mints.ts';
import { probeAll } from './probe.ts';
import { listMints } from './queries.ts';
@@ -54,6 +54,23 @@ const SEED_MINTS = [
'https://kashu.me',
];
/**
* LNURL mints, seeded by URL alone.
*
* Short for the obvious reason: `kind:38174` is a proposed kind (see
* `docs/KIND-LNURL-MINT.md`) and there are no announcements on the network yet, so
* unlike Cashu — where this list was read off real 38172 events — there is nothing to
* read it off. This is the reference instance the ecosystem was built against, and
* discovery takes over the moment operators start announcing.
*
* Seeded with no status: `insertLnurlIfNew` writes `unknown` and the first probe cycle
* decides, exactly as it does for a Cashu mint. Being on this list is not a claim that
* a mint is up, and is not an endorsement of it.
*/
const SEED_LNURL = [
'https://lnurl.21mint.me',
];
function pad(s: string, width: number): string {
return s.length > width ? `${s.slice(0, width - 1)}…` : s.padEnd(width);
}
@@ -64,7 +81,15 @@ async function main(): Promise<void> {
let added = 0;
for (const url of SEED_MINTS) if (await insertMintIfNew(url)) added++;
log.info('seed list ingested', { listed: SEED_MINTS.length, added });
let addedLnurl = 0;
for (const url of SEED_LNURL) if (await insertLnurlIfNew(url)) addedLnurl++;
log.info('seed list ingested', {
listed: SEED_MINTS.length + SEED_LNURL.length,
added: added + addedLnurl,
lnurl: addedLnurl,
});
await probeAll();
const discovery = await runDiscovery(true);
@@ -109,6 +134,7 @@ async function main(): Promise<void> {
const mints = listed.filter((m) => m.type === 'cashu');
const federations = listed.filter((m) => m.type === 'fedimint');
const lnurlMints = listed.filter((m) => m.type === 'lnurl');
const count = (rows: typeof listed, status: string) =>
rows.filter((m) => m.status === status).length;
const reviews = listed.reduce((sum, m) => sum + m.review_count, 0);
@@ -128,6 +154,10 @@ async function main(): Promise<void> {
`${count(federations, 'offline')} reported down, ` +
`${count(federations, 'announced')} announced only)`,
);
console.log(
`${lnurlMints.length} LNURL mints (${count(lnurlMints, 'online')} online, ` +
`${count(lnurlMints, 'offline')} offline)`,
);
console.log(`${reviews} reviews indexed`);
closePool();