From cdd34e88be8a58c1cc9fa3d0cfbbd02b23439629 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 3 Aug 2026 14:02:25 -0700 Subject: Auto-withdraw runs with the app closed; fix the dead Back on the legacy step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The service worker can't watch a relay, so it doesn't try: the app resolves the destination to something concrete (ark address, LNURL endpoint, or on-chain script) and mirrors it beside the keys the background NWC payer already uses. On a push wake-up — which is exactly when money has just landed — the worker re-checks the same gate and sends, writing the outcome back into the mirror for the app to absorb on next open. A partial on-chain forward still waits for the app, since carving an exact vtxo needs more round trips than a worker is promised. writeBgMirror now carries forward the NWC connections and offer when another caller refreshes the mirror, instead of blanking them. And onboarding's legacy step loses its Back: the wallet exists by then, so returning to the nostr question just bounced straight forward again and the link looked broken. Its copy no longer promises a rename either. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01Wvj4aoeMZwA7VUGdJP9Swi --- src/nwc-respond.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nwc-respond.js') diff --git a/src/nwc-respond.js b/src/nwc-respond.js index fbbb98c..258b7e7 100644 --- a/src/nwc-respond.js +++ b/src/nwc-respond.js @@ -48,7 +48,7 @@ const spendableSat = (rec) => // The worker can't derive keys — the mirror carries them per chain: // 3 = coins/change, 4/0 = mailbox, 5 = receive preimages. -function shimAccount(rec) { +export function shimAccount(rec) { const byChain = (chain, i) => { const k = chain === 5 ? rec.keys5?.[String(i)] : chain === 4 ? rec.key4 @@ -59,7 +59,7 @@ function shimAccount(rec) { return { deriveChild: (chain) => ({ deriveChild: (i) => ({ privateKey: byChain(chain, i) }) }) }; } -async function bgManager(rec, walletKey, saveFn) { +export async function bgManager(rec, walletKey, saveFn) { const storage = { load: () => rec.mgr, save: (s) => { rec.mgr = s; saveFn(walletKey, rec).catch(() => {}); }, -- cgit v1.2.3