90 lines
2.2 KiB
OCaml
90 lines
2.2 KiB
OCaml
open Crypto
|
|
|
|
type t = {
|
|
pub: rsa_pub;
|
|
value: Amount.t;
|
|
stamp_start: Timestamp.t;
|
|
stamp_expire_withdraw: Timestamp.t;
|
|
stamp_expire_deposit: Timestamp.t;
|
|
stamp_expire_legal: Timestamp.t;
|
|
fee_withdraw: Amount.t;
|
|
fee_deposit: Amount.t;
|
|
fee_refresh: Amount.t;
|
|
fee_refund: Amount.t;
|
|
age_mask: int;
|
|
h_pub: denom_hash;
|
|
master_sig: Signatures.DenominationKeyValidity.t;
|
|
}
|
|
|
|
let make_denom_group denominations =
|
|
let open Syntax in
|
|
let ht = Hashtbl.create 0xff in
|
|
List.iter
|
|
(fun coin ->
|
|
let open Config.Coin in
|
|
assert (coin.cipher = `RSA);
|
|
let k =
|
|
( coin.value,
|
|
coin.fee_withdraw,
|
|
coin.fee_deposit,
|
|
coin.fee_refresh,
|
|
coin.fee_refund )
|
|
in
|
|
let v = [] in
|
|
Hashtbl.replace ht k v)
|
|
Config.Coin.all_coins;
|
|
let+ () =
|
|
list_iter
|
|
(fun {
|
|
pub;
|
|
value;
|
|
stamp_start;
|
|
stamp_expire_withdraw;
|
|
stamp_expire_deposit;
|
|
stamp_expire_legal;
|
|
fee_withdraw;
|
|
fee_deposit;
|
|
fee_refresh;
|
|
fee_refund;
|
|
age_mask= _;
|
|
h_pub= _;
|
|
master_sig;
|
|
} ->
|
|
let k = (value, fee_withdraw, fee_deposit, fee_refresh, fee_refund) in
|
|
let v =
|
|
Api.RsaDenom.
|
|
{
|
|
rsa_pub= pub;
|
|
master_sig;
|
|
stamp_start;
|
|
stamp_expire_withdraw;
|
|
stamp_expire_deposit;
|
|
stamp_expire_legal;
|
|
lost= None;
|
|
}
|
|
in
|
|
let+ l =
|
|
match Hashtbl.find_opt ht k with
|
|
| None ->
|
|
Error "denomination does not match any coin in configuration"
|
|
| Some l -> Ok l
|
|
in
|
|
Hashtbl.replace ht k (v :: l))
|
|
denominations
|
|
in
|
|
Hashtbl.to_seq ht
|
|
|> List.of_seq
|
|
|> List.map
|
|
(fun
|
|
((value, fee_withdraw, fee_deposit, fee_refresh, fee_refund), denoms)
|
|
->
|
|
Api.DenomGroup.Rsa
|
|
Api.RsaDenomGroup.
|
|
{
|
|
denoms;
|
|
value;
|
|
fee_withdraw;
|
|
fee_deposit;
|
|
fee_refresh;
|
|
fee_refund;
|
|
})
|