+ wip DenomGroup
This commit is contained in:
parent
b5f9e602a3
commit
5a941ee497
1 changed files with 58 additions and 0 deletions
58
src/api.ml
58
src/api.ml
|
|
@ -963,3 +963,61 @@ module DenomCommon = struct
|
||||||
|> mem "lost" (Jsont.option Jsont.bool) ~enc:lost
|
|> mem "lost" (Jsont.option Jsont.bool) ~enc:lost
|
||||||
|> finish
|
|> finish
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module DenomGroupRsa = struct
|
||||||
|
type t = {
|
||||||
|
rsa_pub: RsaPublicKey.t;
|
||||||
|
value: Amount.t;
|
||||||
|
fee_withdraw: Amount.t;
|
||||||
|
fee_deposit: Amount.t;
|
||||||
|
fee_refresh: Amount.t;
|
||||||
|
fee_refund: Amount.t;
|
||||||
|
}
|
||||||
|
|
||||||
|
let jsont =
|
||||||
|
let make rsa_pub value fee_withdraw fee_deposit fee_refresh fee_refund =
|
||||||
|
{ rsa_pub; value; fee_withdraw; fee_deposit; fee_refresh; fee_refund }
|
||||||
|
in
|
||||||
|
let rsa_pub v = v.rsa_pub in
|
||||||
|
let value v = v.value in
|
||||||
|
let fee_withdraw v = v.fee_withdraw in
|
||||||
|
let fee_deposit v = v.fee_deposit in
|
||||||
|
let fee_refresh v = v.fee_refresh in
|
||||||
|
let fee_refund v = v.fee_refund in
|
||||||
|
let open Jsont.Object in
|
||||||
|
map ~kind:"DenomGroupRsa" make
|
||||||
|
|> mem "rsa_pub" RsaPublicKey.jsont ~enc:rsa_pub
|
||||||
|
|> mem "value" Amount.jsont ~enc:value
|
||||||
|
|> mem "fee_withdraw" Amount.jsont ~enc:fee_withdraw
|
||||||
|
|> mem "fee_deposit" Amount.jsont ~enc:fee_deposit
|
||||||
|
|> mem "fee_refresh" Amount.jsont ~enc:fee_refresh
|
||||||
|
|> mem "fee_refund" Amount.jsont ~enc:fee_refund
|
||||||
|
|> finish
|
||||||
|
end
|
||||||
|
|
||||||
|
module DenomGroup = struct
|
||||||
|
(* TODO
|
||||||
|
type DenomGroup =
|
||||||
|
| DenomGroupRsa
|
||||||
|
| DenomGroupCs
|
||||||
|
| DenomGroupRsaAgeRestricted
|
||||||
|
| DenomGroupCsAgeRestricted;
|
||||||
|
*)
|
||||||
|
type t = Rsa of DenomGroupRsa.t
|
||||||
|
|
||||||
|
let to_octets = function Rsa denom -> RsaPublicKey.to_octets denom.rsa_pub
|
||||||
|
|
||||||
|
let of_cs _v =
|
||||||
|
Jsont.Error.msg Jsont.Meta.none "CSDenominationKey are not supported"
|
||||||
|
|
||||||
|
let of_rsa v = Rsa v
|
||||||
|
|
||||||
|
let jsont =
|
||||||
|
let open Jsont.Object in
|
||||||
|
let rsa = Case.map "RSA" DenomGroupRsa.jsont ~dec:of_rsa in
|
||||||
|
let enc_case = function Rsa v -> Case.value rsa v in
|
||||||
|
let cases = Case.[ make rsa ] in
|
||||||
|
map ~kind:"DenomGroup" Fun.id
|
||||||
|
|> case_mem "cipher" Jsont.string ~enc:Fun.id ~enc_case cases
|
||||||
|
|> finish
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue