From 845b7a60c6c4f8ddeffa162b5c8a17272ce2a838 Mon Sep 17 00:00:00 2001 From: hatim boufnichel Date: Mon, 18 Mar 2024 17:39:35 +0100 Subject: [PATCH] moar logs --- src/nostrMiddleware.ts | 3 ++- src/services/lnd/lnd.ts | 9 +++++---- src/services/main/paymentManager.ts | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/nostrMiddleware.ts b/src/nostrMiddleware.ts index b8feb834..83628271 100644 --- a/src/nostrMiddleware.ts +++ b/src/nostrMiddleware.ts @@ -20,8 +20,9 @@ export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSett let j: NostrRequest try { j = JSON.parse(event.content) + log("nostr event", j.rpcName || 'no rpc name') } catch { - console.error("invalid json event received", event.content) + log("ERROR", "invalid json event received", event.content) return } nostrTransport({ ...j, appId: event.appId }, res => { diff --git a/src/services/lnd/lnd.ts b/src/services/lnd/lnd.ts index b92ba9a6..a43e1fcf 100644 --- a/src/services/lnd/lnd.ts +++ b/src/services/lnd/lnd.ts @@ -167,7 +167,7 @@ export default class { if (tx.numConfirmations === 0) { // only process pending transactions, confirmed transaction are processed by the newBlock CB tx.outputDetails.forEach(output => { if (output.isOurAddress) { - this.log("received chan TX", Number(output.amount), "sats") + this.log("received chan TX", Number(output.amount), "sats", "for", output.address) this.addressPaidCb({ hash: tx.txHash, index: Number(output.outputIndex) }, output.address, Number(output.amount), false) } }) @@ -203,6 +203,7 @@ export default class { } async NewAddress(addressType: Types.AddressType): Promise { + this.log("generating new address") await this.Health() let lndAddressType: AddressType switch (addressType) { @@ -219,15 +220,15 @@ export default class { throw new Error("unknown address type " + addressType) } const res = await this.lightning.newAddress({ account: "", type: lndAddressType }, DeadLineMetadata()) + this.log("new address", res.response.address) return res.response } async NewInvoice(value: number, memo: string, expiry: number): Promise { - getLogger({})("adding invoice...") + this.log("generating new invoice for", value, "sats") await this.Health() - getLogger({})("lnd healthy") const res = await this.lightning.addInvoice(AddInvoiceReq(value, expiry, false, memo), DeadLineMetadata()) - getLogger({})("got the invoice") + this.log("new invoice", res.response.paymentRequest) return { payRequest: res.response.paymentRequest } } diff --git a/src/services/main/paymentManager.ts b/src/services/main/paymentManager.ts index 6840c3d2..a917b3e6 100644 --- a/src/services/main/paymentManager.ts +++ b/src/services/main/paymentManager.ts @@ -135,6 +135,7 @@ export default class { } async PayInvoice(userId: string, req: Types.PayInvoiceRequest, linkedApplication: Application): Promise { + this.log("paying invoice", req.invoice) const decoded = await this.lnd.DecodeInvoice(req.invoice) if (decoded.numSatoshis !== 0 && req.amount !== 0) { throw new Error("invoice has value, do not provide amount the the request")