-
Notifications
You must be signed in to change notification settings - Fork 79
std::time::SystemTime has nanosecond precision but Payjoin only sees u32 UnixTime second precision#893Description
In roundtrip testing a new concrete v2::PjParams struct I realized SystemTime includes nanosecond precision. After serializing SystemTime into the EX1 u32 expiration parameter, and deserializing back into the type that precision is lost and an assert_eq failed, raising this issue, since we are storing time as SystemTime in many parts of the payjoin crate.
It seems to me that encoding this information internally as precise as the URL-serialized representation would be more accurate. For this purpose we may even use bitcoin::absolute::Time. Other than accuracy, changing to a u32 UnixTime abstraction gives us the advantage that u32 would work in wasm where SystemTime is not available.
I think this may be a good first issue to start, but it might be tricky to get the ergonomics right to completely close this issue. We'd need to figure out what type (u64, u32, or bitcoin::absolute::Time?) to expose in the API arguments and across the FFI boundary even if the internal representation becomes absolute::Time. We may take a look at how conversion ergonomics from SystemTime::now() to bitcoin::absolute::Time (or similar functionality) are designed as inspiration.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status