diff options
| author | Adam Soltys <[email protected]> | 2026-08-14 00:31:07 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-14 00:31:07 -0700 |
| commit | c61f8775b724b079b25d01964ece7dd3064845fe (patch) | |
| tree | a5a0da633834845ef4879f967383ad4c5d679e1b /names | |
| parent | 057fe8ea706566f281a229c746030c15f30e82bf (diff) | |
| download | coinosv3-server-c61f8775b724b079b25d01964ece7dd3064845fe.tar.gz coinosv3-server-c61f8775b724b079b25d01964ece7dd3064845fe.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
Diffstat (limited to 'names')
| -rw-r--r-- | names/server.js | 10 |
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); |
