This commit is contained in:
parent
355b24ff44
commit
07bed9cdce
5 changed files with 33 additions and 37 deletions
20
src/keys.ml
20
src/keys.ml
|
|
@ -48,8 +48,8 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
| Ok v -> v
|
||||
|
||||
(* - *)
|
||||
let find_signkey pub = Pg.find_signkey conn pub |> unwrap_err_caqti
|
||||
let find_denomination h_pub = Pg.find_denom conn h_pub |> unwrap_err_caqti
|
||||
let find_signkey pub = Pg.find_signkey conn pub |> unwrap_caqti
|
||||
let find_denomination h_pub = Pg.find_denom conn h_pub |> unwrap_caqti
|
||||
|
||||
let warn_key_state =
|
||||
let first = ref true in
|
||||
|
|
@ -64,7 +64,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
|
||||
let signkeys () : Signkey.t list result =
|
||||
let now = Timestamp.of_ptime @@ Ptime_clock.now () in
|
||||
let+ l = Pg.get_signkeys conn ~now |> unwrap_err_caqti in
|
||||
let+ l = Pg.get_signkeys conn ~now |> unwrap_caqti in
|
||||
let missing_l, l =
|
||||
List.partition
|
||||
(fun sk -> Option.is_none @@ Sm_eddsa.find_key sk.Signkey.pub)
|
||||
|
|
@ -78,7 +78,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
l
|
||||
|
||||
let denominations () =
|
||||
let+ l = Pg.get_denominations conn () |> unwrap_err_caqti in
|
||||
let+ l = Pg.get_denominations conn () |> unwrap_caqti in
|
||||
let missing_l, l =
|
||||
List.partition
|
||||
(fun dn -> Option.is_none @@ Sm_rsa.find_key dn.Denomination.h_pub)
|
||||
|
|
@ -200,7 +200,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
let make_future_keys_response () =
|
||||
let now = Timestamp.of_ptime @@ Ptime_clock.now () in
|
||||
(* get keys from database to filter out keys already certified *)
|
||||
let* sk_db_l = Pg.get_signkeys conn ~now |> unwrap_err_caqti in
|
||||
let* sk_db_l = Pg.get_signkeys conn ~now |> unwrap_caqti in
|
||||
let sk_ht = Hashtbl.create 0xff in
|
||||
List.iter (fun sk -> Hashtbl.replace sk_ht sk.Signkey.pub ()) sk_db_l;
|
||||
let future_signkeys =
|
||||
|
|
@ -208,7 +208,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
|> List.filter (fun (pub, _) -> not @@ Hashtbl.mem sk_ht pub)
|
||||
|> List.map make_future_sk
|
||||
in
|
||||
let* dn_db_l = Pg.get_denominations conn () |> unwrap_err_caqti in
|
||||
let* dn_db_l = Pg.get_denominations conn () |> unwrap_caqti in
|
||||
let dn_ht = Hashtbl.create 0xff in
|
||||
List.iter (fun dn -> Hashtbl.replace dn_ht dn.Denomination.h_pub ()) dn_db_l;
|
||||
let future_denoms =
|
||||
|
|
@ -302,7 +302,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
(* rebuild it *)
|
||||
let future_sk = make_future_sk (pub, (t1, t2)) in
|
||||
let sk = sk_of_future_sk future_sk master_sig in
|
||||
let+ () = Pg.insert_signkey conn sk |> unwrap_err_caqti in
|
||||
let+ () = Pg.insert_signkey conn sk |> unwrap_caqti in
|
||||
Logs.info (fun m ->
|
||||
m "certified signkey `%s`" (EddsaPublicKey.to_b32 sk.pub));
|
||||
())
|
||||
|
|
@ -320,7 +320,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
| None ->
|
||||
let future_dn = make_future_dn (h_pub, (section_name, pub, t1)) in
|
||||
let dn = dn_of_future_dn future_dn h_pub master_sig in
|
||||
let+ () = Pg.insert_denom conn dn |> unwrap_err_caqti in
|
||||
let+ () = Pg.insert_denom conn dn |> unwrap_caqti in
|
||||
Logs.info (fun m ->
|
||||
m "certified denomination `%s`"
|
||||
(DenominationHash.to_b32 dn.h_pub));
|
||||
|
|
@ -331,7 +331,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
let* _sk = Option.to_result ~none:"signkey not found" opt in
|
||||
let* () = Sm_eddsa.revoke pub in
|
||||
let+ () =
|
||||
Pg.insert_signkey_revocation conn pub revoked_sig |> unwrap_err_caqti
|
||||
Pg.insert_signkey_revocation conn pub revoked_sig |> unwrap_caqti
|
||||
in
|
||||
Logs.info (fun m -> m "revoked signkey `%s`" (EddsaPublicKey.to_b32 pub));
|
||||
()
|
||||
|
|
@ -342,7 +342,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
let* () = Sm_rsa.revoke dn.h_pub in
|
||||
let+ () =
|
||||
Pg.insert_denomination_revocation conn dn.h_pub revoked_sig
|
||||
|> unwrap_err_caqti
|
||||
|> unwrap_caqti
|
||||
in
|
||||
Logs.info (fun m ->
|
||||
m "revoked denomination `%s`" (DenominationHash.to_b32 h_pub));
|
||||
|
|
|
|||
|
|
@ -41,13 +41,11 @@ let mk_keys ~db_conn (module Keys : Keys.S) ~last_issue_date =
|
|||
let stefan_lin = Config.stefan_lin in
|
||||
(* type of the asset. "fiat", "crypto", "regional" or "stock". *)
|
||||
let asset_type = "fiat" in
|
||||
let* accounts = Pg.get_wire_accounts db_conn () |> unwrap_err_caqti in
|
||||
let* accounts = Pg.get_wire_accounts db_conn () |> unwrap_caqti in
|
||||
let* wire_fees =
|
||||
(* wire_methods? *)
|
||||
let wire_method = "x-taler-bank" in
|
||||
let+ wire_fees =
|
||||
Pg.get_wire_fees db_conn ~wire_method |> unwrap_err_caqti
|
||||
in
|
||||
let+ wire_fees = Pg.get_wire_fees db_conn ~wire_method |> unwrap_caqti in
|
||||
String_map.singleton wire_method wire_fees
|
||||
in
|
||||
let wads = [] in
|
||||
|
|
@ -111,7 +109,7 @@ let mk_keys ~db_conn (module Keys : Keys.S) ~last_issue_date =
|
|||
|
||||
let recoup = (* /recoup *) [] in
|
||||
let* global_fees =
|
||||
Pg.get_global_fees db_conn ~start_date:Timestamp.zero |> unwrap_err_caqti
|
||||
Pg.get_global_fees db_conn ~start_date:Timestamp.zero |> unwrap_caqti
|
||||
in
|
||||
let* auditors =
|
||||
(* /auditors/$AUDITOR_PUB/$H_DENOM_PUB *)
|
||||
|
|
|
|||
|
|
@ -114,18 +114,18 @@ module Auditors = struct
|
|||
let do_ ~db_conn v =
|
||||
let auditor_pub = v.AuditorSetupMessage.auditor_pub in
|
||||
let validity_start = v.AuditorSetupMessage.validity_start in
|
||||
let* opt = Pg.find_auditor db_conn auditor_pub |> unwrap_err_caqti in
|
||||
let* opt = Pg.find_auditor db_conn auditor_pub |> unwrap_caqti in
|
||||
match opt with
|
||||
| None ->
|
||||
let auditor = Auditor.of_setup_message v in
|
||||
let+ () = Pg.update_auditor db_conn auditor |> unwrap_err_caqti in
|
||||
let+ () = Pg.update_auditor db_conn auditor |> unwrap_caqti in
|
||||
Logs.info (fun m -> m "enabled auditor");
|
||||
()
|
||||
| Some auditor ->
|
||||
if Timestamp.compare validity_start auditor.last_change <= 0 then
|
||||
Error "replay detected on enable-auditor"
|
||||
else
|
||||
let+ () = Pg.update_auditor db_conn auditor |> unwrap_err_caqti in
|
||||
let+ () = Pg.update_auditor db_conn auditor |> unwrap_caqti in
|
||||
Logs.info (fun m -> m "updated auditor");
|
||||
()
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ module Auditors_disable = struct
|
|||
|
||||
let do_ ~db_conn auditor_pub
|
||||
AuditorTeardownMessage.{ master_sig= _; validity_end } =
|
||||
let* opt = Pg.find_auditor db_conn auditor_pub |> unwrap_err_caqti in
|
||||
let* opt = Pg.find_auditor db_conn auditor_pub |> unwrap_caqti in
|
||||
match opt with
|
||||
| None -> Error "auditor not found"
|
||||
| Some auditor -> (
|
||||
|
|
@ -168,7 +168,7 @@ module Auditors_disable = struct
|
|||
let auditor =
|
||||
{ auditor with last_change= validity_end; is_active= false }
|
||||
in
|
||||
let+ () = Pg.update_auditor db_conn auditor |> unwrap_err_caqti in
|
||||
let+ () = Pg.update_auditor db_conn auditor |> unwrap_caqti in
|
||||
Logs.info (fun m ->
|
||||
m "revoked auditor `%s`"
|
||||
(Crypto.EddsaPublicKey.to_b32 auditor_pub));
|
||||
|
|
@ -215,11 +215,11 @@ module Wire_fee = struct
|
|||
let* wire_fees =
|
||||
Pg.get_wire_fees_by_time db_conn ~wire_method:v.wire_method
|
||||
~start_date:v.fee_start ~end_date:v.fee_end
|
||||
|> unwrap_err_caqti
|
||||
|> unwrap_caqti
|
||||
in
|
||||
match wire_fees with
|
||||
| [] ->
|
||||
let+ () = Pg.insert_wire_fee db_conn v |> unwrap_err_caqti in
|
||||
let+ () = Pg.insert_wire_fee db_conn v |> unwrap_caqti in
|
||||
Logs.info (fun m -> m "added wire fee");
|
||||
()
|
||||
| [ vv ] -> (
|
||||
|
|
@ -256,12 +256,11 @@ module Global_fees = struct
|
|||
let* global_fees =
|
||||
let start_date = v.GlobalFees.start_date in
|
||||
let end_date = v.GlobalFees.end_date in
|
||||
Pg.get_global_fees_by_time db_conn ~start_date ~end_date
|
||||
|> unwrap_err_caqti
|
||||
Pg.get_global_fees_by_time db_conn ~start_date ~end_date |> unwrap_caqti
|
||||
in
|
||||
match global_fees with
|
||||
| [] ->
|
||||
let+ () = Pg.insert_global_fees db_conn v |> unwrap_err_caqti in
|
||||
let+ () = Pg.insert_global_fees db_conn v |> unwrap_caqti in
|
||||
Logs.info (fun m -> m "added global fees");
|
||||
()
|
||||
| [ vv ] -> (
|
||||
|
|
@ -362,7 +361,7 @@ module Wire = struct
|
|||
bank_label;
|
||||
priority;
|
||||
} =
|
||||
let* opt = Pg.find_wire db_conn ~payto_uri |> unwrap_err_caqti in
|
||||
let* opt = Pg.find_wire db_conn ~payto_uri |> unwrap_caqti in
|
||||
match opt with
|
||||
| None ->
|
||||
let wire =
|
||||
|
|
@ -380,7 +379,7 @@ module Wire = struct
|
|||
let+ () =
|
||||
Pg.update_wire db_conn ~is_active:true ~last_change:validity_start
|
||||
wire
|
||||
|> unwrap_err_caqti
|
||||
|> unwrap_caqti
|
||||
in
|
||||
Logs.info (fun m -> m "added wire method");
|
||||
()
|
||||
|
|
@ -391,7 +390,7 @@ module Wire = struct
|
|||
let+ () =
|
||||
Pg.update_wire db_conn ~is_active:true ~last_change:validity_start
|
||||
wire
|
||||
|> unwrap_err_caqti
|
||||
|> unwrap_caqti
|
||||
in
|
||||
Logs.info (fun m -> m "updated wire method");
|
||||
()
|
||||
|
|
@ -420,7 +419,7 @@ module Wire_disable = struct
|
|||
|
||||
let do_ ~db_conn
|
||||
WireTeardownMessage.{ payto_uri; master_sig_del= _; validity_end } =
|
||||
let* opt = Pg.find_wire db_conn ~payto_uri |> unwrap_err_caqti in
|
||||
let* opt = Pg.find_wire db_conn ~payto_uri |> unwrap_caqti in
|
||||
match opt with
|
||||
| None -> Error "wire not found"
|
||||
| Some (wire, _is_active, last_change) ->
|
||||
|
|
@ -430,7 +429,7 @@ module Wire_disable = struct
|
|||
let+ () =
|
||||
Pg.update_wire db_conn ~is_active:false ~last_change:validity_end
|
||||
wire
|
||||
|> unwrap_err_caqti
|
||||
|> unwrap_caqti
|
||||
in
|
||||
Logs.info (fun m -> m "disabled wire method");
|
||||
()
|
||||
|
|
@ -473,15 +472,14 @@ module Drain = struct
|
|||
|
||||
let do_ ~db_conn v =
|
||||
let* opt =
|
||||
Pg.find_drain_profit db_conn v.DrainProfitsMessage.wtid
|
||||
|> unwrap_err_caqti
|
||||
Pg.find_drain_profit db_conn v.DrainProfitsMessage.wtid |> unwrap_caqti
|
||||
in
|
||||
match opt with
|
||||
| Some _ ->
|
||||
Logs.info (fun m -> m "drain profit message already added to database");
|
||||
Ok ()
|
||||
| None ->
|
||||
let+ () = Pg.insert_drain_profit db_conn v |> unwrap_err_caqti in
|
||||
let+ () = Pg.insert_drain_profit db_conn v |> unwrap_caqti in
|
||||
Logs.info (fun m -> m "added drain profit message to database");
|
||||
()
|
||||
|
||||
|
|
@ -522,7 +520,7 @@ module AmlOfficer = struct
|
|||
}
|
||||
|
||||
let do_ ~db_conn v =
|
||||
let+ _last_change = Pg.insert_aml_officer db_conn v |> unwrap_err_caqti in
|
||||
let+ _last_change = Pg.insert_aml_officer db_conn v |> unwrap_caqti in
|
||||
()
|
||||
|
||||
let jsont = AmlOfficerSetup.jsont
|
||||
|
|
@ -564,7 +562,7 @@ module Partners = struct
|
|||
}
|
||||
|
||||
let do_ ~db_conn v =
|
||||
let+ () = Pg.insert_partner db_conn v |> unwrap_err_caqti in
|
||||
let+ () = Pg.insert_partner db_conn v |> unwrap_caqti in
|
||||
()
|
||||
|
||||
let jsont = ExchangePartnerSetupRequest.jsont
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ let get_auditor_keys =
|
|||
in
|
||||
fun (module Conn : CONN) ->
|
||||
let open Syntax in
|
||||
let* l = Conn.collect_list req () |> unwrap_err_caqti in
|
||||
let* l = Conn.collect_list req () |> unwrap_caqti in
|
||||
let ht = Hashtbl.create 0xff in
|
||||
List.iter
|
||||
(fun (pub, url, name, denom_pub_h, auditor_sig) ->
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ let ( let+ ) o f = match o with Ok v -> Ok (f v) | Error _ as e -> e
|
|||
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
|
||||
let unwrap_msg o = match o with Error (`Msg e) -> Error e | Ok v -> Ok v
|
||||
|
||||
let unwrap_err_caqti o =
|
||||
let unwrap_caqti o =
|
||||
match o with Error err -> Fmt.error "%a" Caqti_error.pp err | Ok v -> Ok v
|
||||
|
||||
let list_iter f l =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue