@@ -5,13 +5,12 @@ use core::convert::TryFrom;
55use bitcoin:: hashes:: hmac:: { Hmac , HmacEngine } ;
66use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
77use bitcoin:: hashes:: { Hash , HashEngine } ;
8- use chrono:: Utc ;
98use serde:: { Deserialize , Serialize } ;
109
1110use lightning:: util:: scid_utils;
1211
1312use crate :: lsps0:: ser:: {
14- string_amount, string_amount_option, LSPSMessage , LSPSRequestId , LSPSResponseError ,
13+ string_amount, string_amount_option, DateTime , LSPSMessage , LSPSRequestId , LSPSResponseError ,
1514} ;
1615use crate :: prelude:: { String , Vec } ;
1716use crate :: utils;
@@ -42,7 +41,7 @@ pub struct LSPS2RawOpeningFeeParams {
4241 /// A fee proportional to the size of the initial payment.
4342 pub proportional : u32 ,
4443 /// An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid.
45- pub valid_until : chrono :: DateTime < Utc > ,
44+ pub valid_until : DateTime ,
4645 /// The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing.
4746 pub min_lifetime : u32 ,
4847 /// The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter.
@@ -93,7 +92,7 @@ pub struct LSPS2OpeningFeeParams {
9392 /// A fee proportional to the size of the initial payment.
9493 pub proportional : u32 ,
9594 /// An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid.
96- pub valid_until : chrono :: DateTime < Utc > ,
95+ pub valid_until : DateTime ,
9796 /// The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing.
9897 pub min_lifetime : u32 ,
9998 /// The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter.
@@ -214,15 +213,17 @@ impl From<LSPS2Message> for LSPSMessage {
214213#[ cfg( test) ]
215214mod tests {
216215 use super :: * ;
216+
217217 use crate :: alloc:: string:: ToString ;
218218 use crate :: lsps2:: utils:: is_valid_opening_fee_params;
219219
220+ use core:: str:: FromStr ;
221+
220222 #[ test]
221223 fn into_opening_fee_params_produces_valid_promise ( ) {
222224 let min_fee_msat = 100 ;
223225 let proportional = 21 ;
224- let valid_until: chrono:: DateTime < Utc > =
225- chrono:: DateTime :: parse_from_rfc3339 ( "2035-05-20T08:30:45Z" ) . unwrap ( ) . into ( ) ;
226+ let valid_until = DateTime :: from_str ( "2035-05-20T08:30:45Z" ) . unwrap ( ) ;
226227 let min_lifetime = 144 ;
227228 let max_client_to_self_delay = 128 ;
228229 let min_payment_size_msat = 1 ;
@@ -257,7 +258,7 @@ mod tests {
257258 fn changing_single_field_produced_invalid_params ( ) {
258259 let min_fee_msat = 100 ;
259260 let proportional = 21 ;
260- let valid_until = chrono :: DateTime :: parse_from_rfc3339 ( "2035-05-20T08:30:45Z" ) . unwrap ( ) ;
261+ let valid_until = DateTime :: from_str ( "2035-05-20T08:30:45Z" ) . unwrap ( ) ;
261262 let min_lifetime = 144 ;
262263 let max_client_to_self_delay = 128 ;
263264 let min_payment_size_msat = 1 ;
@@ -266,7 +267,7 @@ mod tests {
266267 let raw = LSPS2RawOpeningFeeParams {
267268 min_fee_msat,
268269 proportional,
269- valid_until : valid_until . into ( ) ,
270+ valid_until,
270271 min_lifetime,
271272 max_client_to_self_delay,
272273 min_payment_size_msat,
@@ -284,7 +285,7 @@ mod tests {
284285 fn wrong_secret_produced_invalid_params ( ) {
285286 let min_fee_msat = 100 ;
286287 let proportional = 21 ;
287- let valid_until = chrono :: DateTime :: parse_from_rfc3339 ( "2035-05-20T08:30:45Z" ) . unwrap ( ) ;
288+ let valid_until = DateTime :: from_str ( "2035-05-20T08:30:45Z" ) . unwrap ( ) ;
288289 let min_lifetime = 144 ;
289290 let max_client_to_self_delay = 128 ;
290291 let min_payment_size_msat = 1 ;
@@ -293,7 +294,7 @@ mod tests {
293294 let raw = LSPS2RawOpeningFeeParams {
294295 min_fee_msat,
295296 proportional,
296- valid_until : valid_until . into ( ) ,
297+ valid_until,
297298 min_lifetime,
298299 max_client_to_self_delay,
299300 min_payment_size_msat,
@@ -313,7 +314,7 @@ mod tests {
313314 fn expired_params_produces_invalid_params ( ) {
314315 let min_fee_msat = 100 ;
315316 let proportional = 21 ;
316- let valid_until = chrono :: DateTime :: parse_from_rfc3339 ( "2023-05-20T08:30:45Z" ) . unwrap ( ) ;
317+ let valid_until = DateTime :: from_str ( "2023-05-20T08:30:45Z" ) . unwrap ( ) ;
317318 let min_lifetime = 144 ;
318319 let max_client_to_self_delay = 128 ;
319320 let min_payment_size_msat = 1 ;
@@ -322,7 +323,7 @@ mod tests {
322323 let raw = LSPS2RawOpeningFeeParams {
323324 min_fee_msat,
324325 proportional,
325- valid_until : valid_until . into ( ) ,
326+ valid_until,
326327 min_lifetime,
327328 max_client_to_self_delay,
328329 min_payment_size_msat,
@@ -339,7 +340,7 @@ mod tests {
339340 fn buy_request_serialization ( ) {
340341 let min_fee_msat = 100 ;
341342 let proportional = 21 ;
342- let valid_until = chrono :: DateTime :: parse_from_rfc3339 ( "2023-05-20T08:30:45Z" ) . unwrap ( ) ;
343+ let valid_until = DateTime :: from_str ( "2023-05-20T08:30:45Z" ) . unwrap ( ) ;
343344 let min_lifetime = 144 ;
344345 let max_client_to_self_delay = 128 ;
345346 let min_payment_size_msat = 1 ;
@@ -348,7 +349,7 @@ mod tests {
348349 let raw = LSPS2RawOpeningFeeParams {
349350 min_fee_msat,
350351 proportional,
351- valid_until : valid_until . into ( ) ,
352+ valid_until,
352353 min_lifetime,
353354 max_client_to_self_delay,
354355 min_payment_size_msat,
0 commit comments