add api_types.ml

This commit is contained in:
swrup 2025-10-18 17:35:15 +02:00
parent d5abae41b6
commit 4611c1e057
6 changed files with 154 additions and 172 deletions

90
src/api_types.ml Normal file
View file

@ -0,0 +1,90 @@
(* TODO
number
- number is "float", but we probably want int everywhere instead
- numeric values capped at 2^53 -1 inclusive because json
time
- better types
- issues with "never" = uint64_max *)
open Types
module ErrorDetail = struct
(* TODO GANA error codes
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
type t = {
code: int;
hint: string option;
}
end
module Timestamp = struct
type t =
| Seconds of float
| Never
let of_ptime p = Seconds (Ptime.to_float_s p)
end
module RelativeTime = struct
type t =
| Microseconds of float
| Forever
end
module RsaDenominationKey = struct
type t = {
age_mask: int;
rsa_pub: RsaPublicKey.t;
}
end
(* not implemented *)
module CSDenominationKey = struct
(* Clause Schnorr *)
type t = {
age_mask: int;
cs_pub: string;
}
end
module DenominationKey = struct
type t =
| Rsa of RsaDenominationKey.t
| CS of CSDenominationKey.t
end
module FutureSignKey = struct
type t = {
key: EddsaPublicKey.t;
stamp_start: Timestamp.t;
stamp_expire: Timestamp.t;
stamp_end: Timestamp.t;
signkey_secmod_sig: EddsaSignature.t;
}
end
module FutureDenom = struct
type t = {
section_name: string;
value: Amount.t;
stamp_start: Timestamp.t;
stamp_expire_withdraw: Timestamp.t;
stamp_expire_deposit: Timestamp.t;
stamp_expire_legal: Timestamp.t;
denom_pub: DenominationKey.t;
fee_withdraw: Amount.t;
fee_deposit: Amount.t;
fee_refresh: Amount.t;
fee_refund: Amount.t;
denom_secmod_sig: EddsaSignature.t;
}
end
module FutureKeysResponse = struct
type t = {
future_denoms: FutureDenom.t list;
future_signkeys: FutureSignKey.t list;
master_pub: EddsaPublicKey.t;
denom_secmod_public_key: EddsaPublicKey.t;
signkey_secmod_public_key: EddsaPublicKey.t;
}
end