diff options
| author | Adam Soltys <[email protected]> | 2026-11-25 09:25:18 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-25 09:25:18 -0700 |
| commit | 9225b8ddea10c15487271a7e4a4c9b26598fc45b (patch) | |
| tree | 624050dcfd53cfb8105194195871cbad11a4eb99 /lib/nwc.ts | |
| parent | 43b6d2a4e16f1991a02a77f2198bc83bb71deb04 (diff) | |
| download | coinos-server-9225b8ddea10c15487271a7e4a4c9b26598fc45b.tar.gz coinos-server-9225b8ddea10c15487271a7e4a4c9b26598fc45b.zip | |
nwc: floor the default routing fee cap at 5 sats
1% rounds to zero below 50 sats, which rejected small zaps whose route
costs a sat. Unused fee is refunded.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VMan6SEnsbshZrUDtTsxAX
Diffstat (limited to 'lib/nwc.ts')
| -rw-r--r-- | lib/nwc.ts | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -59,6 +59,12 @@ const methods = [ ]; const week = 7 * 24 * 60 * 60; + +// Fee cap for a connection with no max fee of its own: 1% of the amount, but +// never under 5 sats. Plain 1% rounds to 0 below 50 sats, and a 0 cap rejects +// any zap whose route costs a single sat. Unused fee is refunded. +const defaultMaxFee = (amount: number) => + Math.max(5, Math.ceil(amount * 0.01)); const nwcEventMaxAgeSeconds = 5 * 60; // Tolerated clock skew for future-dated events. Events further ahead than this // are rejected so a captured, future-dated signed event can't be replayed later. @@ -704,7 +710,7 @@ const handle = (method, params, ev, app, user) => // payment had settled; see issue #80). const p = await sendLightning({ amount, - fee: max_fee || Math.round(amount * 0.01), + fee: max_fee || defaultMaxFee(amount), user, pr, memo: JSON.stringify(metadata), @@ -877,7 +883,7 @@ const handle = (method, params, ev, app, user) => try { const p = await sendLightning({ amount, - fee: app.max_fee || Math.round(amount * 0.01), + fee: app.max_fee || defaultMaxFee(amount), user, pr, memo: metadata ? JSON.stringify(metadata) : undefined, |
