Repository navigation
fix(payments): parse ISO 8601 time/expiry returned by LNbits >= 1.0 - #943
Merged
Merged
Conversation
LNbits 1.x returns details.time and details.expiry as ISO 8601 strings
("2025-10-11T15:24:27+00:00") instead of unix seconds, so
`new Date(value * 1000)` produced Invalid Date. Paid admissions were
never confirmed (confirmInvoice throws RangeError on
confirmedAt.toISOString()) and expired invoices stayed pending forever.
Accept both unix seconds (LNbits < 1.0) and ISO strings.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116ucVjyUPmPdBqnQsWxEws
🦋 Changeset detectedLatest commit: c7de11d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
[Medium impact] The PR appears safe to merge.
|
cameri
approved these changes
Oct 23, 2026
Collaborator
Coverage Report for CI Build 40017127422Coverage increased (+0.004%) to 75.458%Details
Uncovered Changes
Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picks Perlover's commit
5ffad56from their fork (Perlover/nostream, branchfix/lnbits-iso-dates) onto currentmain. The contributor could not open the PR themselves — GitHub refusedCreatePullRequestfor their account — so this PR carries their work with authorship intact: the commit keepsAuthor: Perlover <perlover@perlover.com>, and the change is unmodified.Closes #927
The bug
LNbits 1.x returns
details.timeanddetails.expiryas ISO 8601 strings; LNbits 0.x returned unix seconds.LNbitsPaymentsProcessormultiplied by 1000 unconditionally, sonew Date(value * 1000)yieldedInvalid Dateagainst a 1.x server. Two consequences, both in the issue's reproduction:confirmInvoicecalledconfirmedAt.toISOString()→RangeError: Invalid time value, so a paid admission was never confirmed.isExpiredInvoice()was false for an invalidexpiresAt, so unpaid invoices were re-saved aspendingon every maintenance pass and never retired.The fix
A
toDatehelper accepting either shape, used fortime/expiryin bothgetInvoiceandcreateInvoice:This keeps LNbits 0.x working — the
numberbranch is the old behaviour, unchanged.Verification on this branch
Run in a clean worktree at
e417437(currentmain) withbun install:mocha test/unit/payments-processors/lnbits-payment-processor.spec.tsHEAD~1expected 'pending' to equal 'expired'andRangeError: Invalid time valuebiome linton both changed filesbiome formattsc --noEmitThe failing run reproduces both failures the issue describes, on the same two tests the commit adds, so the tests are shown to catch the bug rather than merely accompany the fix.
Credit
Original author: Perlover (https://github.com/Perlover) — commit
5ffad56, reported and diagnosed in #927. Thanks for the unit-level reproduction, which made this quick to confirm.