diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/app.ts | 1 | ||||
| -rw-r--r-- | lib/health.ts | 10 | ||||
| -rw-r--r-- | lib/ln.ts | 2 | ||||
| -rw-r--r-- | lib/nwc.ts | 10 | ||||
| -rw-r--r-- | lib/payments.ts | 9 |
5 files changed, 13 insertions, 19 deletions
@@ -118,6 +118,7 @@ app.register(fastifyProxy, { prefix: "/ws", rewritePrefix: "/ws", websocket: true, + disableRequestLogging: true, }); app.register(fastifySecureSession, { diff --git a/lib/health.ts b/lib/health.ts index c2e268c6..d9c38fa5 100644 --- a/lib/health.ts +++ b/lib/health.ts @@ -37,7 +37,7 @@ async function checkLightningHealth(): Promise<boolean> { const startTime = Date.now(); try { - l("health check: testing lightning connection..."); + // l("health check: testing lightning connection..."); const info = await withTimeout(ln.getinfo(), RPC_TIMEOUT, "getinfo"); if (!info?.id) { @@ -71,7 +71,7 @@ async function checkLightningHealth(): Promise<boolean> { } const duration = Date.now() - startTime; - l(`health check: passed in ${duration}ms, node: ${info.id.slice(0, 16)}...`); + // l(`health check: passed in ${duration}ms, node: ${info.id.slice(0, 16)}...`); return true; } catch (e: any) { @@ -139,9 +139,9 @@ export async function runHealthCheck() { } export function startHealthCheck() { - l( - `health check: starting (interval=${HEALTH_CHECK_INTERVAL / 1000}s, timeout=${RPC_TIMEOUT / 1000}s, max_failures=${MAX_CONSECUTIVE_FAILURES})`, - ); + // l( + // `health check: starting (interval=${HEALTH_CHECK_INTERVAL / 1000}s, timeout=${RPC_TIMEOUT / 1000}s, max_failures=${MAX_CONSECUTIVE_FAILURES})`, + // ); // Run first check after a delay to let the app initialize checkTimer = setTimeout(runHealthCheck, 30000); } @@ -123,7 +123,7 @@ export default ln; // Dedicated proxy for long-polling (waitanyinvoice) — uses its own socket // so it doesn't block the main connection -export const lnListen = lightningProxy(config.lightning); +export const lnListen = lightningProxy(config.lightningListen || config.lightning); export const lnb = lightningProxy(config.lightningb); export { LightningUnavailableError }; @@ -185,14 +185,6 @@ const handle = (method, params, ev, app, user) => ); if (!created) { - warn( - "old nwc token", - pubkey, - user?.username, - spent, - amount, - max_amount, - ); return error({ code: "UNAUTHORIZED", message: `This NWC connection is no longer valid please create a new one at https://coinos.io/settings/nostr`, @@ -334,7 +326,7 @@ const handle = (method, params, ev, app, user) => async make_invoice() { const { amount, description, description_hash, expiry } = params; - l("nwc make_invoice", user.username); + // l("nwc make_invoice", user.username); const invoice = { amount: Math.round(amount / 1000), diff --git a/lib/payments.ts b/lib/payments.ts index 53b8dec1..151d4c99 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -309,7 +309,6 @@ export const completePayment = async (inv, p, user) => { }; } } catch (e) { - console.log(e); withdrawal = { failed: true }; warn(username, "autowithdraw failed", e.message); } @@ -543,11 +542,12 @@ export const sendLightning = async ({ payee = invoice_node_id; } - let minfee = 2; + const amt = amount_msat ? Math.round(amount_msat / 1000) : amount; + let minfee = Math.max(5, Math.round(amt * 0.005)); const { channels } = await ln.listpeerchannels(); if (channels.some((c) => c.peer_id === payee)) minfee = 0; - fee = Math.max(Number.parseInt(fee || 0), minfee); + fee = Math.max(Number.parseInt(fee) || minfee, minfee); if (fee < 0) fail("Fee cannot be negative"); const { pays } = await ln.listpays(pr); @@ -576,7 +576,8 @@ export const sendLightning = async ({ // bolt11: pr.replace(/\s/g, "").toLowerCase(), amount_msat: amount_msat ? undefined : amount * 1000, maxfee: fee * 1000, - retry_for: 10, + retry_for: 30, + layers: ["prefer-kappa"], }); try { |
