From a89b891a3311104f2cc34d75d97b84774924befa Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 23 Dec 2023 00:26:26 +0000 Subject: cltv default --- lib/invoices.js | 3 ++- lib/lightning.js | 2 -- lib/payments.js | 14 ++++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/invoices.js b/lib/invoices.js index 0cf2d72b..23af1aa4 100644 --- a/lib/invoices.js +++ b/lib/invoices.js @@ -46,6 +46,7 @@ export let generate = async ({ invoice, user, sender, memo }) => { description: memo || "", expiry: expiry || 60 * 60 * 24 * 30, deschashonly: true, + cltv: 19 }); hash = r.bolt11; @@ -79,7 +80,7 @@ export let generate = async ({ invoice, user, sender, memo }) => { webhook, }; - l(type, "invoice", user.username, amount); + if (!user.username === 'lightningins') l(type, "invoice", user.username, amount); await s(`invoice:${hash}`, id); await s(`invoice:${id}`, invoice); diff --git a/lib/lightning.js b/lib/lightning.js index 8bde9633..9400a449 100644 --- a/lib/lightning.js +++ b/lib/lightning.js @@ -25,8 +25,6 @@ export async function listenForLightning() { let received = Math.round(amount_received_msat / 1000); try { - l("incoming lightning payment", received); - if (!preimage) return; let id = await g(`invoice:${bolt11}`); diff --git a/lib/payments.js b/lib/payments.js index c76bea70..92cd0760 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -70,7 +70,7 @@ export let debit = async ({ amount || 0, tip || 0, fee || 0, - ourfee || 0, + ourfee || 0 ); if (r !== "ok") fail("Problem debiting account"); @@ -133,7 +133,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { if (Math.abs(invoice.rate / store.rates[invoice.currency] - 1) < 0.01) { rate = equivalentRate; } else { - warn("rate slipped", hash, invoice.rate, equivalentRate); + // warn("rate slipped", hash, invoice.rate, equivalentRate); } let id = v4(); @@ -176,7 +176,9 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { .incrBy(`${balance}:${uid}`, amount) .exec(); - l("received", type, username, amount, tip); + if (!username.startsWith("lightning")) + l(username, "received", type, amount, tip); + emit(uid, "payment", p); notify(user, `Received ${amount} sats`); callWebhook(invoice, p); @@ -187,7 +189,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { sats: "⚡️" + new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format( - p.amount, + p.amount ), link: `${process.env.URL}/payment/${p.id}`, }); @@ -195,12 +197,12 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { mqtt1.publish( username, - `pay:${p.amount}:${p.tip}:${p.rate}:${p.created}:${p.id}`, + `pay:${p.amount}:${p.tip}:${p.rate}:${p.created}:${p.id}` ); mqtt2.publish( username, - `pay:${p.amount}:${p.tip}:${p.rate}:${p.created}:${p.id}`, + `pay:${p.amount}:${p.tip}:${p.rate}:${p.created}:${p.id}` ); return p; -- cgit v1.2.3