From 7199b0f72b34e630e358f15f1a9351a58fa3008b Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 8 Nov 2024 22:06:10 +0000 Subject: logging --- lib/nwc.ts | 38 +++++++++++++++++++++----------------- lib/payments.ts | 5 ++--- 2 files changed, 23 insertions(+), 20 deletions(-) (limited to 'lib') diff --git a/lib/nwc.ts b/lib/nwc.ts index 0cbced1f..28675291 100644 --- a/lib/nwc.ts +++ b/lib/nwc.ts @@ -45,23 +45,27 @@ export default () => { const uid = await g(pubkey); const user = await g(`user:${uid}`); - const result = await handle(method, params, user); - const payload = JSON.stringify({ result_type: method, ...result }); - content = await nip04.encrypt(sk, pubkey, payload); - - let response: UnsignedEvent = { - created_at: Math.floor(Date.now() / 1000), - kind: 23195, - pubkey: serverPubkey, - tags: [ - ["p", pubkey], - ["e", ev.id], - ], - content, - }; - - response = await finalizeEvent(response, sk); - r.send(["EVENT", response]); + try { + const result = await handle(method, params, user); + const payload = JSON.stringify({ result_type: method, ...result }); + content = await nip04.encrypt(sk, pubkey, payload); + + let response: UnsignedEvent = { + created_at: Math.floor(Date.now() / 1000), + kind: 23195, + pubkey: serverPubkey, + tags: [ + ["p", pubkey], + ["e", ev.id], + ], + content, + }; + + response = await finalizeEvent(response, sk); + r.send(["EVENT", response]); + } catch(e) { + err("problem with nwc", user.username, params, e.message); + } } catch (e) { err("problem with nwc", e.message); } diff --git a/lib/payments.ts b/lib/payments.ts index 0f55368f..0ae84f10 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -457,7 +457,6 @@ export const sendLightning = async ({ invstring: pr.replace(/\s/g, "").toLowerCase(), amount_msat: amount_msat ? undefined : amount * 1000, maxfee: maxfee ? maxfee * 1000 : 0, - retry_for: 10, }); try { @@ -737,7 +736,7 @@ const reverse = async (p) => { const ourfee = p.ourfee || 0; const credit = Math.round(total * config.fee) - ourfee; - const k = await db.reverse( + await db.reverse( `payment:${p.id}`, `balance:${p.uid}`, `credit:${types.lightning}:${p.uid}`, @@ -749,5 +748,5 @@ const reverse = async (p) => { p.hash, ); - warn("reversed", k); + warn("reversed", p.hash); }; -- cgit v1.2.3