Skip to content

Commit

Permalink
fix: improve LND HTLC acceptance logging
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Feb 7, 2024
1 parent d0dbe53 commit ce4824b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 9 additions & 2 deletions lib/lightning/LndClient.ts
Expand Up @@ -861,16 +861,23 @@ class LndClient extends BaseClient<EventTypes> implements LightningClient {

const deleteSubscription = () => {
invoiceSubscription.removeAllListeners();
invoiceSubscription.destroy();
};

invoiceSubscription
.on('data', (invoice: lndrpc.Invoice) => {
if (invoice.getState() === lndrpc.Invoice.InvoiceState.ACCEPTED) {
const acceptedHtlcs = invoice
.getHtlcsList()
.filter(
(htlc) => htlc.getState() === lndrpc.InvoiceHTLCState.ACCEPTED,
);

this.logger.debug(
`${LndClient.serviceName} ${this.symbol} accepted ${
invoice.getHtlcsList().length
acceptedHtlcs.length
} HTLC${
invoice.getHtlcsList().length > 1 ? 's' : ''
acceptedHtlcs.length > 1 ? 's' : ''
} for invoice: ${invoice.getPaymentRequest()}`,
);

Expand Down
8 changes: 6 additions & 2 deletions tools/stats.sql
Expand Up @@ -176,5 +176,9 @@ SELECT
EXTRACT(DAY FROM "createdAt") AS day,
SUM(fee) AS revenue
FROM marked
GROUP BY year, month, day
ORDER BY year, month, day;
GROUP BY GROUPING SETS (
(year, month, day),
(year, month),
(year)
)
ORDER BY year, month NULLS LAST , day NULLS LAST;

0 comments on commit ce4824b

Please sign in to comment.