From 4ca5dd0afa7848d100f0b99be7b53f5dcb2fd061 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 1 Aug 2026 17:49:50 -0700 Subject: Never let a losing device's error shout over a paid zap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Loose leader election for pay_invoice across a user's open tabs: before handling, defer a beat and stay silent if any reply for the request already exists on the relays; and before sending an ERROR reply, re-check — a device that lost the race (mid-init, stale state) was replying 'superseded' after another device's success, and clients trusted the later error, marking paid zaps as failed. Co-Authored-By: Claude Fable 5 --- tools/nwc-test.js | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/nwc-test.js b/tools/nwc-test.js index 7b7f8c3..d1d0cbc 100644 --- a/tools/nwc-test.js +++ b/tools/nwc-test.js @@ -18,6 +18,7 @@ const published = []; const nwcTransport = { subscribe: (relays, filter, on) => { subHandler = on; return () => { subHandler = null; }; }, publish: async (relays, evt) => { published.push(evt); return true; }, + query: async () => [], // no other device has answered anything in tests }; let paid = []; const wallet = { -- cgit v1.2.3