aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-14 00:31:07 -0700
committerAdam Soltys <[email protected]>2026-08-14 00:31:07 -0700
commit8a75debb215a3e7a5697b1a5da7a9894222a290c (patch)
tree40671c36bd61b652f1b5290c40a5b0357f8d64a2
parent106254b74b28a5d5e1390bacabaf08e5613a86f4 (diff)
downloadcoinosv3-8a75debb215a3e7a5697b1a5da7a9894222a290c.tar.gz
coinosv3-8a75debb215a3e7a5697b1a5da7a9894222a290c.zip
A route that costs less than a sat quotes as free — the ASP eats the msats, which mostly land back on our own node
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014tE4U5nEjGTQy8PwYqamfv
-rw-r--r--names/server.js10
1 files 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);