From 8a75debb215a3e7a5697b1a5da7a9894222a290c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 14 Aug 2026 00:31:07 -0700 Subject: A route that costs less than a sat quotes as free — the ASP eats the msats, which mostly land back on our own node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_014tE4U5nEjGTQy8PwYqamfv --- names/server.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/names/server.js b/names/server.js index c76be68..976fe60 100644 --- a/names/server.js +++ b/names/server.js @@ -210,6 +210,12 @@ const ln = CFG.ln ? lnBackend(CFG.ln) : null; // -- routing-fee quotes (the /lnquote endpoint) ------------------------------ +// Sub-sat route fees round DOWN to a free quote: Ark locks are sat-granular, +// and captaind passes a 0 maxfee as an absent proto field, so xpay falls back +// to its default ~1% cap and the ASP absorbs the msats (which land on our own +// node whenever the route goes through it). Anything >= 1 sat rounds up. +const quoteSat = (msat) => (msat < 1000 ? 0 : Math.ceil(msat / 1000)); + let _ourNodeId = null; async function ourNodeId() { if (!_ourNodeId) _ourNodeId = (await ln.call('getinfo')).id; @@ -500,7 +506,7 @@ Bun.serve({ const finalCltv = dec.min_final_cltv_expiry || 18; try { const feeMsat = await routeFeeMsat(our, dest, amountMsat, finalCltv); - return json({ feeMsat, feeSat: Math.ceil(feeMsat / 1000), direct: false }); + return json({ feeMsat, feeSat: quoteSat(feeMsat), direct: false }); } catch (e) { // Private recipient: not in gossip, reachable only via the // invoice's route hints. Quote = route to the hint's public entry @@ -517,7 +523,7 @@ Bun.serve({ const toEntry = entry === our ? 0 : await routeFeeMsat(our, entry, amountMsat + hintFeeMsat, finalCltv); const feeMsat = toEntry + hintFeeMsat; - return json({ feeMsat, feeSat: Math.ceil(feeMsat / 1000), direct: false, hinted: true }); + return json({ feeMsat, feeSat: quoteSat(feeMsat), direct: false, hinted: true }); } } catch (e) { return json({ error: e.message || 'no route found' }, 404); -- cgit v1.2.3