aboutsummaryrefslogtreecommitdiffstats
path: root/src/nwc-bg.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-28 00:22:33 -0700
committerAdam Soltys <[email protected]>2026-10-28 00:22:33 -0700
commit2302a4f0e25562c4d4977990918b86d4c6baba27 (patch)
tree7c187291cdafbfb50b8124dc3db7156ba258af79 /src/nwc-bg.js
parentf5c07454284a123070a0f0159919fc8c2de2b825 (diff)
downloadcoinosv3-2302a4f0e25562c4d4977990918b86d4c6baba27.tar.gz
coinosv3-2302a4f0e25562c4d4977990918b86d4c6baba27.zip
The background worker's key window is 250 keys (was 25: PullCap's hourly subscription ran out after 19 payments with the app closed, "key window exhausted"), derived once per account and memoized; 60 receive preimages (was 15). When the worker can't act on a request it still wakes the user, and now leaves a "wait, open the app" error with the notifier that goes out only if nobody answers within 20 s, so the other app hears something instead of silence and a sibling's real payment is never shouted over. A request older than its two-minute window (a push that waited at APNs) is ignored quietly instead of showing "Payment request"
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Diffstat (limited to 'src/nwc-bg.js')
-rw-r--r--src/nwc-bg.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/nwc-bg.js b/src/nwc-bg.js
index ab083d9..9e7a303 100644
--- a/src/nwc-bg.js
+++ b/src/nwc-bg.js
@@ -133,8 +133,15 @@ export async function allBgs() {
}
// How many upcoming change/refund indices travel with the record: the worker
-// cannot derive keys, so its allocations must land inside this window.
-export const BG_KEY_LOOKAHEAD = 25;
+// cannot derive keys, so its allocations must land inside this window. Each
+// Lightning send burns a change and an HTLC index, so 25 keys lasted PullCap
+// about 19 hourly payments (2026-10-26, "key window exhausted" after a day
+// with the app closed). 250 keys are 16 KB in the record and cover weeks of
+// hourly payments, or years of monthly ones; the app tops the window up
+// every time it writes the mirror.
+export const BG_KEY_LOOKAHEAD = 250;
+// ...and the receive preimages a closed wallet can mint invoices with
+export const BG_RECV_LOOKAHEAD = 60;
// { ark } endpoints, the manager state to mirror, and a keyFor(chain, index)
// derive function (the caller owns the account node — it never enters this
@@ -153,7 +160,7 @@ export function buildBg({ ark, mgrState, keyFor, connections, offer, autowithdra
idx.add(0); // the receive-address key: mailbox/refund defaults land on it
for (const i of idx) keys[String(i)] = keyFor(3, i);
const keys5 = {};
- for (let i = 0; i < 15; i++) {
+ for (let i = 0; i < BG_RECV_LOOKAHEAD; i++) {
const n = (mgrState.nextLnRecvIndex || 0) + i;
keys5[String(n)] = keyFor(5, n);
}