From dd1489303f59ccef6b322142f94e08d750c06e79 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 14 Sep 2026 09:16:23 -0700 Subject: A zap answers as fast as the route allows. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wallet used to add two to four seconds of its own around a Lightning send: a random pause plus a relay look-back before paying, and a two-second poll for the result after. The notifier's claim now decides who pays in one round trip, with the relay look-back kept only for replays and for when the notifier gives no verdict; a phone answering from behind another app waits a second so a desktop tab wins the claim instead of paying at a throttled crawl. After the send, one held CheckLightningPayment call brings the preimage the moment CLN has it — for wallet-connect pays, the background worker, and the app's own Send. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01QYJfZ4A1TDCEY4Foq3CApR --- src/ark/manager.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/ark/manager.js') diff --git a/src/ark/manager.js b/src/ark/manager.js index 5775d65..c3a8b58 100644 --- a/src/ark/manager.js +++ b/src/ark/manager.js @@ -973,6 +973,21 @@ export class ArkManager { } } + // Wait on the server for a Lightning send to settle or fail, then drive + // the action to its terminal step. One held call instead of polling every + // couple of seconds — the preimage reaches the caller the moment CLN has + // it. A broken long call (proxy timeout, network) just returns the action + // as it stands, and the caller's polling takes over. + async awaitLnPay(id, timeoutMs = 90_000) { + const a = this.lnAction(id); + if (!a || a.step !== 'initiated') return this.driveLn(id); + await Promise.race([ + checkLightningPayment(this.arkUrl, hex.decode(a.paymentHash), true).catch(() => null), + new Promise((r) => setTimeout(r, timeoutMs)), + ]); + return this.driveLn(id); + } + lnAction(id) { return this.state.actions.find((a) => a.id === id && a.type.startsWith('ln-')); } -- cgit v1.2.3