diff options
Diffstat (limited to 'src/features')
| -rw-r--r-- | src/features/names.js | 17 | ||||
| -rw-r--r-- | src/features/nwc.js | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/features/names.js b/src/features/names.js index d57bb19..e07e025 100644 --- a/src/features/names.js +++ b/src/features/names.js @@ -17,7 +17,7 @@ import { nip98Header } from '../nip98.js'; import { qrSvg } from '../qr.js'; import { bech32 } from '@scure/base'; import { isArkAddress } from './ark.js'; -import { getNetwork } from '../api.js'; +import { getNetwork, getArkProviderId } from '../api.js'; import { t } from '../i18n.js'; import { getCurrency } from '../rates.js'; @@ -411,6 +411,7 @@ export function namesFeature(ctx) { // should have to retype who they already are — but only when that name is // actually free on the registrar (or already theirs to retake). let lnReceipts = { at: 0, p: null }; + let listeningAt = 0; let suggestedFor = null; function suggestName() { @@ -959,6 +960,20 @@ export function namesFeature(ctx) { }; return lnReceipts.p; }, + // A wallet on another ark server (Second, a custom one) gets its name's + // Lightning receives only while it is open to answer the registrar's + // offer request — the registrar can't arkoor to a server it has no + // float on — and its hourly retry rarely met a short session (52 sats + // waited 449 tries, 2026-10-18 → 11-03). So once the offer listener is + // up, say so: whatever is queued for this name goes now. Once per ten + // minutes; a wallet on the coinos server is paid while asleep and + // never needs to (and never spends a signature on it). + namesListening() { + if (!available() || !load().name || getArkProviderId() === 'coinos') return null; + if (Date.now() - listeningAt < 600_000) return null; + listeningAt = Date.now(); + return post('/listening', 'POST', {}).catch(() => { listeningAt = 0; return null; }); + }, // the claimed payment address, for anyone prefilling a lightning address namesAddress() { const st = load(); return st.name ? `${st.name}@${st.domain || DOMAIN()}` : null; }, // Sign-in races this lookup against the seed work: by the time the diff --git a/src/features/nwc.js b/src/features/nwc.js index a2730f5..dc87388 100644 --- a/src/features/nwc.js +++ b/src/features/nwc.js @@ -671,6 +671,10 @@ export function nwcFeature(ctx) { { kinds: [OFFER_KIND], '#p': [o.pk], since: nowSec() - MAX_AGE_SEC }, (ev) => { onOfferRequest(ev).catch((e) => console.warn('nwc: offer handler', e.message)); }, )); + // a beat for the subscription to reach the relays, then tell the + // registrar this wallet is here to answer: Lightning deliveries + // queued for a wallet on another ark server go out now (names) + setTimeout(() => { if (gen === listenGen) Promise.resolve(hook('namesListening')).catch(() => {}); }, 1500); } const list = [...conns(), ...revokedConns()]; dlog(`nwc: listen() gen ${gen} — ${list.length} connection(s)`); |
