2025-11-16 05:33:06 +01:00
|
|
|
(* TODO be sure to not use postgres ptime
|
|
|
|
|
add a dune stanza like for prelude:
|
|
|
|
|
"(flags (:standard -open Prelude))" *)
|
|
|
|
|
module Caqti_type = struct
|
|
|
|
|
include Caqti_type
|
|
|
|
|
|
|
|
|
|
(* we want to use int64 timestamps,
|
|
|
|
|
not postgresql built-in timestamp type *)
|
|
|
|
|
let ptime : Ptime.t Caqti_type.t =
|
|
|
|
|
let encode i = Ok (Util.ptime_to_int64 i) in
|
|
|
|
|
let decode = Util.ptime_of_int64 in
|
|
|
|
|
Caqti_type.custom ~encode ~decode Caqti_type.(int64)
|
|
|
|
|
end
|
|
|
|
|
|
2025-11-21 19:29:04 +01:00
|
|
|
open Crypto
|
|
|
|
|
(*open Bin_type*)
|
|
|
|
|
|
|
|
|
|
let amount_t : Amount.t Caqti_type.t =
|
2025-11-16 05:33:06 +01:00
|
|
|
let open Amount in
|
|
|
|
|
Caqti_type.custom
|
2025-11-16 15:28:14 +01:00
|
|
|
~encode:(fun amount -> Ok (amount.value, amount.fraction))
|
2025-11-16 05:33:06 +01:00
|
|
|
~decode:(fun (value, fraction) ->
|
2025-11-20 22:14:45 +01:00
|
|
|
Amount.make ~sign:None ~currency:Config.currency ~value ~fraction)
|
2025-11-16 05:33:06 +01:00
|
|
|
Caqti_type.(t2 int64 int32)
|
|
|
|
|
|
2025-11-21 19:29:04 +01:00
|
|
|
let eddsa_signature_t : EddsaSignature.t Caqti_type.t =
|
|
|
|
|
let open EddsaSignature in
|
|
|
|
|
Caqti_type.custom
|
|
|
|
|
~encode:(fun master_sig -> Ok (to_octets master_sig))
|
|
|
|
|
~decode:(fun s -> Ok (of_octets s))
|
|
|
|
|
Caqti_type.octets
|
|
|
|
|
|
2025-11-16 05:33:06 +01:00
|
|
|
(* WIP: minimum db functions for basic /management *)
|
|
|
|
|
|
|
|
|
|
let pg_todo () = assert false
|
|
|
|
|
|
2025-11-21 19:29:04 +01:00
|
|
|
open Caqti_request.Infix
|
|
|
|
|
|
2025-11-16 05:33:06 +01:00
|
|
|
(* signkey *)
|
2025-11-16 15:55:32 +01:00
|
|
|
(* todo:
|
|
|
|
|
- what type to use for TALER_ExchangePublicKeyP + TALER_EXCHANGEDB_SignkeyMetaData
|
|
|
|
|
-> I think it could be something = to FutureSignKey.t
|
|
|
|
|
- master signature: over smthing? *)
|
2025-11-21 19:29:04 +01:00
|
|
|
let activate_signing_key _cls (exchange_public_key : Signkey.t) =
|
|
|
|
|
(*let open Bin_type in*)
|
|
|
|
|
let _exchange_pub = EddsaPublicKey.(to_octets exchange_public_key.pub) in
|
|
|
|
|
let _master_sig =
|
|
|
|
|
exchange_public_key.master_sig |> Option.get
|
|
|
|
|
(*|> EddsaSignature.to_octets*)
|
|
|
|
|
in
|
|
|
|
|
let _insert_signkey =
|
|
|
|
|
Caqti_type.(t5 string ptime ptime ptime string ->! int)
|
|
|
|
|
"INSERT INTO exchange_sign_keys (exchange_pub, valid_from, expire_sign, \
|
|
|
|
|
expire_legal, master_sig) VALUES ($1, $2, $3, $4, $5);"
|
|
|
|
|
in
|
|
|
|
|
pg_todo ()
|
2025-11-16 15:55:32 +01:00
|
|
|
|
|
|
|
|
(*
|
|
|
|
|
|
|
|
|
|
enum GNUNET_DB_QueryStatus
|
|
|
|
|
TEH_PG_activate_signing_key (
|
|
|
|
|
void *cls,
|
|
|
|
|
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
|
|
|
|
const struct TALER_EXCHANGEDB_SignkeyMetaData *meta,
|
|
|
|
|
const struct TALER_MasterSignatureP *master_sig)
|
|
|
|
|
{
|
|
|
|
|
struct PostgresClosure *pg = cls;
|
|
|
|
|
struct GNUNET_PQ_QueryParam iparams[] = {
|
|
|
|
|
GNUNET_PQ_query_param_auto_from_type (exchange_pub),
|
|
|
|
|
GNUNET_PQ_query_param_timestamp (&meta->start),
|
|
|
|
|
GNUNET_PQ_query_param_timestamp (&meta->expire_sign),
|
|
|
|
|
GNUNET_PQ_query_param_timestamp (&meta->expire_legal),
|
|
|
|
|
GNUNET_PQ_query_param_auto_from_type (master_sig),
|
|
|
|
|
GNUNET_PQ_query_param_end
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
*)
|
|
|
|
|
|
|
|
|
|
(* ----- *)
|
|
|
|
|
|
2025-11-16 05:33:06 +01:00
|
|
|
let lookup_signing_key = pg_todo
|
|
|
|
|
let iterate_active_signkeys = pg_todo
|
|
|
|
|
let insert_signkey_revocation = pg_todo
|
|
|
|
|
let lookup_signkey_revocation = pg_todo
|
|
|
|
|
|
|
|
|
|
(* denominations *)
|
|
|
|
|
let insert_denomination_info = pg_todo
|
|
|
|
|
let get_denomination_info = pg_todo
|
|
|
|
|
let get_denomination_by_serial = pg_todo
|
|
|
|
|
let iterate_denomination_info = pg_todo
|
|
|
|
|
let iterate_denominations = pg_todo
|
|
|
|
|
let get_coin_denomination = pg_todo
|
|
|
|
|
let insert_denomination_revocation = pg_todo
|
|
|
|
|
let get_denomination_revocation = pg_todo
|
|
|
|
|
let lookup_denomination_key = pg_todo
|
|
|
|
|
let add_denomination_key = pg_todo
|