diff --git a/src/amount.ml b/src/amount.ml index 26b9ed9d..3d8f6508 100644 --- a/src/amount.ml +++ b/src/amount.ml @@ -110,14 +110,6 @@ let make_exn value fraction currency = | Ok v -> v let bin = - let open Bin in - record make_exn - |+ field neint64 (fun t -> t.value) - |+ field neint32 (fun t -> t.fraction) - |+ field (bytes currency_len) (fun t -> pad_currency_string t.currency) - |> sealr - -let bin_nbo = let open Bin in record make_exn |+ field beint64 (fun t -> t.value) diff --git a/src/amount.mli b/src/amount.mli index f055430c..7ffeba71 100644 --- a/src/amount.mli +++ b/src/amount.mli @@ -23,5 +23,4 @@ val of_string : string -> (t, string) result (* - *) val jsont : t Jsont.t val bin : t Bin.t -val bin_nbo : t Bin.t (* [caqti] is in pg_type.ml *) diff --git a/src/api.ml b/src/api.ml index 9a63ce8b..6fbade8b 100644 --- a/src/api.ml +++ b/src/api.ml @@ -11,6 +11,7 @@ let protocol_version = "31:0:0" +open Time open Crypto open Signatures module DenominationHash = Hash.DenominationHash @@ -580,9 +581,9 @@ module GlobalFees = struct history_fee: Amount.t; account_fee: Amount.t; purse_fee: Amount.t; - history_expiration: Time.Relative.t; + history_expiration: TimeRelative.t; purse_account_limit: int32; - purse_timeout: Time.Relative.t; + purse_timeout: TimeRelative.t; master_sig: GlobalFees.t; } @@ -616,9 +617,9 @@ module GlobalFees = struct |> mem "history_fee" Amount.jsont ~enc:history_fee |> mem "account_fee" Amount.jsont ~enc:account_fee |> mem "purse_fee" Amount.jsont ~enc:purse_fee - |> mem "history_expiration" Time.Relative.jsont ~enc:history_expiration + |> mem "history_expiration" TimeRelative.jsont ~enc:history_expiration |> mem "purse_account_limit" Jsont.int32 ~enc:purse_account_limit - |> mem "purse_timeout" Time.Relative.jsont ~enc:purse_timeout + |> mem "purse_timeout" TimeRelative.jsont ~enc:purse_timeout |> mem "master_sig" GlobalFees.jsont ~enc:master_sig |> finish end @@ -762,7 +763,7 @@ module ExchangePartnerSetupRequest = struct type t = { partner_base_url: string; partner_pub: EddsaPublicKey.t; - wad_frequency: Time.Relative.t; + wad_frequency: TimeRelative.t; master_sig: PartnerConfiguration.t; start_date: Timestamp.t; end_date: Timestamp.t; @@ -792,7 +793,7 @@ module ExchangePartnerSetupRequest = struct map ~kind:"ExchangePartnerSetupRequest" make |> mem "partner_base_url" Jsont.string ~enc:partner_base_url |> mem "partner_pub" EddsaPublicKey.jsont ~enc:partner_pub - |> mem "wad_frequency" Time.Relative.jsont ~enc:wad_frequency + |> mem "wad_frequency" TimeRelative.jsont ~enc:wad_frequency |> mem "master_sig" PartnerConfiguration.jsont ~enc:master_sig |> mem "start_date" Timestamp.jsont ~enc:start_date |> mem "end_date" Timestamp.jsont ~enc:end_date @@ -807,7 +808,7 @@ module ExchangePartnerListEntry = struct partner_base_url: string; partner_master_pub: EddsaPublicKey.t; wad_fee: Amount.t; - wad_frequency: Time.Relative.t; + wad_frequency: TimeRelative.t; start_date: Timestamp.t; end_date: Timestamp.t; master_sig: WadPartnerSignature.t; @@ -837,7 +838,7 @@ module ExchangePartnerListEntry = struct |> mem "partner_base_url" Jsont.string ~enc:partner_base_url |> mem "partner_master_pub" EddsaPublicKey.jsont ~enc:partner_master_pub |> mem "wad_fee" Amount.jsont ~enc:wad_fee - |> mem "wad_frequency" Time.Relative.jsont ~enc:wad_frequency + |> mem "wad_frequency" TimeRelative.jsont ~enc:wad_frequency |> mem "start_date" Timestamp.jsont ~enc:start_date |> mem "end_date" Timestamp.jsont ~enc:end_date |> mem "master_sig" WadPartnerSignature.jsont ~enc:master_sig @@ -1061,7 +1062,7 @@ end module AccountLimit = struct type t = { operation_type: Account_operation.t; - timeframe: Time.Relative.t; + timeframe: TimeRelative.t; threshold: Amount.t; soft_limit: bool option; } @@ -1076,7 +1077,7 @@ module AccountLimit = struct let soft_limit v = v.soft_limit in map ~kind:"AccountLimit" make |> mem "operation_type" Account_operation.jsont ~enc:operation_type - |> mem "timeframe" Time.Relative.jsont ~enc:timeframe + |> mem "timeframe" TimeRelative.jsont ~enc:timeframe |> mem "threshold" Amount.jsont ~enc:threshold |> opt_mem "soft_limit" Jsont.bool ~enc:soft_limit |> finish @@ -1224,7 +1225,7 @@ module ExchangeKeysResponse = struct kyc_enabled: bool; disable_direct_deposit: bool; master_public_key: EddsaPublicKey.t; - reserve_closing_delay: Time.Relative.t; + reserve_closing_delay: TimeRelative.t; wallet_balance_limit_without_kyc: Amount.t list option; hard_limits: AccountLimit.t list; zero_limits: ZeroLimitedOperation.t list; @@ -1347,8 +1348,7 @@ module ExchangeKeysResponse = struct |> mem "kyc_enabled" Jsont.bool ~enc:kyc_enabled |> mem "disable_direct_deposit" Jsont.bool ~enc:disable_direct_deposit |> mem "master_public_key" EddsaPublicKey.jsont ~enc:master_public_key - |> mem "reserve_closing_delay" Time.Relative.jsont - ~enc:reserve_closing_delay + |> mem "reserve_closing_delay" TimeRelative.jsont ~enc:reserve_closing_delay |> opt_mem "wallet_balance_limit_without_kyc" (Jsont.list Amount.jsont) ~enc:wallet_balance_limit_without_kyc |> mem "hard_limits" (Jsont.list AccountLimit.jsont) ~enc:hard_limits diff --git a/src/config.ml b/src/config.ml index 6b44aa65..6db64eed 100644 --- a/src/config.ml +++ b/src/config.ml @@ -136,9 +136,9 @@ module Coin = struct type t = { section_name: string; value: Amount.t; - duration_withdraw: Time.Relative.t; - duration_spend: Time.Relative.t; - duration_legal: Time.Relative.t; + duration_withdraw: Time.TimeRelative.t; + duration_spend: Time.TimeRelative.t; + duration_legal: Time.TimeRelative.t; fee_withdraw: Amount.t; fee_deposit: Amount.t; fee_refresh: Amount.t; diff --git a/src/keys.ml b/src/keys.ml index f7ce0e87..1c2af9f2 100644 --- a/src/keys.ml +++ b/src/keys.ml @@ -87,11 +87,12 @@ module Make (Conn : Pg.CONN) : S = struct l let make_future_sk ~pub ~start ~expire = + let open Time in let stamp_start = Timestamp.of_absolute start in let stamp_expire = Timestamp.of_absolute expire in let stamp_end = Timestamp.of_absolute - @@ Time.Absolute.add start Config.Exchange.signkey_legal_duration + @@ TimeAbsolute.add start Config.Exchange.signkey_legal_duration in let signkey_secmod_sig = let open Signatures.SigningKeyAnnouncement in @@ -104,6 +105,7 @@ module Make (Conn : Pg.CONN) : S = struct { key= pub; stamp_start; stamp_expire; stamp_end; signkey_secmod_sig } let make_future_dn ~coin ~pub ~start = + let open Time in let Config.Coin. { section_name; @@ -123,13 +125,13 @@ module Make (Conn : Pg.CONN) : S = struct in let stamp_start = Timestamp.of_absolute start in let stamp_expire_withdraw = - Timestamp.of_absolute @@ Time.Absolute.add start duration_withdraw + Timestamp.of_absolute @@ TimeAbsolute.add start duration_withdraw in let stamp_expire_deposit = - Timestamp.of_absolute @@ Time.Absolute.add start duration_spend + Timestamp.of_absolute @@ TimeAbsolute.add start duration_spend in let stamp_expire_legal = - Timestamp.of_absolute @@ Time.Absolute.add start duration_legal + Timestamp.of_absolute @@ TimeAbsolute.add start duration_legal in let open Api in let rsa_denomination_key = diff --git a/src/parse_config.ml b/src/parse_config.ml index 8e53b77c..5e191bd8 100644 --- a/src/parse_config.ml +++ b/src/parse_config.ml @@ -119,7 +119,7 @@ module Config_duration = struct let duration = many1 duration_element <* end_of_input - (* TODO put this in Time.Relative *) + (* TODO put this in TimeRelative *) let dunit_to_seconds u = let rec f = function | `Year -> 365 * f `Day @@ -136,7 +136,7 @@ module Config_duration = struct (fun acc { number; dunit } -> acc + (number * dunit_to_seconds dunit)) 0 t |> Int64.of_int - |> Time.Relative.of_s + |> Time.TimeRelative.of_s let parse s : duration_element list = match parse_string ~consume:All duration s with diff --git a/src/pg_type.ml b/src/pg_type.ml index 3d5bfca3..546c0b4f 100644 --- a/src/pg_type.ml +++ b/src/pg_type.ml @@ -15,7 +15,7 @@ let amount : Amount.t t = not postgresql built-in timestamp type *) let ptime : unit t = Caqti_type.unit let time = Timestamp.caqti -let time_span = Time.Relative.caqti +let time_span = Time.TimeRelative.caqti let age_mask : int t = Caqti_type.int let rsa_pub = RsaPublicKey.caqti let eddsa_pub = EddsaPublicKey.caqti diff --git a/src/secmod_eddsa.ml b/src/secmod_eddsa.ml index 7eec6927..9aa95cd0 100644 --- a/src/secmod_eddsa.ml +++ b/src/secmod_eddsa.ml @@ -11,8 +11,8 @@ module Cfg = Config.Exchange_secmod_eddsa type key = { priv: EddsaPrivateKey.t; pub: EddsaPublicKey.t; - t1: Absolute.t; - t2: Absolute.t; + t1: TimeAbsolute.t; + t2: TimeAbsolute.t; } type t = { @@ -24,7 +24,7 @@ type t = { let parse_filename = let scan_filename s = Scanf.sscanf_opt s "%Lu-%Lu" (fun t1 t2 -> - (Absolute.of_s t1, Absolute.of_s t2)) + (TimeAbsolute.of_s t1, TimeAbsolute.of_s t2)) in fun fpath -> scan_filename (Fpath.filename fpath) @@ -81,18 +81,18 @@ let gen_key t1 t2 = (EddsaPublicKey.to_b32 pub)); { priv; pub; t1; t2 } -let sort_keys l = List.sort (fun a b -> Absolute.compare a.t2 b.t2) l +let sort_keys l = List.sort (fun a b -> TimeAbsolute.compare a.t2 b.t2) l let split_in_periodes ~start ~end_ = assert (start < end_); (* no overlap on first periode *) let t1 = start in - let t2 = Absolute.add start Cfg.duration in + let t2 = TimeAbsolute.add start Cfg.duration in let acc = [ (t1, t2) ] in let start = t2 in let rec go acc start end_ = - let t1 = Absolute.sub start Cfg.overlap_duration in - let t2 = Absolute.add start Cfg.duration in + let t1 = TimeAbsolute.sub start Cfg.overlap_duration in + let t2 = TimeAbsolute.add start Cfg.duration in if t2 > end_ then acc else go ((t1, t2) :: acc) t2 end_ in go acc start end_ @@ -103,10 +103,10 @@ let gen_additional_keys_until_lookahead ~now l = let start = match List.rev (sort_keys l) with | [] -> now - | hd :: _ -> Absolute.sub hd.t2 Cfg.overlap_duration + | hd :: _ -> TimeAbsolute.sub hd.t2 Cfg.overlap_duration in - let end_ = Absolute.add now Cfg.lookahead_sign in - if Absolute.compare start end_ >= 0 then [] + let end_ = TimeAbsolute.add now Cfg.lookahead_sign in + if TimeAbsolute.compare start end_ >= 0 then [] else let periodes = split_in_periodes ~start ~end_ in let new_keys = List.map (fun (t1, t2) -> gen_key t1 t2) periodes in @@ -159,19 +159,14 @@ let init () = let ht = Hashtbl.create 0xff in Ok { sm_key_priv; sm_pub; ht } in - let now = Absolute.of_ptime (Ptime_clock.now ()) in + let now = TimeAbsolute.of_ptime (Ptime_clock.now ()) in let keys = List.of_seq @@ Hashtbl.to_seq_values t.ht in let new_keys = gen_additional_keys_until_lookahead ~now keys in let () = List.iter (fun k -> Hashtbl.replace t.ht k.pub k) keys in let+ () = list_iter write_key new_keys in t -type info = eddsa_pub * Time.Absolute.t * Time.Absolute.t - module Make () = struct - type pub = EddsaPublicKey.t - type info = EddsaPublicKey.t * Time.Absolute.t * Time.Absolute.t - let t = match init () with | Error e -> Fmt.failwith "secmod_eddsa initialization failure: %s." e @@ -193,7 +188,7 @@ module Make () = struct let _delete_outdated ~now = Hashtbl.to_seq_values t.ht |> List.of_seq - |> List.filter (fun k -> Absolute.compare now k.t2 >= 0) + |> List.filter (fun k -> TimeAbsolute.compare now k.t2 >= 0) |> List.map (fun k -> k.pub) |> list_iter delete diff --git a/src/secmod_rsa.ml b/src/secmod_rsa.ml index c63fc46b..10bec6b7 100644 --- a/src/secmod_rsa.ml +++ b/src/secmod_rsa.ml @@ -45,8 +45,8 @@ type key = { priv: RsaPrivateKey.t; pub: RsaPublicKey.t; h_pub: DenominationHash.t; - t1: Absolute.t; - t2: Absolute.t; + t1: TimeAbsolute.t; + t2: TimeAbsolute.t; } type t = { @@ -58,7 +58,7 @@ type t = { let parse_filename = let scan_filename s = Scanf.sscanf_opt s "%Lu-%Lu" (fun t1 t2 -> - (Absolute.of_s t1, Absolute.of_s t2)) + (TimeAbsolute.of_s t1, TimeAbsolute.of_s t2)) in fun fpath -> scan_filename (Fpath.filename fpath) @@ -125,18 +125,18 @@ let gen_key ~section_name t1 t2 = (DenominationHash.to_octets h_pub |> B32.encode)); { section_name; priv; pub; h_pub; t1; t2 } -let sort_keys l = List.sort (fun a b -> Absolute.compare a.t2 b.t2) l +let sort_keys l = List.sort (fun a b -> TimeAbsolute.compare a.t2 b.t2) l let split_in_periodes ~start ~end_ ~duration_withdraw = assert (start < end_); (* no overlap on first periode *) let t1 = start in - let t2 = Absolute.add start duration_withdraw in + let t2 = TimeAbsolute.add start duration_withdraw in let acc = [ (t1, t2) ] in let start = t2 in let rec go acc start end_ = - let t1 = Absolute.sub start Cfg.overlap_duration in - let t2 = Absolute.add start duration_withdraw in + let t1 = TimeAbsolute.sub start Cfg.overlap_duration in + let t2 = TimeAbsolute.add start duration_withdraw in if t2 > end_ then acc else go ((t1, t2) :: acc) t2 end_ in go acc start end_ @@ -147,10 +147,10 @@ let gen_additional_keys_until_lookahead ~now ~section_name l = let start = match List.rev (sort_keys l) with | [] -> now - | hd :: _ -> Absolute.sub hd.t2 Cfg.overlap_duration + | hd :: _ -> TimeAbsolute.sub hd.t2 Cfg.overlap_duration in - let end_ = Absolute.add now Cfg.lookahead_sign in - if Absolute.compare start end_ >= 0 then [] + let end_ = TimeAbsolute.add now Cfg.lookahead_sign in + if TimeAbsolute.compare start end_ >= 0 then [] else let duration_withdraw = Cfg.duration_withdraw ~section_name in let periodes = split_in_periodes ~start ~end_ ~duration_withdraw in @@ -212,7 +212,7 @@ let init () = let ht = Hashtbl.create 0xff in Ok { sm_key_priv; sm_pub; ht } in - let now = Absolute.of_ptime (Ptime_clock.now ()) in + let now = TimeAbsolute.of_ptime (Ptime_clock.now ()) in let all_keys = List.of_seq @@ Hashtbl.to_seq_values t.ht in let new_keys_l = List.map @@ -228,13 +228,7 @@ let init () = let+ () = list_iter write_key new_keys in t -type info = string * rsa_pub * Time.Absolute.t * Time.Absolute.t - module Make () = struct - type pub = RsaPublicKey.t - type info = string * RsaPublicKey.t * Time.Absolute.t * Time.Absolute.t - - (* --- *) let t = match init () with | Error e -> Fmt.failwith "secmod_rsa initialization failure: %s." e @@ -251,7 +245,7 @@ module Make () = struct let _delete_outdated ~now = Hashtbl.to_seq t.ht |> List.of_seq - |> List.filter (fun (_h_pub, k) -> Absolute.compare now k.t2 >= 0) + |> List.filter (fun (_h_pub, k) -> TimeAbsolute.compare now k.t2 >= 0) |> List.map (fun (h_pub, _k) -> h_pub) |> list_iter delete diff --git a/src/signatures.ml b/src/signatures.ml index fe787f24..dbb0d892 100644 --- a/src/signatures.ml +++ b/src/signatures.ml @@ -1,38 +1,7 @@ -(* TODO signatures - rm non-NBO bin *) +open Time open Hash module Aliases = struct - module Timestamp = struct - type t = Time.Timestamp.t - - let bin = Time.Timestamp.bin - end - - module TimestampNBO = struct - type t = Time.Timestamp.t - - let bin = Time.Timestamp.bin_nbo - end - - module TimeRelative = struct - type t = Time.Relative.t - - let bin = Time.Relative.bin - end - - module TimeRelativeNBO = struct - type t = Time.Relative.t - - let bin = Time.Relative.bin_nbo - end - - module AmountNBO = struct - type t = Amount.t - - let bin = Amount.bin_nbo - end - (* - Keys - *) (* some of those are actuall ecdhe, or union of eddsa|ecdhe *) @@ -62,8 +31,7 @@ end open Aliases -let int32_size = 4 -let int64_size = 8 +let size_of_int32 = 4 module Bytes32 = struct type t = string @@ -90,14 +58,14 @@ module RefreshCommitmentP = Bytes64 module UUID = struct type t = string - let size = 4 * int32_size + let size = 4 * size_of_int32 let bin = Bin.bytes size end module WadId = struct type t = string - let size = 6 * int32_size + let size = 6 * size_of_int32 let bin = Bin.bytes size end @@ -189,8 +157,8 @@ module DenominationKeyAnnouncement = struct type r = { h_denom_pub: DenominationHash.t; h_section_name: Hash.Cstring.H64.t; - anchor_time: TimestampNBO.t; - duration_withdraw: TimeRelativeNBO.t; + anchor_time: Timestamp.t; + duration_withdraw: TimeRelative.t; } let bin = @@ -204,8 +172,8 @@ module DenominationKeyAnnouncement = struct |+ Purpose.field purpose |+ field DenominationHash.bin (fun t -> t.h_denom_pub) |+ field Hash.Cstring.H64.bin (fun t -> t.h_section_name) - |+ field TimestampNBO.bin (fun t -> t.anchor_time) - |+ field TimeRelativeNBO.bin (fun t -> t.duration_withdraw) + |+ field Timestamp.bin (fun t -> t.anchor_time) + |+ field TimeRelative.bin (fun t -> t.duration_withdraw) |> sealr end @@ -217,8 +185,8 @@ module SigningKeyAnnouncement = struct (* purpose.purpose = TALER_SIGNATURE_SM_SIGNING_KEY *) type r = { exchange_pub: ExchangePublicKeyP.t; - anchor_time: TimestampNBO.t; - duration: TimeRelativeNBO.t; + anchor_time: Timestamp.t; + duration: TimeRelative.t; } let bin = @@ -228,8 +196,8 @@ module SigningKeyAnnouncement = struct { exchange_pub; anchor_time; duration }) |+ Purpose.field purpose |+ field ExchangePublicKeyP.bin (fun t -> t.exchange_pub) - |+ field TimestampNBO.bin (fun t -> t.anchor_time) - |+ field TimeRelativeNBO.bin (fun t -> t.duration) + |+ field Timestamp.bin (fun t -> t.anchor_time) + |+ field TimeRelative.bin (fun t -> t.duration) |> sealr end @@ -241,16 +209,16 @@ module DenominationKeyValidity = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY *) type r = { master: MasterPublicKeyP.t; - start: TimestampNBO.t; - expire_withdraw: TimestampNBO.t; - expire_spend: TimestampNBO.t; - expire_legal: TimestampNBO.t; - value: AmountNBO.t; - fee_withdraw: AmountNBO.t; - fee_deposit: AmountNBO.t; - fee_refresh: AmountNBO.t; + start: Timestamp.t; + expire_withdraw: Timestamp.t; + expire_spend: Timestamp.t; + expire_legal: Timestamp.t; + value: Amount.t; + fee_withdraw: Amount.t; + fee_deposit: Amount.t; + fee_refresh: Amount.t; (* TODO signatures taler doc *) - fee_refund: AmountNBO.t; + fee_refund: Amount.t; denom_hash: DenominationHash.t; } @@ -288,15 +256,15 @@ module DenominationKeyValidity = struct }) |+ Purpose.field purpose |+ field MasterPublicKeyP.bin (fun t -> t.master) - |+ field TimestampNBO.bin (fun t -> t.start) - |+ field TimestampNBO.bin (fun t -> t.expire_withdraw) - |+ field TimestampNBO.bin (fun t -> t.expire_spend) - |+ field TimestampNBO.bin (fun t -> t.expire_legal) - |+ field AmountNBO.bin (fun t -> t.value) - |+ field AmountNBO.bin (fun t -> t.fee_withdraw) - |+ field AmountNBO.bin (fun t -> t.fee_deposit) - |+ field AmountNBO.bin (fun t -> t.fee_refresh) - |+ field AmountNBO.bin (fun t -> t.fee_refund) + |+ field Timestamp.bin (fun t -> t.start) + |+ field Timestamp.bin (fun t -> t.expire_withdraw) + |+ field Timestamp.bin (fun t -> t.expire_spend) + |+ field Timestamp.bin (fun t -> t.expire_legal) + |+ field Amount.bin (fun t -> t.value) + |+ field Amount.bin (fun t -> t.fee_withdraw) + |+ field Amount.bin (fun t -> t.fee_deposit) + |+ field Amount.bin (fun t -> t.fee_refresh) + |+ field Amount.bin (fun t -> t.fee_refund) |+ field DenominationHash.bin (fun t -> t.denom_hash) |> sealr end @@ -308,9 +276,9 @@ module ExchangeSigningKeyValidity = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY *) type r = { - start: TimestampNBO.t; - expire: TimestampNBO.t; - end_: TimestampNBO.t; + start: Timestamp.t; + expire: Timestamp.t; + end_: Timestamp.t; signkey_pub: ExchangePublicKeyP.t; } @@ -321,9 +289,9 @@ module ExchangeSigningKeyValidity = struct record (fun _purpose start expire end_ signkey_pub -> { start; expire; end_; signkey_pub }) |+ Purpose.field purpose - |+ field TimestampNBO.bin (fun t -> t.start) - |+ field TimestampNBO.bin (fun t -> t.expire) - |+ field TimestampNBO.bin (fun t -> t.end_) + |+ field Timestamp.bin (fun t -> t.start) + |+ field Timestamp.bin (fun t -> t.expire) + |+ field Timestamp.bin (fun t -> t.end_) |+ field ExchangePublicKeyP.bin (fun t -> t.signkey_pub) |> sealr end @@ -371,7 +339,7 @@ module MasterAddAuditor = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_ADD_AUDITOR *) type r = { - start_date: TimestampNBO.t; + start_date: Timestamp.t; auditor_pub: AuditorPublicKeyP.t; h_auditor_url: Hash.Cstring.H64.t; } @@ -382,7 +350,7 @@ module MasterAddAuditor = struct record (fun _purpose start_date auditor_pub h_auditor_url -> { start_date; auditor_pub; h_auditor_url }) |+ Purpose.field purpose - |+ field TimestampNBO.bin (fun t -> t.start_date) + |+ field Timestamp.bin (fun t -> t.start_date) |+ field AuditorPublicKeyP.bin (fun t -> t.auditor_pub) |+ field Hash.Cstring.H64.bin (fun t -> t.h_auditor_url) |> sealr @@ -395,7 +363,7 @@ module MasterDelAuditor = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_DEL_AUDITOR *) type r = { - end_date: TimestampNBO.t; + end_date: Timestamp.t; auditor_pub: AuditorPublicKeyP.t; } @@ -404,7 +372,7 @@ module MasterDelAuditor = struct Purpose.make_bin Taler_signatures.master_del_auditor @@ fun purpose -> record (fun _purpose end_date auditor_pub -> { end_date; auditor_pub }) |+ Purpose.field purpose - |+ field TimestampNBO.bin (fun t -> t.end_date) + |+ field Timestamp.bin (fun t -> t.end_date) |+ field AuditorPublicKeyP.bin (fun t -> t.auditor_pub) |> sealr end @@ -417,13 +385,13 @@ module GlobalFees = struct (* TODO signatures taler doc *) (* purpose.purpose = TALER_SIGNATURE_MASTER_GLOBAL_FEES *) type r = { - start_date: TimestampNBO.t; - end_date: TimestampNBO.t; - purse_timeout: TimeRelativeNBO.t; - history_expiration: TimeRelativeNBO.t; - history_fee: AmountNBO.t; - account_fee: AmountNBO.t; - purse_fee: AmountNBO.t; + start_date: Timestamp.t; + end_date: Timestamp.t; + purse_timeout: TimeRelative.t; + history_expiration: TimeRelative.t; + history_fee: Amount.t; + account_fee: Amount.t; + purse_fee: Amount.t; purse_account_limit: int32; } @@ -453,13 +421,13 @@ module GlobalFees = struct purse_account_limit; }) |+ Purpose.field purpose - |+ field TimestampNBO.bin (fun t -> t.start_date) - |+ field TimestampNBO.bin (fun t -> t.end_date) - |+ field TimeRelativeNBO.bin (fun t -> t.purse_timeout) - |+ field TimeRelativeNBO.bin (fun t -> t.history_expiration) - |+ field AmountNBO.bin (fun t -> t.history_fee) - |+ field AmountNBO.bin (fun t -> t.account_fee) - |+ field AmountNBO.bin (fun t -> t.purse_fee) + |+ field Timestamp.bin (fun t -> t.start_date) + |+ field Timestamp.bin (fun t -> t.end_date) + |+ field TimeRelative.bin (fun t -> t.purse_timeout) + |+ field TimeRelative.bin (fun t -> t.history_expiration) + |+ field Amount.bin (fun t -> t.history_fee) + |+ field Amount.bin (fun t -> t.account_fee) + |+ field Amount.bin (fun t -> t.purse_fee) |+ field beint32 (fun t -> t.purse_account_limit) |> sealr end @@ -509,7 +477,7 @@ module MasterAddWire = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_ADD_WIRE *) type r = { - start_date: TimestampNBO.t; + start_date: Timestamp.t; h_wire: FullPaytoHash.t; h_conversion_url: Hash.Cstring.H64.t; h_credit_restrictions: Hash.Cstring.H64.t; @@ -536,7 +504,7 @@ module MasterAddWire = struct h_debit_restrictions; }) |+ Purpose.field _purpose - |+ field TimestampNBO.bin (fun t -> t.start_date) + |+ field Timestamp.bin (fun t -> t.start_date) |+ field FullPaytoHash.bin (fun t -> t.h_wire) |+ field Hash.Cstring.H64.bin (fun t -> t.h_conversion_url) |+ field Hash.Cstring.H64.bin (fun t -> t.h_credit_restrictions) @@ -551,7 +519,7 @@ module MasterDelWire = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_DEL_WIRE *) type r = { - end_date: TimestampNBO.t; + end_date: Timestamp.t; h_wire: FullPaytoHash.t; } @@ -560,7 +528,7 @@ module MasterDelWire = struct Purpose.make_bin Taler_signatures.master_del_wire @@ fun _purpose -> record (fun _purpose end_date h_wire -> { end_date; h_wire }) |+ Purpose.field _purpose - |+ field TimestampNBO.bin (fun t -> t.end_date) + |+ field Timestamp.bin (fun t -> t.end_date) |+ field FullPaytoHash.bin (fun t -> t.h_wire) |> sealr end @@ -573,8 +541,8 @@ module MasterDrainProfit = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_DRAIN_PROFITS *) type r = { wtid: WireTransferIdentifierRawP.t; - date: TimestampNBO.t; - amount: AmountNBO.t; + date: Timestamp.t; + amount: Amount.t; h_section: Hash.Cstring.H64.t; h_payto: FullPaytoHash.t; } @@ -586,8 +554,8 @@ module MasterDrainProfit = struct { wtid; date; amount; h_section; h_payto }) |+ Purpose.field _purpose |+ field WireTransferIdentifierRawP.bin (fun t -> t.wtid) - |+ field TimestampNBO.bin (fun t -> t.date) - |+ field AmountNBO.bin (fun t -> t.amount) + |+ field Timestamp.bin (fun t -> t.date) + |+ field Amount.bin (fun t -> t.amount) |+ field Hash.Cstring.H64.bin (fun t -> t.h_section) |+ field FullPaytoHash.bin (fun t -> t.h_payto) |> sealr @@ -600,7 +568,7 @@ module MasterAmlOfficerStatus = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_AML_KEY *) type r = { - change_date: TimestampNBO.t; + change_date: Timestamp.t; officer_pub: AmlOfficerPublicKeyP.t; h_officer_name: Hash.Cstring.H64.t; is_active: int32; @@ -612,7 +580,7 @@ module MasterAmlOfficerStatus = struct record (fun _purpose change_date officer_pub h_officer_name is_active -> { change_date; officer_pub; h_officer_name; is_active }) |+ Purpose.field _purpose - |+ field TimestampNBO.bin (fun t -> t.change_date) + |+ field Timestamp.bin (fun t -> t.change_date) |+ field AmlOfficerPublicKeyP.bin (fun t -> t.officer_pub) |+ field Hash.Cstring.H64.bin (fun t -> t.h_officer_name) |+ field beint32 (fun t -> t.is_active) @@ -627,10 +595,10 @@ module PartnerConfiguration = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_PARNTER_DETAILS *) type r = { partner_pub: MasterPublicKeyP.t; - start_date: TimestampNBO.t; - end_date: TimestampNBO.t; - wad_frequency: TimeRelativeNBO.t; - wad_fee: AmountNBO.t; + start_date: Timestamp.t; + end_date: Timestamp.t; + wad_frequency: TimeRelative.t; + wad_fee: Amount.t; h_url: Hash.Cstring.H64.t; } @@ -650,10 +618,10 @@ module PartnerConfiguration = struct -> { partner_pub; start_date; end_date; wad_frequency; wad_fee; h_url }) |+ Purpose.field _purpose |+ field MasterPublicKeyP.bin (fun t -> t.partner_pub) - |+ field TimestampNBO.bin (fun t -> t.start_date) - |+ field TimestampNBO.bin (fun t -> t.end_date) - |+ field TimeRelativeNBO.bin (fun t -> t.wad_frequency) - |+ field AmountNBO.bin (fun t -> t.wad_fee) + |+ field Timestamp.bin (fun t -> t.start_date) + |+ field Timestamp.bin (fun t -> t.end_date) + |+ field TimeRelative.bin (fun t -> t.wad_frequency) + |+ field Amount.bin (fun t -> t.wad_fee) |+ field Hash.Cstring.H64.bin (fun t -> t.h_url) |> sealr end @@ -667,10 +635,10 @@ module WadPartnerSignature = struct type r = { h_partner_base_url: Hash.Cstring.H64.t; master_public_key: MasterPublicKeyP.t; - start_date: TimestampNBO.t; - end_date: TimestampNBO.t; - wad_fee: AmountNBO.t; - wad_frequency: TimeRelativeNBO.t; + start_date: Timestamp.t; + end_date: Timestamp.t; + wad_fee: Amount.t; + wad_frequency: TimeRelative.t; } let bin = @@ -698,10 +666,10 @@ module WadPartnerSignature = struct |+ Purpose.field _purpose |+ field Hash.Cstring.H64.bin (fun t -> t.h_partner_base_url) |+ field MasterPublicKeyP.bin (fun t -> t.master_public_key) - |+ field TimestampNBO.bin (fun t -> t.start_date) - |+ field TimestampNBO.bin (fun t -> t.end_date) - |+ field AmountNBO.bin (fun t -> t.wad_fee) - |+ field TimeRelativeNBO.bin (fun t -> t.wad_frequency) + |+ field Timestamp.bin (fun t -> t.start_date) + |+ field Timestamp.bin (fun t -> t.end_date) + |+ field Amount.bin (fun t -> t.wad_fee) + |+ field TimeRelative.bin (fun t -> t.wad_frequency) |> sealr end @@ -713,10 +681,10 @@ module MasterWireFee = struct (* purpose.purpose = TALER_SIGNATURE_MASTER_WIRE_FEES *) type r = { h_wire_method: Hash.Cstring.H64.t; - start_date: TimestampNBO.t; - end_date: TimestampNBO.t; - wire_fee: AmountNBO.t; - closing_fee: AmountNBO.t; + start_date: Timestamp.t; + end_date: Timestamp.t; + wire_fee: Amount.t; + closing_fee: Amount.t; } let bin = @@ -727,10 +695,10 @@ module MasterWireFee = struct { h_wire_method; start_date; end_date; wire_fee; closing_fee }) |+ Purpose.field _purpose |+ field Hash.Cstring.H64.bin (fun t -> t.h_wire_method) - |+ field TimestampNBO.bin (fun t -> t.start_date) - |+ field TimestampNBO.bin (fun t -> t.end_date) - |+ field AmountNBO.bin (fun t -> t.wire_fee) - |+ field AmountNBO.bin (fun t -> t.closing_fee) + |+ field Timestamp.bin (fun t -> t.start_date) + |+ field Timestamp.bin (fun t -> t.end_date) + |+ field Amount.bin (fun t -> t.wire_fee) + |+ field Amount.bin (fun t -> t.closing_fee) |> sealr end @@ -743,14 +711,14 @@ module ExchangeKeyValidity = struct type r = { auditor_url_hash: Hash.Cstring.H64.t; master: MasterPublicKeyP.t; - start: TimestampNBO.t; - expire_withdraw: TimestampNBO.t; - expire_spend: TimestampNBO.t; - expire_legal: TimestampNBO.t; - value: AmountNBO.t; - fee_withdraw: AmountNBO.t; - fee_deposit: AmountNBO.t; - fee_refresh: AmountNBO.t; + start: Timestamp.t; + expire_withdraw: Timestamp.t; + expire_spend: Timestamp.t; + expire_legal: Timestamp.t; + value: Amount.t; + fee_withdraw: Amount.t; + fee_deposit: Amount.t; + fee_refresh: Amount.t; denom_hash: DenominationHash.t; } @@ -788,14 +756,14 @@ module ExchangeKeyValidity = struct |+ Purpose.field _purpose |+ field Hash.Cstring.H64.bin (fun t -> t.auditor_url_hash) |+ field MasterPublicKeyP.bin (fun t -> t.master) - |+ field TimestampNBO.bin (fun t -> t.start) - |+ field TimestampNBO.bin (fun t -> t.expire_withdraw) - |+ field TimestampNBO.bin (fun t -> t.expire_spend) - |+ field TimestampNBO.bin (fun t -> t.expire_legal) - |+ field AmountNBO.bin (fun t -> t.value) - |+ field AmountNBO.bin (fun t -> t.fee_withdraw) - |+ field AmountNBO.bin (fun t -> t.fee_deposit) - |+ field AmountNBO.bin (fun t -> t.fee_refresh) + |+ field Timestamp.bin (fun t -> t.start) + |+ field Timestamp.bin (fun t -> t.expire_withdraw) + |+ field Timestamp.bin (fun t -> t.expire_spend) + |+ field Timestamp.bin (fun t -> t.expire_legal) + |+ field Amount.bin (fun t -> t.value) + |+ field Amount.bin (fun t -> t.fee_withdraw) + |+ field Amount.bin (fun t -> t.fee_deposit) + |+ field Amount.bin (fun t -> t.fee_refresh) |+ field DenominationHash.bin (fun t -> t.denom_hash) |> sealr end @@ -807,7 +775,7 @@ module ExchangeKeySet = struct module R = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_KEY_SET *) type r = { - list_issue_date: TimestampNBO.t; + list_issue_date: Timestamp.t; (* hash over a concatenation of master_sigs *) hc: H64.t; } @@ -817,7 +785,7 @@ module ExchangeKeySet = struct Purpose.make_bin Taler_signatures.exchange_key_set @@ fun _purpose -> record (fun _purpose list_issue_date hc -> { list_issue_date; hc }) |+ Purpose.field _purpose - |+ field TimestampNBO.bin (fun t -> t.list_issue_date) + |+ field Timestamp.bin (fun t -> t.list_issue_date) |+ field H64.bin (fun t -> t.hc) |> sealr end @@ -876,7 +844,7 @@ end module SingleWithdrawRequest = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW *) type t = { - amount_with_fee: AmountNBO.t; + amount_with_fee: Amount.t; h_denomination_pub: DenominationHash.t; h_coin_envelope: BlindedCoinHash.t; } @@ -890,10 +858,10 @@ module DepositRequest = struct h_policy: ExtensionsPolicyHash.t; h_wire: MerchantWireHash.t; h_denom_pub: DenominationHash.t; - timestamp: TimestampNBO.t; - refund_deadline: TimestampNBO.t; - amount_with_fee: AmountNBO.t; - deposit_fee: AmountNBO.t; + timestamp: Timestamp.t; + refund_deadline: Timestamp.t; + amount_with_fee: Amount.t; + deposit_fee: Amount.t; merchant: MerchantPublicKeyP.t; wallet_data_hash: Hash.Cstring.H64.t; } @@ -905,9 +873,9 @@ module DepositConfirmation = struct h_contract_terms: PrivateContractHash.t; h_wire: MerchantWireHash.t; h_policy: ExtensionsPolicyHash.t; - timestamp: TimestampNBO.t; - refund_deadline: TimestampNBO.t; - amount_without_fee: AmountNBO.t; + timestamp: Timestamp.t; + refund_deadline: Timestamp.t; + amount_without_fee: Amount.t; coin_pub: CoinSpendPublicKeyP.t; merchant: MerchantPublicKeyP.t; } @@ -919,8 +887,8 @@ module RefreshMeltCoinAffirmation = struct session_hash: RefreshCommitmentP.t; h_denom_pub: DenominationHash.t; h_age_commitment: AgeCommitmentHash.t; - amount_with_fee: AmountNBO.t; - melt_fee: AmountNBO.t; + amount_with_fee: Amount.t; + melt_fee: Amount.t; } end @@ -944,18 +912,18 @@ end module WireDepositDetailP = struct type t = { h_contract_terms: PrivateContractHash.t; - execution_time: TimestampNBO.t; + execution_time: Timestamp.t; coin_pub: CoinSpendPublicKeyP.t; - deposit_value: AmountNBO.t; - deposit_fee: AmountNBO.t; + deposit_value: Amount.t; + deposit_fee: Amount.t; } end module WireDepositData = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT *) type t = { - total: AmountNBO.t; - wire_fee: AmountNBO.t; + total: Amount.t; + wire_fee: Amount.t; merchant_pub: MerchantPublicKeyP.t; h_wire: MerchantWireHash.t; h_details: Hash.Cstring.H64.t; @@ -979,8 +947,8 @@ module ConfirmWire = struct h_contract_terms: PrivateContractHash.t; wtid: WireTransferIdentifierRawP.t; coin_pub: CoinSpendPublicKeyP.t; - execution_time: TimestampNBO.t; - coin_contribution: AmountNBO.t; + execution_time: Timestamp.t; + coin_contribution: Amount.t; } end @@ -991,7 +959,7 @@ module RefundConfirmation = struct coin_pub: CoinSpendPublicKeyP.t; merchant: MerchantPublicKeyP.t; rtransaction_id: int64; - refund_amount: AmountNBO.t; + refund_amount: Amount.t; } end @@ -1011,8 +979,8 @@ module RefundRequest = struct h_contract_terms: PrivateContractHash.t; coin_pub: CoinSpendPublicKeyP.t; rtransaction_id: int64; - refund_amount: AmountNBO.t; - refund_fee: AmountNBO.t; + refund_amount: Amount.t; + refund_fee: Amount.t; } end @@ -1033,8 +1001,8 @@ end module RecoupRefreshConfirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH *) type t = { - timestamp: TimestampNBO.t; - recoup_amount: AmountNBO.t; + timestamp: Timestamp.t; + recoup_amount: Amount.t; coin_pub: CoinSpendPublicKeyP.t; old_coin_pub: CoinSpendPublicKeyP.t; } @@ -1043,8 +1011,8 @@ end module RecoupConfirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP *) type t = { - timestamp: TimestampNBO.t; - recoup_amount: AmountNBO.t; + timestamp: Timestamp.t; + recoup_amount: Amount.t; coin_pub: CoinSpendPublicKeyP.t; reserve_pub: ReservePublicKeyP.t; } @@ -1053,7 +1021,7 @@ end module DenominationUnknownAffirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_AFFIRM_DENOM_UNKNOWN *) type t = { - timestamp: TimestampNBO.t; + timestamp: Timestamp.t; h_denom_pub: DenominationHash.t; } end @@ -1061,7 +1029,7 @@ end module DenominationExpiredAffirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_GENERIC_DENOMINATIN_EXPIRED *) type t = { - timestamp: TimestampNBO.t; + timestamp: Timestamp.t; operation: string; (* char[8] → string *) h_denom_pub: DenominationHash.t; } @@ -1070,8 +1038,8 @@ end module ReserveCloseConfirmation = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED *) type t = { - timestamp: TimestampNBO.t; - closing_amount: AmountNBO.t; + timestamp: Timestamp.t; + closing_amount: Amount.t; reserve_pub: ReservePublicKeyP.t; h_wire: FullPaytoHash.t; } @@ -1094,14 +1062,14 @@ end module ReserveStatusRequestSignature = struct (* purpose.purpose = TALER_SIGNATURE_RESERVE_STATUS_REQUEST *) - type t = { request_timestamp: TimestampNBO.t } + type t = { request_timestamp: Timestamp.t } end module ReserveHistoryRequestSignature = struct (* purpose.purpose = TALER_SIGNATURE_RESERVE_HISTORY_REQUEST *) type t = { - history_fee: AmountNBO.t; - request_timestamp: TimestampNBO.t; + history_fee: Amount.t; + request_timestamp: Timestamp.t; } end @@ -1113,11 +1081,11 @@ end module PurseStatusResponseSignature = struct (* purpose.purpose = TALER_SIGNATURE_PURSE_STATUS_RESPONSE *) type t = { - total_purse_amount: AmountNBO.t; - total_deposit_amount: AmountNBO.t; - max_deposit_fees: AmountNBO.t; - purse_expiration: TimestampNBO.t; - status_timestamp: TimestampNBO.t; + total_purse_amount: Amount.t; + total_deposit_amount: Amount.t; + max_deposit_fees: Amount.t; + purse_expiration: Timestamp.t; + status_timestamp: Timestamp.t; h_contract_terms: PrivateContractHash.t; } end @@ -1130,8 +1098,8 @@ end module PurseRequestSignature = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_PURSE_CREATE *) type t = { - purse_expiration: TimestampNBO.t; - merge_value_after_fees: AmountNBO.t; + purse_expiration: Timestamp.t; + merge_value_after_fees: Amount.t; h_contract_terms: PrivateContractHash.t; min_age: int; } @@ -1140,7 +1108,7 @@ end module PurseDepositSignature = struct (* purpose.purpose = TALER_SIGNATURE_PURSE_DEPOSIT *) type t = { - coin_contribution: AmountNBO.t; + coin_contribution: Amount.t; h_denom_pub: DenominationHash.t; h_age_commitment: AgeCommitmentHash.t; purse_pub: PursePublicKey.t; @@ -1152,17 +1120,17 @@ module PurseDepositSignaturePS2 = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_RESERVE_OPEN_DEPOSIT *) type t = { reserve_sig: ReserveSignatureP.t; - coin_contribution: AmountNBO.t; + coin_contribution: Amount.t; } end module PurseDepositConfirmedSignature = struct (* purpose.purpose = TALER_SIGNATURE_PURSE_DEPOSIT_CONFIRMED *) type t = { - total_purse_amount: AmountNBO.t; - total_deposit_fees: AmountNBO.t; + total_purse_amount: Amount.t; + total_deposit_fees: Amount.t; purse_pub: PursePublicKey.t; - purse_expiration: TimestampNBO.t; + purse_expiration: Timestamp.t; h_contract_terms: PrivateContractHash.t; } end @@ -1170,7 +1138,7 @@ end module PurseMergeSignature = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_PURSE_MERGE *) type t = { - merge_timestamp: TimestampNBO.t; + merge_timestamp: Timestamp.t; h_wire: NormalizedPaytoHash.t; } end @@ -1180,9 +1148,9 @@ module AccountMergeSignature = struct type t = { reserve_pub: ReservePublicKeyP.t; purse_pub: PursePublicKey.t; - merge_amount_after_fees: AmountNBO.t; - merge_timestamp: TimestampNBO.t; - purse_expiration: TimestampNBO.t; + merge_amount_after_fees: Amount.t; + merge_timestamp: Timestamp.t; + purse_expiration: Timestamp.t; h_contract_terms: PrivateContractHash.t; min_age: int; } @@ -1190,7 +1158,7 @@ end module AccountSetupRequestSignature = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_ACCOUNT_SETUP *) - type t = { threshold: AmountNBO.t } + type t = { threshold: Amount.t } end module PurseMergeSuccessSignature = struct @@ -1198,8 +1166,8 @@ module PurseMergeSuccessSignature = struct type t = { reserve_pub: ReservePublicKeyP.t; purse_pub: PursePublicKey.t; - merge_amount_after_fees: AmountNBO.t; - contract_time: TimestampNBO.t; + merge_amount_after_fees: Amount.t; + contract_time: Timestamp.t; h_contract_terms: PrivateContractHash.t; h_wire: NormalizedPaytoHash.t; min_age: int; @@ -1209,8 +1177,8 @@ end module WadDataSignature = struct (* purpose.purpose = TALER_SIGNATURE_WAD_DATA *) type t = { - wad_execution_time: TimestampNBO.t; - total_amount: AmountNBO.t; + wad_execution_time: Timestamp.t; + total_amount: Amount.t; h_items: Hash.Cstring.H64.t; wad_id: WadId.t; } @@ -1219,14 +1187,14 @@ end module P2PFees = struct (* purpose.purpose = TALER_SIGNATURE_P2P_FEES *) type t = { - start_date: TimestampNBO.t; - end_date: TimestampNBO.t; - kyc_fee: AmountNBO.t; - purse_fee: AmountNBO.t; - account_history_fee: AmountNBO.t; - account_annual_fee: AmountNBO.t; - account_kyc_timeout: TimeRelativeNBO.t; - purse_timeout: TimeRelativeNBO.t; + start_date: Timestamp.t; + end_date: Timestamp.t; + kyc_fee: Amount.t; + purse_fee: Amount.t; + account_history_fee: Amount.t; + account_annual_fee: Amount.t; + account_kyc_timeout: TimeRelative.t; + purse_timeout: TimeRelative.t; purse_account_limit: int; } end @@ -1236,8 +1204,8 @@ module CoinPurseRefundConfirmation = struct type t = { purse_pub: PursePublicKey.t; coin_pub: CoinSpendPublicKeyP.t; - refunded_amount: AmountNBO.t; - refund_fee: AmountNBO.t; + refunded_amount: Amount.t; + refund_fee: Amount.t; } end @@ -1245,8 +1213,8 @@ module AmlDecision = struct (* purpose.purpose = TALER_SIGNATURE_AML_DECISION *) type t = { h_justification: Hash.Cstring.H64.t; - decision_time: TimestampNBO.t; - new_threshold: AmountNBO.t; + decision_time: Timestamp.t; + new_threshold: Amount.t; h_payto: NormalizedPaytoHash.t; h_kyc_requirements: Hash.Cstring.H64.t; new_state: int; @@ -1256,9 +1224,9 @@ end module ReserveOpen = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_RESERVE_OPEN *) type t = { - reserve_payment: AmountNBO.t; - request_timestamp: TimestampNBO.t; - reserve_expiration: TimestampNBO.t; + reserve_payment: Amount.t; + request_timestamp: Timestamp.t; + reserve_expiration: Timestamp.t; purse_limit: int; } end @@ -1266,7 +1234,7 @@ end module ReserveClose = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_RESERVE_CLOSE *) type t = { - request_timestamp: TimestampNBO.t; + request_timestamp: Timestamp.t; target_account_h_payto: FullPaytoHash.t; } end @@ -1274,7 +1242,7 @@ end module ReserveAttestRequest = struct (* purpose.purpose = TALER_SIGNATURE_WALLET_ATTEST_REQUEST *) type t = { - request_timestamp: TimestampNBO.t; + request_timestamp: Timestamp.t; h_details: Hash.Cstring.H64.t; } end @@ -1282,8 +1250,8 @@ end module ExchangeAttest = struct (* purpose.purpose = TALER_SIGNATURE_EXCHANGE_RESERVE_ATTEST_DETAILS *) type t = { - attest_timestamp: TimestampNBO.t; - expiration_time: TimestampNBO.t; + attest_timestamp: Timestamp.t; + expiration_time: Timestamp.t; reserve_pub: ReservePublicKeyP.t; h_attributes: Hash.Cstring.H64.t; } diff --git a/src/time.ml b/src/time.ml index 3ac0368b..e65cad41 100644 --- a/src/time.ml +++ b/src/time.ml @@ -1,6 +1,6 @@ let uint64_max = Int64.minus_one -module Relative = struct +module TimeRelative = struct type t = Int64.t let forever = uint64_max @@ -26,8 +26,7 @@ module Relative = struct let v = Int64.mul s 1_000_000L in if Int64.unsigned_div v 1_000_000L <> s then forever else v - let bin = Bin.neint64 - let bin_nbo = Bin.beint64 + let bin = Bin.beint64 let caqti = let encode v = Ok v in @@ -57,7 +56,7 @@ module Relative = struct |> Jsont.Object.finish end -module Absolute = struct +module TimeAbsolute = struct type t = Int64.t let never = uint64_max @@ -117,9 +116,8 @@ module Timestamp = struct let of_absolute a = if a = never then never else Int64.sub a (Int64.unsigned_rem a 1_000_000L) - let of_ptime v = v |> Absolute.of_ptime |> of_absolute - let bin = Bin.neint64 - let bin_nbo = Bin.beint64 + let of_ptime v = v |> TimeAbsolute.of_ptime |> of_absolute + let bin = Bin.beint64 let caqti = let encode v = Ok v in diff --git a/src/time.mli b/src/time.mli index 9430b8a1..ce2e398a 100644 --- a/src/time.mli +++ b/src/time.mli @@ -1,4 +1,4 @@ -module Relative : sig +module TimeRelative : sig type t val forever : t @@ -12,12 +12,11 @@ module Relative : sig (* - *) val bin : t Bin.t - val bin_nbo : t Bin.t val caqti : t Caqti_type.t val jsont : t Jsont.t end -module Absolute : sig +module TimeAbsolute : sig type t val never : t @@ -25,9 +24,9 @@ module Absolute : sig val compare : t -> t -> int val min : t -> t -> t val max : t -> t -> t - val diff : t -> t -> Relative.t - val add : t -> Relative.t -> t - val sub : t -> Relative.t -> t + val diff : t -> t -> TimeRelative.t + val add : t -> TimeRelative.t -> t + val sub : t -> TimeRelative.t -> t val of_s : int64 -> t val of_ptime : Ptime.t -> t end @@ -40,18 +39,17 @@ module Timestamp : sig val compare : t -> t -> int val min : t -> t -> t val max : t -> t -> t - val diff : t -> t -> Relative.t + val diff : t -> t -> TimeRelative.t val of_s : int64 -> t (* none if t = never *) val to_s : t -> int64 option - val of_absolute : Absolute.t -> t + val of_absolute : TimeAbsolute.t -> t val of_ptime : Ptime.t -> t (* TODO add pp *) (* - *) val bin : t Bin.t - val bin_nbo : t Bin.t val caqti : t Caqti_type.t val jsont : t Jsont.t end diff --git a/tools/offline.ml b/tools/offline.ml index 461492c7..3991fb8a 100644 --- a/tools/offline.ml +++ b/tools/offline.ml @@ -14,16 +14,17 @@ open Offline_impl module Arg = struct include Arg + open Time (* in seconds *) let timestamp = let parser s = match int_of_string_opt s with | None -> Error "not an int" - | Some n -> Ok (Time.Timestamp.of_s (Int64.of_int n)) + | Some n -> Ok (Timestamp.of_s (Int64.of_int n)) in let pp fmt t = - match Time.Timestamp.to_s t with + match Timestamp.to_s t with | None -> Fmt.pf fmt "never" | Some s -> Fmt.pf fmt "%Ld" s in @@ -34,11 +35,11 @@ module Arg = struct let parser s = match int_of_string_opt s with | None -> Error "not an int" - | Some s -> Ok (Time.Relative.of_s (Int64.of_int s)) + | Some s -> Ok (TimeRelative.of_s (Int64.of_int s)) in let pp fmt d = - let t = Time.Timestamp.of_absolute Time.Absolute.(add zero d) in - match Time.Timestamp.to_s t with + let t = Timestamp.of_absolute TimeAbsolute.(add zero d) in + match Timestamp.to_s t with | None -> Fmt.pf fmt "never" | Some s -> Fmt.pf fmt "%Ld" s in