From 0519a79ac05ec983ae7ad8d4292f5cfa9fa321a9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 1 Aug 2026 11:02:37 -0700 Subject: NWC: own the relay set instead of borrowing the sync feature's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The connection URI advertised up to four relays (sync relays + profile relays) while the subscription only ever listened on the sync relay, so a client could publish its request somewhere hal wasn't and spin forever waiting for a reply. Amethyst did exactly that. NWC now has its own relay list used for all three things that must agree: the URI, the subscription, and the replies. It no longer depends on device sync being enabled, which would otherwise have made the whole wallet service a silent no-op. Also republish the kind 13194 capability event on every start — a client that can't find it just spins, and a single publish at creation time is easy for a relay to miss. The relay transport is now injectable so the protocol can be exercised without a live relay (tools/nwc-test.js). Co-Authored-By: Claude Fable 5 --- tools/nwc-test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/nwc-test.js b/tools/nwc-test.js index e22c5d2..3df0f28 100644 --- a/tools/nwc-test.js +++ b/tools/nwc-test.js @@ -14,6 +14,11 @@ globalThis.localStorage = { getItem:k=>k in store?store[k]:null, setItem:(k,v)=> let subHandler = null; const published = []; +// fake relay transport: capture the subscription handler and any replies +const nwcTransport = { + subscribe: (relays, filter, on) => { subHandler = on; return () => { subHandler = null; }; }, + publish: async (relays, evt) => { published.push(evt); return true; }, +}; let paid = []; const wallet = { watchOnly: false, @@ -31,7 +36,7 @@ const hooks = { arkMovements: () => ([{ type:'ln-send', status:'complete', amountSat: 25, ts: Date.now(), invoice:'lnbc250n1', preimage:'ef'.repeat(32) }]), }; const ctx = { h:()=>null, ui:{}, render:()=>{}, wallet, hook:(n,...a)=>hooks[n]?hooks[n](...a):null, - fmtAmount:(n)=>String(n), unitLabel:()=>'sats', copyBtn:()=>null, toast:()=>{} }; + fmtAmount:(n)=>String(n), unitLabel:()=>'sats', copyBtn:()=>null, toast:()=>{}, nwcTransport }; const f = nwcFeature(ctx); f.init(); -- cgit v1.2.3