Skip to content

lsps-types: replace the unmaintained chrono with jiff - #9753

Open
nepet wants to merge 3 commits into
ElementsProject:masterfrom
nepet:lsps-chrono-to-jiff
Open

nepet wants to merge 3 commits into
ElementsProject:masterfrom
nepet:lsps-chrono-to-jiff

Conversation

@nepet

@nepet nepet commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.
  • Important All PRs must consider how to reverse any persistent changes for tools/lightning-downgrade

Fixes #9752.

chrono is unmaintained (RUSTSEC-2026-0543, informational). lsps-types exposed it in its public API, so this replaces it with jiff as a private dependency and bumps lsps-types to 0.8.0. The only known users of lsps-types are the CLN LSPS plugin and the blsp LSPS2 service, so this is a clean break without a compatibility feature.

API changes in lsps-types

Removed: DateTime::as_chrono() and the conversions to and from chrono::DateTime<Utc>.

Added:

  • DateTime::now(), DateTime::from_unix_millis(), DateTime::unix_millis()
  • DateTime::checked_add(std::time::Duration)
  • TryFrom<SystemTime> for DateTime and TryFrom<DateTime> for SystemTime
  • FromStr, which parses like deserializing
  • DateTime::to_rfc3339(), which writes the same string as chrono's to_rfc3339() and is meant for the promise HMAC
  • DateTimeError

Unchanged: local values are truncated to milliseconds and serialize as YYYY-MM-DDThh:mm:ss.uuuZ. Parsed values keep full precision and echo the string they came from.

Behaviour changes

  • Parsing accepts exactly an RFC 3339 date-time with up to nine fractional digits and Z or a +hh:mm/-hh:mm offset. Leap seconds, offsets without a colon (+0200) and more than nine fractional digits were accepted by chrono and are now rejected.
  • Display writes 2023-02-23T08:47:30.511Z instead of chrono's 2023-02-23 08:47:30.511 UTC. This shows up in a few plugin error messages.

DateTime stores a jiff::civil::DateTime in UTC rather than a jiff::Timestamp, because a Timestamp ends at 9999-12-30T22:00:00Z and datetimes up to the end of the year 9999 must keep parsing. The fields of the fixed RFC 3339 layout are parsed directly, and jiff does the calendar validation and arithmetic. jiff is built without its time zone features, everything is UTC.

The promise is an HMAC over the opening fee params in which valid_until
enters as chrono's to_rfc3339(), e.g. "2026-11-05T12:00:00.123+00:00".
That string is not the LSPS0 wire format and no spec fixes it, but
formatting it any differently voids every offer an LSP handed out and
hasn't sold yet. Pin it before chrono is replaced, so a replacement has
to reproduce it.

The vectors are the ones blsp's lsps2-service pins, which verifies
promises this plugin issued, so the two stay in agreement.

Changelog-None
core/lsps2/mod.rs doesn't declare it, so it isn't compiled. The live
LSPS2 service handler is in core/lsps2/service.rs and the HTLC handling
in core/lsps2/htlc.rs.

Changelog-None
chrono is unmaintained (RUSTSEC-2026-0543). lsps-types exposed it in
its API through DateTime::as_chrono() and the conversions to and from
chrono::DateTime<Utc>. Those are gone. jiff is a private dependency, so
callers only see DateTime and std types:

  - DateTime::now(), DateTime::from_unix_millis(), DateTime::unix_millis()
  - DateTime::checked_add(std::time::Duration)
  - TryFrom<SystemTime> for DateTime and TryFrom<DateTime> for SystemTime
  - FromStr, which parses like deserializing
  - DateTime::to_rfc3339(), the format of chrono's to_rfc3339()
  - DateTimeError for parse and range errors

Values built locally are still truncated to milliseconds and serialize
as "YYYY-MM-DDThh:mm:ss.uuuZ". Parsed values still keep full precision
and echo the string they came from.

DateTime holds a jiff::civil::DateTime in UTC rather than a
jiff::Timestamp: a Timestamp ends at 9999-12-30T22:00:00Z, and
datetimes up to the end of the year 9999 must keep parsing.

Parsing now takes exactly an RFC 3339 date-time, YYYY-MM-DDThh:mm:ss
with up to nine fractional digits and Z or a +hh:mm/-hh:mm offset ("t"
or a space for "T" and "z" for "Z" allowed). chrono also accepted leap
seconds, offsets without a colon and more than nine fractional digits.
Those are now rejected. Display now writes RFC 3339 in UTC
("2023-02-23T08:47:30.511Z") instead of chrono's
"2023-02-23 08:47:30.511 UTC".

The LSPS2 promise hashes valid_until as chrono's to_rfc3339() wrote
it, so the plugin now uses DateTime::to_rfc3339(), which writes the
same string. The pinned promise vectors pass unchanged. The plugin
moves off chrono as well, which removes it from the workspace.

lsps-types goes to 0.8.0.

Changelog-Changed: lsps-plugin: datetimes in LSPS messages must be RFC 3339. Leap seconds and offsets without a colon are no longer accepted.
@nepet
nepet requested a review from daywalker90 November 20, 2026 11:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lsps-crates: chrono now unmaintained

1 participant