diff options
| author | Adam Soltys <[email protected]> | 2026-08-01 20:46:12 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-01 20:46:12 -0700 |
| commit | ed1d996f9dbd6cedc18ec293daba0cfcd745ae2b (patch) | |
| tree | 6d552796e899314d402dc92f6f80886405e296b5 /src/nwc-bg.js | |
| parent | 5986cbf5337593eb11fd984d284bd41da7719a87 (diff) | |
| download | coinosv3-ed1d996f9dbd6cedc18ec293daba0cfcd745ae2b.tar.gz coinosv3-ed1d996f9dbd6cedc18ec293daba0cfcd745ae2b.zip | |
Zappable offer codes and per-name Lightning offers
CLINK offers (noffer): every wallet gets a static offer keypair (synced
across devices, first-minted wins) answering kind-21001 invoice
requests — from open tabs and from the service worker while closed,
which mints against the mirrored state (the record now carries chain-4
and chain-5 key windows) and raises an open-to-receive notification.
Zap requests ride along and their kind-9735 receipts publish once the
payment is claimed. The code is shown in the payment-address card for
pasting into a Nostr profile; the notifier watches and relays kind
21001 alongside NWC.
Payment names also gain a Lightning offer: the registrar creates a
BOLT 12 offer per name on the node and appends lno= to the DNS record;
a settle-forwarder pushes each received payment on to the name's ark
destination from a small float wallet (custody window: seconds between
Lightning settle and the ark send).
Name resolution now runs full client-side DNSSEC validation
(src/dnssec.js): binary DoH, root-anchor chain walk, RSA + ECDSA via
WebCrypto — the resolver is untrusted transport, verified against live
signed zones including the canonical BIP-353 test name.
Co-Authored-By: Claude Fable 5 <[email protected]>
Diffstat (limited to 'src/nwc-bg.js')
| -rw-r--r-- | src/nwc-bg.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/nwc-bg.js b/src/nwc-bg.js index f539e45..af0bb6d 100644 --- a/src/nwc-bg.js +++ b/src/nwc-bg.js @@ -79,20 +79,31 @@ export async function allBgs() { // cannot derive keys, so its allocations must land inside this window. export const BG_KEY_LOOKAHEAD = 25; -// { ark } endpoints, the manager state to mirror, and a keyFor(index) derive -// function (the caller owns the account node — it never enters this module). -export function buildBg({ ark, mgrState, keyFor, connections }) { +// { ark } endpoints, the manager state to mirror, and a keyFor(chain, index) +// derive function (the caller owns the account node — it never enters this +// module). Chain 3 covers coins + change, chain 4/0 the mailbox, chain 5 a +// window of receive preimages — everything the worker needs to pay AND to +// mint invoices while the app is closed. +export function buildBg({ ark, mgrState, keyFor, connections, offer }) { const keys = {}; const idx = new Set((mgrState.vtxos || []).filter((v) => v.state !== 'spent').map((v) => v.keyIndex)); for (let i = 0; i < BG_KEY_LOOKAHEAD; i++) idx.add((mgrState.nextKeyIndex || 1) + i); idx.add(0); // the receive-address key: mailbox/refund defaults land on it - for (const i of idx) keys[String(i)] = keyFor(i); + for (const i of idx) keys[String(i)] = keyFor(3, i); + const keys5 = {}; + for (let i = 0; i < 15; i++) { + const n = (mgrState.nextLnRecvIndex || 0) + i; + keys5[String(n)] = keyFor(5, n); + } return { v: 3, updated: Date.now(), ark, mgr: mgrState, keys, + keys5, + key4: keyFor(4, 0), + offer: offer || null, // { sk, pk } — the CLINK offer service keypair connections: (connections || []).map((c) => ({ id: c.id, servicePk: c.servicePk, serviceSk: c.serviceSk, clientPk: c.clientPk, maxSat: c.maxSat, dailySat: c.dailySat, |
