add /management/auditors (untested)
This commit is contained in:
parent
399a977c2d
commit
a7b205b33e
6 changed files with 119 additions and 17 deletions
55
src/pg.ml
55
src/pg.ml
|
|
@ -28,9 +28,9 @@ module Caqti_type = struct
|
|||
let ptime : Ptime.t option t = Timestamp.caqti
|
||||
let time = Timestamp.caqti
|
||||
let age_mask : int t = Caqti_type.int
|
||||
let rsa_public = RsaPublicKey.caqti
|
||||
let eddsa_public = EddsaPublicKey.caqti
|
||||
let eddsa_signature = EddsaSignature.caqti
|
||||
let rsa_pub = RsaPublicKey.caqti
|
||||
let eddsa_pub = EddsaPublicKey.caqti
|
||||
let eddsa_sig = EddsaSignature.caqti
|
||||
|
||||
include struct
|
||||
(* alias for hash *)
|
||||
|
|
@ -68,7 +68,7 @@ let preflight =
|
|||
|
||||
let lookup_signing_key =
|
||||
let lookup_signing_key =
|
||||
Caqti_type.(eddsa_public ->? t3 time time time)
|
||||
Caqti_type.(eddsa_pub ->? t3 time time time)
|
||||
"SELECT valid_from, expire_sign, expire_legal FROM exchange_sign_keys \
|
||||
WHERE exchange_pub=$1"
|
||||
in
|
||||
|
|
@ -78,7 +78,7 @@ let lookup_signing_key =
|
|||
let activate_signing_key =
|
||||
let insert_signkey =
|
||||
let master_sig = Bin_sig.ExchangeSigningKeyValidity.caqti in
|
||||
Caqti_type.(t5 eddsa_public time time time master_sig ->. unit)
|
||||
Caqti_type.(t5 eddsa_pub time time time master_sig ->. unit)
|
||||
"INSERT INTO exchange_sign_keys (exchange_pub, valid_from, expire_sign, \
|
||||
expire_legal, master_sig) VALUES ($1, $2, $3, $4, $5)"
|
||||
in
|
||||
|
|
@ -114,8 +114,8 @@ let add_denomination_key =
|
|||
let denomination_insert =
|
||||
let master_sig = Bin_sig.DenominationKeyValidity.caqti in
|
||||
Caqti_type.(
|
||||
t12 denomination_hash rsa_public master_sig time time time time amount
|
||||
amount amount amount (t2 amount age_mask)
|
||||
t12 denomination_hash rsa_pub master_sig time time time time amount amount
|
||||
amount amount (t2 amount age_mask)
|
||||
->. unit)
|
||||
"INSERT INTO denominations (denom_pub_hash, denom_pub, master_sig, \
|
||||
valid_from, expire_withdraw, expire_deposit, expire_legal, coin, \
|
||||
|
|
@ -173,9 +173,48 @@ let insert_denomination_revocation =
|
|||
let insert_signkey_revocation =
|
||||
let signkey_revocation_insert =
|
||||
let master_sig = Bin_sig.MasterSigningKeyRevocation.caqti in
|
||||
Caqti_type.(t2 eddsa_public master_sig ->. unit)
|
||||
Caqti_type.(t2 eddsa_pub master_sig ->. unit)
|
||||
"INSERT INTO signkey_revocations (esk_serial, master_sig) SELECT \
|
||||
esk_serial, $2 FROM exchange_sign_keys WHERE exchange_pub=$1"
|
||||
in
|
||||
fun (module Conn : CONN) exchange_pub master_sig ->
|
||||
Conn.exec signkey_revocation_insert (exchange_pub, master_sig)
|
||||
|
||||
let lookup_auditor_timestamp =
|
||||
let lookup_auditor_timestamp =
|
||||
Caqti_type.(eddsa_pub ->? time)
|
||||
"lookup_auditor_timestamp SELECT last_change FROM auditors WHERE \
|
||||
auditor_pub=$1"
|
||||
in
|
||||
fun (module Conn : CONN) auditor_pub ->
|
||||
Conn.find_opt lookup_auditor_timestamp auditor_pub
|
||||
|
||||
let insert_auditor =
|
||||
let insert_auditor =
|
||||
Caqti_type.(t4 eddsa_pub string string time ->. unit)
|
||||
"INSERT INTO auditors (auditor_pub, auditor_name, auditor_url, \
|
||||
is_active, last_change) VALUES ($1, $2, $3, true, $4)"
|
||||
in
|
||||
fun (module Conn : CONN)
|
||||
~auditor_pub
|
||||
~auditor_url
|
||||
~auditor_name
|
||||
~start_date
|
||||
->
|
||||
Conn.exec insert_auditor (auditor_pub, auditor_name, auditor_url, start_date)
|
||||
|
||||
let update_auditor =
|
||||
let update_auditor =
|
||||
Caqti_type.(t5 eddsa_pub string string bool time ->. unit)
|
||||
"UPDATE auditors SET auditor_url=$2, auditor_name=$3, is_active=$4, \
|
||||
last_change=$5 WHERE auditor_pub=$1"
|
||||
in
|
||||
fun (module Conn : CONN)
|
||||
~auditor_pub
|
||||
~auditor_url
|
||||
~auditor_name
|
||||
~change_date
|
||||
~enabled
|
||||
->
|
||||
Conn.exec update_auditor
|
||||
(auditor_pub, auditor_url, auditor_name, enabled, change_date)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue