From 5642b90b54084061cdbbf6f1dc70c38245b05d5f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 19 Nov 2024 13:50:35 -0800 Subject: min fee 5 sats --- lib/payments.ts | 12 ++++++------ routes/payments.ts | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/payments.ts b/lib/payments.ts index e950786f..11cd5eff 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -414,7 +414,7 @@ export const sendLightning = async ({ user, pr, amount, - maxfee = undefined, + fee = undefined, memo = undefined, }) => { let p; @@ -431,8 +431,8 @@ export const sendLightning = async ({ ? decoded.invoice_amount_msat : decoded.amount_msat; - if (maxfee) maxfee = parseInt(maxfee); - if (maxfee < 0) fail("Max fee cannot be negative"); + fee = Math.max(parseInt(fee || 0), 5); + if (fee < 0) fail("Fee cannot be negative"); const { pays } = await ln.listpays(pr); if (pays.find((p) => p.status === "complete")) @@ -444,7 +444,7 @@ export const sendLightning = async ({ p = await debit({ hash: pr, amount: total, - fee: maxfee || 0, + fee, memo, user, type: types.lightning, @@ -452,13 +452,13 @@ export const sendLightning = async ({ await db.sAdd("pending", pr); - l("paying lightning invoice", pr.substr(-8), total, amount, maxfee); + l("paying lightning invoice", pr.substr(-8), total, amount, fee); const r = await ln.pay({ // invstring: pr.replace(/\s/g, "").toLowerCase(), bolt11: pr.replace(/\s/g, "").toLowerCase(), amount_msat: amount_msat ? undefined : amount * 1000, - maxfee: maxfee ? maxfee * 1000 : 0, + maxfee: fee * 1000, retry_for: 20, }); diff --git a/routes/payments.ts b/routes/payments.ts index c8fd07dd..5a6eba91 100644 --- a/routes/payments.ts +++ b/routes/payments.ts @@ -157,9 +157,10 @@ export default { params: { hash }, } = req; const p = await getPayment(hash); - if (p.type === types.internal) p.with = await g(`user:${p.ref}`); + if (p?.type === types.internal) p.with = await g(`user:${p.ref}`); res.send(p); } catch (e) { + console.log(e); err("failed to get payment", e.message); bail(res, e.message); } -- cgit v1.2.3