JJ: Description from the destination commit:

wip fix taler_amount, lookup_denomination_key

JJ: Description from source commit:
.
This commit is contained in:
swrup 2025-12-07 04:05:15 +01:00
parent 0c8ea5ba65
commit facada9638
3 changed files with 46 additions and 4 deletions

View file

@ -179,6 +179,42 @@ let update_master_signatures ~db_conn ~sm_signkey ~sm_denom
(h_denom_pub, master_sig)) (h_denom_pub, master_sig))
|> Secmod_denom.add_master_signatures db_conn sm_denom |> Secmod_denom.add_master_signatures db_conn sm_denom
in in
let* () =
(* TODO move to test *)
Secmod_denom.get_denoms sm_denom
|> list_iter (fun denom ->
let error = Error "update_master_signatures sanity check failure" in
let* opt =
Pg.lookup_denomination_key db_conn denom.Denomination.h_pub
|> unwrap_err_caqti
in
let* ( valid_from,
_expire_withdraw,
_expire_deposit,
_expire_legal,
coin,
_fee_withdraw,
_fee_deposit,
_fee_refresh,
fee_refund,
age_mask ) =
match opt with None -> error | Some v -> Ok v
in
let check = function false -> error | true -> Ok () in
(* TODO time *)
let timestamp_equal a b =
let timestamp_to_int64 = function
| None -> None
| Some v -> v |> Ptime.to_float_s |> Int64.of_float |> Option.some
in
timestamp_to_int64 a = timestamp_to_int64 b
in
let* () = check (timestamp_equal valid_from denom.stamp_start) in
let* () = check (coin = denom.value) in
let* () = check (fee_refund = denom.fee_refund) in
let* () = check (age_mask = denom.age_mask) in
Ok ())
in
Ok () Ok ()
(* --- *) (* --- *)
@ -200,7 +236,10 @@ let respond_with_ok_json content req =
let respond_with_res res req = let respond_with_res res req =
match res with match res with
| Error err -> respond_with_plain_text_error err req | Error err ->
Logs.err (fun m -> m "%s." err);
let err = Fmt.str "%s@." err in
respond_with_plain_text_error err req
| Ok content -> respond_with_ok_json content req | Ok content -> respond_with_ok_json content req
let keys_get req server _env = let keys_get req server _env =

View file

@ -110,8 +110,10 @@ let lookup_denomination_key =
Caqti_type.( Caqti_type.(
denomination_hash denomination_hash
->? t10 time time time time amount amount amount amount amount age_mask) ->? t10 time time time time amount amount amount amount amount age_mask)
"SELECT valid_from, expire_withdraw, expire_deposit, expire_legal, coin, \ "SELECT valid_from, expire_withdraw, expire_deposit, expire_legal, \
fee_withdraw, fee_deposit, fee_refresh, fee_refund, age_mask FROM \ (coin).val, (coin).frac, (fee_withdraw).val, (fee_withdraw).frac, \
(fee_deposit).val, (fee_deposit).frac, (fee_refresh).val, \
(fee_refresh).frac, (fee_refund).val, (fee_refund).frac, age_mask FROM \
denominations WHERE denom_pub_hash=$1" denominations WHERE denom_pub_hash=$1"
in in
fun (module Conn : CONN) (h_denom_pub : DenominationHash.t) -> fun (module Conn : CONN) (h_denom_pub : DenominationHash.t) ->

View file

@ -1,5 +1,6 @@
(* TODO time (* TODO time
not sure about this *) uhuh!
need to be int64 for binary/pg round trip *)
type t = Ptime.t option type t = Ptime.t option
type span = Ptime.Span.t option type span = Ptime.Span.t option