diff options
| author | Adam Soltys <[email protected]> | 2026-06-14 12:38:29 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-06-17 07:47:48 -0700 |
| commit | af8e395dd9ed010fce0e3b92593d5ea6d39dc65a (patch) | |
| tree | b7734423601fd0ce14ec7e09eea5299677c3b448 | |
| parent | 58ae0b1d73992bdce4f44c19fde1585ea4312e29 (diff) | |
| download | coinos-server-af8e395dd9ed010fce0e3b92593d5ea6d39dc65a.tar.gz coinos-server-af8e395dd9ed010fce0e3b92593d5ea6d39dc65a.zip | |
nwc: fix make_invoice timestamps (ms -> seconds) breaking NWC clients
Port of master 0154bb06. generate() stores `created` in milliseconds, but
NWC make_invoice returned it directly as created_at and computed
expires_at = created_at + expiry. NWC timestamps are Unix SECONDS
(NIP-47), so clients parsed a ~1.78e12 expires_at that overflowed their
date types (ptcpay's .NET DateTimeOffset, issue #84). Convert created to
seconds. Fixes #84.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
| -rw-r--r-- | lib/nwc.ts | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -341,7 +341,14 @@ const handle = (method, params, ev, app, user) => expiry, }; - const { hash, created: created_at, paymentHash } = await generate({ invoice, user }); + const { hash, created, paymentHash } = await generate({ invoice, user }); + + // generate() stores `created` in milliseconds (Date.now()), but NWC + // timestamps are Unix SECONDS (NIP-47). Returning ms here produced an + // expires_at ~1.78e12 that overflowed clients' date parsers — e.g. + // ptcpay's .NET DateTimeOffset (issue #84: "Valid values are between + // -62135596800 and 253402300799"). Convert to seconds. + const created_at = Math.floor(created / 1000); return result({ type: "incoming", |
